Permalink
Browse files

Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git …

…into develop
  • Loading branch information...
eldy committed Feb 22, 2012
2 parents ef6706a + bb9a63c commit 3a915de69a1ebea2c0c05195a5679aae81708f98
View
@@ -23,7 +23,7 @@ TCPDF 5.9.098 LGPL 3.0 Yes PDF generation
JS libraries:
jQuery 1.7.1 GPL and MIT Licence Yes JS library
-jQuery UI 1.8.16 GPL and MIT Licence Yes JS library plugin UI
+jQuery UI 1.8.17 GPL and MIT Licence Yes JS library plugin UI
jQuery Colorpicker 1.1 MIT Licence Yes JS library for color picker for a defined list of colors
jQuery DataTable 1.8.1 BSD Yes JS library for tables output
jQuery Flot 0.7 MIT Licence Yes JS library to build graph
View
@@ -50,8 +50,9 @@ For users:
- New: Extra fields support int type.
- New: Add brazilian states.
- New: Increase usability of module project.
-- New: Automtic list of documents in ECM module is ok for customers,
+- New: Automatic list of documents in ECM module is ok for customers,
suppliers invoice, orders, customers orders, proposals and social contributions.
+- New: [ task #176 ] Allow to use ODT templates for proposals and orders like it's done for invoices
- Fix: Can use POS module with several concurrent users.
- Fix: Installer don't fails with Mysql version that added a ssl_cypher field.
View
@@ -126,26 +126,20 @@
}
// Suppression de la propale
-else if ($action == 'confirm_delete' && $confirm == 'yes')
+else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propale->supprimer)
{
- if ($user->rights->propale->supprimer)
+ $object->fetch($id);
+ $result=$object->delete($user);
+ if ($result > 0)
{
- $object->fetch($id);
- $result=$object->delete($user);
- $id = 0;
- $brouillon = 1;
-
- if ($result > 0)
- {
- Header('Location: '.$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- $langs->load("errors");
- if ($object->error == 'ErrorFailToDeleteDir') $mesg='<div class="error">'.$langs->trans('ErrorFailedToDeleteJoinedFiles').'</div>';
- else $mesg='<div class="error">'.$object->error.'</div>';
- }
+ Header('Location: '.$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ $langs->load("errors");
+ if ($object->error == 'ErrorFailToDeleteDir') $mesg='<div class="error">'.$langs->trans('ErrorFailedToDeleteJoinedFiles').'</div>';
+ else $mesg='<div class="error">'.$object->error.'</div>';
}
}
@@ -86,6 +86,7 @@ class Commande extends CommonObject
var $origin;
var $origin_id;
+ var $linked_objects=array();
var $user_author_id;
@@ -706,37 +707,44 @@ function create($user, $notrigger=0)
if ($this->id)
{
$this->ref="(PROV".$this->id.")";
-
- // Add linked object
- if ($this->origin && $this->origin_id)
- {
- $ret = $this->add_object_linked();
- if (! $ret) dol_print_error($this->db);
- }
-
- // TODO mutualiser
- if ($this->origin == 'propal' && $this->origin_id)
+
+ // Add object linked
+ if (is_array($this->linked_objects) && ! empty($this->linked_objects))
{
- // On recupere les differents contact interne et externe
- $prop = new Propal($this->db, $this->socid, $this->origin_id);
-
- // On recupere le commercial suivi propale
- $this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL');
-
- if ($this->userid)
- {
- //On passe le commercial suivi propale en commercial suivi commande
- $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
- }
-
- // On recupere le contact client suivi propale
- $this->contactid = $prop->getIdcontact('external', 'CUSTOMER');
-
- if ($this->contactid)
- {
- //On passe le contact client suivi propale en contact client suivi commande
- $this->add_contact($this->contactid[0], 'CUSTOMER', 'external');
- }
+ foreach($this->linked_objects as $origin => $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ dol_print_error($this->db);
+ $error++;
+ }
+
+ // TODO mutualiser
+ if ($origin == 'propal' && $origin_id)
+ {
+ // On recupere les differents contact interne et externe
+ $prop = new Propal($this->db, $this->socid, $origin_id);
+
+ // On recupere le commercial suivi propale
+ $this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL');
+
+ if ($this->userid)
+ {
+ //On passe le commercial suivi propale en commercial suivi commande
+ $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
+ }
+
+ // On recupere le contact client suivi propale
+ $this->contactid = $prop->getIdcontact('external', 'CUSTOMER');
+
+ if ($this->contactid)
+ {
+ //On passe le contact client suivi propale en contact client suivi commande
+ $this->add_contact($this->contactid[0], 'CUSTOMER', 'external');
+ }
+ }
+ }
}
}
View
@@ -2,7 +2,7 @@
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
- * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
+ * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
@@ -229,6 +229,13 @@
$object->origin = $_POST['origin'];
$object->origin_id = $_POST['originid'];
+
+ // Possibility to add external linked objects with hooks
+ $object->linked_objects[$object->origin] = $object->origin_id;
+ if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects']))
+ {
+ $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
+ }
$object_id = $object->create($user);
@@ -1368,7 +1375,7 @@
}
// Other attributes
- $parameters=array('colspan' => ' colspan="3"');
+ $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
View
@@ -3,7 +3,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
- * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
+ * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
@@ -742,6 +742,13 @@
$object->origin = $_POST['origin'];
$object->origin_id = $_POST['originid'];
+
+ // Possibility to add external linked objects with hooks
+ $object->linked_objects[$object->origin] = $object->origin_id;
+ if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects']))
+ {
+ $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
+ }
$id = $object->create($user);
@@ -1802,7 +1809,7 @@
}
// Other attributes
- $parameters=array('colspan' => ' colspan="3"');
+ $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
@@ -2737,7 +2744,7 @@
include(DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php');
}
- print '<table id="tablelines" class="noborder" width="100%">';
+ print '<table id="tablelines" class="noborder noshadow" width="100%">';
// Show object lines
if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager);
@@ -90,6 +90,7 @@ class Facture extends CommonObject
var $fk_facture_source;
var $origin;
var $origin_id;
+ var $linked_objects=array();
var $fk_project;
var $date_lim_reglement;
var $cond_reglement_id; // Id in llx_c_paiement
@@ -242,14 +243,17 @@ function create($user,$notrigger=0,$forceduedate=0)
if (! $resql) $error++;
// Add object linked
- if (! $error && $this->id && $this->origin && $this->origin_id)
- {
- $ret = $this->add_object_linked();
- if (! $ret)
- {
- dol_print_error($this->db);
- $error++;
- }
+ if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
+ {
+ foreach($this->linked_objects as $origin => $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ dol_print_error($this->db);
+ $error++;
+ }
+ }
}
/*
@@ -1458,12 +1458,17 @@ function update_price($exclspec=0,$roundingadjust=-1)
}
/**
- * Add objects linked in llx_element_element.
+ * Add objects linked in llx_element_element.
*
- * @return int <=0 if KO, >0 if OK
+ * @param string $origin Linked element type
+ * @param int $origin_id Linked element id
+ * @return int <=0 if KO, >0 if OK
*/
- function add_object_linked()
+ function add_object_linked($origin=null, $origin_id=null)
{
+ $origin = (! empty($origin) ? $origin : $this->origin);
+ $origin_id = (! empty($origin_id) ? $origin_id : $this->origin_id);
+
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
@@ -1472,8 +1477,8 @@ function add_object_linked()
$sql.= ", fk_target";
$sql.= ", targettype";
$sql.= ") VALUES (";
- $sql.= $this->origin_id;
- $sql.= ", '".$this->origin."'";
+ $sql.= $origin_id;
+ $sql.= ", '".$origin."'";
$sql.= ", ".$this->id;
$sql.= ", '".$this->element."'";
$sql.= ")";
@@ -1685,8 +1690,10 @@ function updateObjectLinked($sourceid='', $sourcetype='', $targetid='', $targett
function deleteObjectLinked()
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
- $sql.= " WHERE fk_target = ".$this->id;
- $sql.= " AND targettype = '".$this->element."'";
+ $sql.= " WHERE";
+ $sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->element."')";
+ $sql.= " OR";
+ $sql.= " (fk_target = ".$this->id." AND targettype = '".$this->element."')";
dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
@@ -235,7 +235,13 @@ function setValues($db)
$rootfordata = DOL_DATA_ROOT;
$rootforuser = DOL_DATA_ROOT;
// If multicompany module is enabled, we redefine the root of data
- if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity) && $this->entity > 1) $rootfordata.='/'.$this->entity;
+ if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity) && $this->entity > 1)
+ {
+ $rootfordata.='/'.$this->entity;
+ //var_dump($mc->sharings);
+ //var_dump($mc->referent);
+ //var_dump($mc->entities);
+ }
// For backward compatibility
// TODO Replace this->xxx->enabled by this->modulename->enabled to remove this code
@@ -86,7 +86,7 @@ function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='st
if ($perm)
{
$tmp=explode(':',$typeofdata);
- $ret.= '<div class="editkey_'.$tmp[0].'" id="'.$htmlname.'">';
+ $ret.= '<div class="editkey_'.$tmp[0].' '.$tmp[1].'" id="'.$htmlname.'">';
$ret.= $langs->trans($text);
$ret.= '</div>'."\n";
}
@@ -287,7 +287,7 @@ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
$pdf->SetFont('','',$default_font_size - 1);
$pdf->SetXY($this->posxdesc-1, $tab_top+1);
- $pdf->MultiCell(108, 2, $outputlangs->trans("Description"), '', 'L');
+ $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Description"), '', 'L');
$pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
@@ -117,7 +117,7 @@ function getNextValue($objsoc=0,$type=-1)
$sql = "SELECT MAX(SUBSTRING(".$field." FROM ".$posindice.")) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE ".$field." LIKE '".$prefix."____-%'";
- $sql.= " AND entity = ".getEntity('societe');
+ $sql.= " AND entity IN (".getEntity('societe', 1).")";
$resql=$db->query($sql);
if ($resql)
@@ -216,7 +216,7 @@ function verif_dispo($db, $code, $soc)
$sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE code_client = '".$code."'";
- $sql.= " AND entity = ".getEntity('societe');
+ $sql.= " AND entity IN (".getEntity('societe', 1).")";
if ($soc->id > 0) $sql.= " AND rowid != ".$soc->id;
dol_syslog(get_class($this)."::verif_dispo sql=".$sql, LOG_DEBUG);
@@ -1,8 +1,8 @@
<?php
-/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
- * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
+/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2009-2012 Regis Houssin <regis@dolibarr.fr>
+ * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -51,11 +51,11 @@ class ProductFournisseur extends Product
/**
* Constructor
*
- * @param DoliDB $DB Database handler
+ * @param DoliDB $db Database handler
*/
- function ProductFournisseur($DB)
+ function __construct($db)
{
- $this->db = $DB;
+ $this->db = $db;
}
@@ -324,15 +324,14 @@ function fetch_product_fournisseur_price($rowid)
function list_product_fournisseur_price($prodid)
{
global $conf;
-
- // Suppliers list
+
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn,";
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
- $sql.= " INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
- $sql.= " ON pfp.fk_soc = s.rowid";
- $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
+ $sql.= ", ".MAIN_DB_PREFIX."societe as s";
+ $sql.= " WHERE pfp.entity IN (".getEntity('product', 1).")";
+ $sql.= " AND pfp.fk_soc = s.rowid";
$sql.= " AND pfp.fk_product = ".$prodid;
$sql.= " ORDER BY s.nom, pfp.quantity, pfp.price";
Oops, something went wrong.

0 comments on commit 3a915de

Please sign in to comment.