diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 5b75bbadd00..9f051b902cc 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -834,7 +834,7 @@ class ActionComm extends CommonObject
if (! empty($elementtype))
{
if ($elementtype == 'project') $sql.= ' AND a.fk_project = '.$fk_element;
- else $sql.= " AND a.fk_element = ".$fk_element." AND a.elementtype = '".$elementtype."'";
+ else $sql.= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'";
}
if (! empty($filter)) $sql.= $filter;
if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder);
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index de32e30c5e6..3417419f892 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -76,9 +76,41 @@ class Commande extends CommonOrder
var $brouillon;
var $cond_reglement_code;
+
+ var $fk_account;
+
+ /**
+ * It holds the label of the payment mode. Use it in case translation cannot be found.
+ * @var string
+ */
+ var $mode_reglement;
+
+ /**
+ * Payment mode id
+ * @var int
+ */
+ var $mode_reglement_id;
+ /**
+ * Payment mode code
+ * @var string
+ */
var $mode_reglement_code;
+ /**
+ * Availability delivery time id
+ * @var int
+ */
var $availability_id;
+ /**
+ * Availability delivery time code
+ * @var string
+ */
var $availability_code;
+ /**
+ * Label of availability delivery time. Use it in case translation cannot be found.
+ * @var string
+ */
+ var $availability;
+
var $demand_reason_id;
var $demand_reason_code;
var $address;
@@ -1435,7 +1467,7 @@ class Commande extends CommonOrder
$sql.= ", i.libelle as libelle_incoterms";
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
- $sql.= ', ca.code as availability_code';
+ $sql.= ', ca.code as availability_code, ca.label as availability_label';
$sql.= ', dr.code as demand_reason_code';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)';
@@ -1492,6 +1524,7 @@ class Commande extends CommonOrder
$this->fk_account = $obj->fk_account;
$this->availability_id = $obj->fk_availability;
$this->availability_code = $obj->availability_code;
+ $this->availability = $obj->availability_label;
$this->demand_reason_id = $obj->fk_input_reason;
$this->demand_reason_code = $obj->demand_reason_code;
$this->date_livraison = $this->db->jdate($obj->date_livraison);
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 8c2b725f8d2..cf38669d554 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -1281,12 +1281,12 @@ class AccountLine extends CommonObject
$nbko++;
}
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".$this->rowid;
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".(int) $this->rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
if (! $result) $nbko++;
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$this->rowid;
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".(int) $this->rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
if (! $result) $nbko++;
@@ -1323,7 +1323,7 @@ class AccountLine extends CommonObject
$this->db->begin();
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$this->rowid;
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".(int) $this->rowid;
dol_syslog(get_class($this)."::delete_urls", LOG_DEBUG);
$result = $this->db->query($sql);
if (! $result) $nbko++;
diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php
index 82070a957e2..eaaf44b4e14 100644
--- a/htdocs/compta/bank/rappro.php
+++ b/htdocs/compta/bank/rappro.php
@@ -99,11 +99,14 @@ if ($action == 'rappro' && $user->rights->banque->consolidate)
if ($action == 'del')
{
$bankline=new AccountLine($db);
- $bankline->fetch($_GET["rowid"]);
- $result=$bankline->delete($user);
- if ($result < 0)
- {
- dol_print_error($db,$bankline->error);
+
+ if ($bankline->fetch($_GET["rowid"]) > 0) {
+ $result = $bankline->delete($user);
+ if ($result < 0) {
+ dol_print_error($db, $bankline->error);
+ }
+ } else {
+ setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
}
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index cc3d4200912..f8bb53cf9ed 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1040,7 +1040,7 @@ class Facture extends CommonInvoice
}
else
{
- $this->error='Bill with id '.$rowid.' or ref '.$ref.' not found sql='.$sql;
+ $this->error='Bill with id '.$rowid.' or ref '.$ref.' not found';
dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR);
return 0;
}
diff --git a/htdocs/core/class/dolprintipp.class.php b/htdocs/core/class/dolprintipp.class.php
index fdd0fc2732c..869b26e2f75 100644
--- a/htdocs/core/class/dolprintipp.class.php
+++ b/htdocs/core/class/dolprintipp.class.php
@@ -66,7 +66,7 @@ class dolprintIPP
*/
function list_jobs($module)
{
- global $conf, $db, $bc;
+ global $conf, $db, $bc, $langs;
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
$ipp = new CupsPrintIPP();
$ipp->setLog(DOL_DATA_ROOT.'/printipp.log','file',3); // logging very verbose
@@ -96,7 +96,8 @@ class dolprintIPP
}
catch(Exception $e)
{
- print $e->getMessage();
+ setEventMessage('[printipp] '.$langs->trans('CoreErrorMessage'), 'errors');
+ dol_syslog($e->getMessage(), LOG_ERR);
}
print '
';
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index d4f0a1e4691..05c190e3bfc 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1100,7 +1100,7 @@ class Form
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
$sql.= " re.description, re.fk_facture_source";
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
- $sql.= " WHERE fk_soc = ".$socid;
+ $sql.= " WHERE fk_soc = ".(int) $socid;
if ($filter) $sql.= " AND ".$filter;
$sql.= " ORDER BY re.description ASC";
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index b8bb8f65b95..30607201e73 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -560,7 +560,7 @@ class Expedition extends CommonObject
else
{
dol_syslog(get_class($this).'::Fetch no expedition found', LOG_ERR);
- $this->error='Delivery with id '.$id.' not found sql='.$sql;
+ $this->error='Delivery with id '.$id.' not found';
return 0;
}
}
diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php
index e54f2d3329b..6a4f2255f6b 100644
--- a/htdocs/fourn/product/list.php
+++ b/htdocs/fourn/product/list.php
@@ -109,7 +109,7 @@ if ($sref)
}
if ($snom)
{
- $sql .= natural_search('s.nom', $snom);
+ $sql .= natural_search('p.label', $snom);
}
if($catid)
{
diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php
index 147afc124fc..32c39b63b4f 100644
--- a/htdocs/margin/tabs/thirdpartyMargins.php
+++ b/htdocs/margin/tabs/thirdpartyMargins.php
@@ -49,6 +49,21 @@ $pagenext = $page + 1;
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="f.datef";
+$object = new Societe($db);
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('thirdpartymargins','globalcard'));
+
+
+/*
+ * Actions
+ */
+
+$parameters=array('id'=>$socid);
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+
/*
* View
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index 5924a89956b..e222e77ee81 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -79,6 +79,8 @@ $extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label('product');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
+if (empty($action)) $action='list';
+
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$canvas=GETPOST("canvas");
$objcanvas=null;
@@ -165,8 +167,8 @@ $form=new Form($db);
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
{
- $objcanvas->assign_values('list'); // This must contains code to load data (must call LoadListDatas($limit, $offset, $sortfield, $sortorder))
- $objcanvas->display_canvas('list'); // This is code to show template
+ $objcanvas->assign_values($action); // This must contains code to load data (must call LoadListDatas($limit, $offset, $sortfield, $sortorder))
+ $objcanvas->display_canvas($action); // This is code to show template
}
else
{
diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php
index 6a6fb7ab1df..cfbf3529bba 100644
--- a/htdocs/societe/notify/card.php
+++ b/htdocs/societe/notify/card.php
@@ -56,65 +56,78 @@ if (! $sortfield) $sortfield="c.lastname";
$now=dol_now();
+$object = new Societe($db);
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('thirdpartynotification','globalcard'));
+
+
/*
* Actions
*/
-// Add a notification
-if ($action == 'add')
+$parameters=array('id'=>$socid);
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
{
$error=0;
- if (empty($contactid))
+ // Add a notification
+ if ($action == 'add')
{
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors');
- $error++;
- }
- if ($actionid <= 0)
- {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
- $error++;
- }
-
- if (! $error)
- {
- $db->begin();
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
- $sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$contactid." AND fk_action=".$actionid;
- if ($db->query($sql))
+ if (empty($contactid))
{
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
- $sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")";
-
- if (! $db->query($sql))
- {
- $error++;
- dol_print_error($db);
- }
+ setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Contact")), null, 'errors');
+ $error++;
}
- else
+ if ($actionid <= 0)
{
- dol_print_error($db);
+ setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), null, 'errors');
+ $error++;
}
-
+
if (! $error)
{
- $db->commit();
- }
- else
- {
- $db->rollback();
+ $db->begin();
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
+ $sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$contactid." AND fk_action=".$actionid;
+ if ($db->query($sql))
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
+ $sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")";
+
+ if (! $db->query($sql))
+ {
+ $error++;
+ dol_print_error($db);
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+
+ if (! $error)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
}
}
-}
-
-// Remove a notification
-if ($action == 'delete')
-{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"];
- $db->query($sql);
+
+ // Remove a notification
+ if ($action == 'delete')
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"];
+ $db->query($sql);
+ }
}
diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php
index a7356010185..589c102c8a3 100644
--- a/htdocs/societe/price.php
+++ b/htdocs/societe/price.php
@@ -49,78 +49,82 @@ if ($user->societe_id)
$socid = $user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe');
+$object = new Societe($db);
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('thirdpartycustomerprice','globalcard'));
+
+
/*
* Actions
*/
-if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
+$parameters=array('id'=>$socid);
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- $update_child_soc = GETPOST('updatechildprice');
-
- // add price by customer
- $prodcustprice->fk_soc = $socid;
- $prodcustprice->fk_product = GETPOST('prodid', 'int');
- $prodcustprice->price = price2num(GETPOST("price"), 'MU');
- $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
- $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
- $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
- $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
-
- $result = $prodcustprice->create($user, 0, $update_child_soc);
-
- if ($result < 0)
- {
- setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
- }
- else
- {
- setEventMessages($langs->trans('Save'), null, 'mesgs');
- }
-
- $action = '';
-}
-
-if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
- // Delete price by customer
- $prodcustprice->id = GETPOST('lineid');
- $result = $prodcustprice->delete($user);
-
- if ($result < 0)
- {
- setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
- }
- else
- {
- setEventMessages($langs->trans('Delete'), null, 'mesgs');
- }
- $action = '';
-}
-
-if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
-
- $prodcustprice->fetch(GETPOST('lineid', 'int'));
-
- $update_child_soc = GETPOST('updatechildprice');
-
- // update price by customer
- $prodcustprice->price = price2num(GETPOST("price"), 'MU');
- $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
- $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
- $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
- $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
-
- $result = $prodcustprice->update($user, 0, $update_child_soc);
- if ($result < 0)
- {
- setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
- }
- else
- {
- setEventMessages($langs->trans('Save'), null, 'mesgs');
- }
-
- $action = '';
+if (empty($reshook))
+{
+ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
+
+ $update_child_soc = GETPOST('updatechildprice');
+
+ // add price by customer
+ $prodcustprice->fk_soc = $socid;
+ $prodcustprice->fk_product = GETPOST('prodid', 'int');
+ $prodcustprice->price = price2num(GETPOST("price"), 'MU');
+ $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
+ $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
+ $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
+ $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
+
+ $result = $prodcustprice->create($user, 0, $update_child_soc);
+
+ if ($result < 0) {
+ setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
+ } else {
+ setEventMessages($langs->trans('Save'), null, 'mesgs');
+ }
+
+ $action = '';
+ }
+
+ if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
+ // Delete price by customer
+ $prodcustprice->id = GETPOST('lineid');
+ $result = $prodcustprice->delete($user);
+
+ if ($result < 0) {
+ setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs');
+ } else {
+ setEventMessages($langs->trans('Delete'), null, 'errors');
+ }
+ $action = '';
+ }
+
+ if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
+
+ $prodcustprice->fetch(GETPOST('lineid', 'int'));
+
+ $update_child_soc = GETPOST('updatechildprice');
+
+ // update price by customer
+ $prodcustprice->price = price2num(GETPOST("price"), 'MU');
+ $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
+ $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
+ $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
+ $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
+
+ $result = $prodcustprice->update($user, 0, $update_child_soc);
+ if ($result < 0) {
+ setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
+ } else {
+ setEventMessages($langs->trans('Save'), null, 'mesgs');
+ }
+
+ $action = '';
+ }
}