diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 0fefb5baf00..0dc64c5a9fe 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -96,7 +96,8 @@ class BlockedLog /** * try to retrieve logged object link */ - public function getObjectLink() { + public function getObjectLink() + { global $langs; if($this->element === 'facture') { @@ -110,6 +111,17 @@ class BlockedLog $this->error++; } } + if($this->element === 'invoice_supplier') { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + + $object = new FactureFournisseur($this->db); + if($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + else{ + $this->error++; + } + } else if($this->element === 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; @@ -121,6 +133,17 @@ class BlockedLog $this->error++; } } + else if($this->element === 'payment_supplier') { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; + + $object = new PaiementFourn($this->db); + if($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + else{ + $this->error++; + } + } return $langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object); @@ -129,7 +152,8 @@ class BlockedLog /** * try to retrieve user author */ - public function getUser() { + public function getUser() + { global $langs, $cachedUser; if(empty($cachedUser))$cachedUser=array(); @@ -149,14 +173,14 @@ class BlockedLog } /** - * populate log by object + * Populate properties of log from object data * - * @param payment|facture $object object to store + * @param Object $object object to store */ - public function setObjectData(&$object) { - + public function setObjectData(&$object) + { // Set date - if ($object->element=='payment') + if($object->element == 'payment' || $object->element == 'payment_supplier') { $this->date_object = $object->datepaye; } @@ -174,7 +198,7 @@ class BlockedLog $this->object_data=new stdClass(); - if ($this->element === 'facture') + if ($this->element == 'facture') { if(empty($object->thirdparty))$object->fetch_thirdparty(); $this->object_data->thirdparty = new stdClass(); @@ -190,15 +214,31 @@ class BlockedLog $this->object_data->total_localtax2= (double) $object->total_localtax2; $this->object_data->note_public = (double) $object->note_public; } - elseif($this->element === 'payment') + if($this->element == 'invoice_supplier') { + if(empty($object->thirdparty))$object->fetch_thirdparty(); + $this->object_data->thirdparty = new stdClass(); + + foreach($object->thirdparty as $key=>$value) { + if(!is_object($value)) $this->object_data->thirdparty->{$key} = $value; + } + + $this->object_data->total_ht = (double) $object->total_ht; + $this->object_data->total_tva = (double) $object->total_tva; + $this->object_data->total_ttc = (double) $object->total_ttc; + $this->object_data->total_localtax1= (double) $object->total_localtax1; + $this->object_data->total_localtax2= (double) $object->total_localtax2; + $this->object_data->note_public = (double) $object->note_public; + $this->object_data->note_private= (double) $object->note_private; + + } + elseif ($this->element == 'payment'|| $object->element == 'payment_supplier') { $this->object_data->amounts = $object->amounts; } - elseif($this->element === 'payment_salary') + elseif($this->element == 'payment_salary') { $this->object_data->amounts = array($object->amount); } - } /** @@ -520,6 +560,15 @@ class BlockedLog $this->amounts = (double) $obj->amount; } } + if($this->element === 'payment_supplier') { + $sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiementfourn WHERE rowid=".$this->fk_object; + + $res = $this->db->query($sql); + + if($res && $obj = $this->db->fetch_object($res)) { + $this->amounts = (double) $obj->amount; + } + } elseif($this->element === 'facture') { $sql="SELECT total_ttc FROM ".MAIN_DB_PREFIX."facture WHERE rowid=".$this->fk_object; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 14913f5d2ee..56e2edf527f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -333,6 +333,15 @@ if (empty($reshook)) $desc = dol_htmlentitiesbr($lines[$i]->desc); } + // Extrafields + $array_options = array(); + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if + // trigger used + { + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_options = $lines[$i]->array_options; + } + $txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx . ' (' . $lines[$i]->vat_src_code . ')' : $lines[$i]->tva_tx; // View third's localtaxes for now @@ -355,7 +364,7 @@ if (empty($reshook)) $lines[$i]->info_bits, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, - array(), + $array_options, $lines[$i]->fk_unit ); diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 635a4649902..4eac937a476 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -50,19 +50,27 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' - || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') { + + // Test if event/record is qualified + $listofqualifiedelement = array('payment', 'facture'); + if (! in_array($object->element, $listofqualifiedelement)) return 1; + + + // Event/record is qualified + if ($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' + || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW' + || $action === 'BILL_SUPPLIER_PAYED') + { $amounts= (double) $object->total_ttc; } - else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { + else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK' || $action === 'PAYMENT_SUPPLIER_CREATE') + { $amounts = 0; if(!empty($object->amounts)) { foreach($object->amounts as $amount) { $amounts+= price2num($amount); } } - - } else if(strpos($action,'PAYMENT')!==false) { $amounts= (double) $object->amount; @@ -71,6 +79,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers return 0; // not implemented action log } + $b=new BlockedLog($this->db); $b->action = $action; $b->amounts= $amounts; @@ -78,17 +87,15 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $res = $b->create($user); - if($res<0) { + if ($res<0) + { setEventMessage($b->error,'errors'); - return -1; } - else { - + else + { return 1; } - - } } diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 5753760df66..ab2346b679a 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -109,7 +109,7 @@ if ($socid > 0) print ''; } - if ($object->fournisseur) + if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) { print ''; print $langs->trans('SupplierCode').''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 5e02cb99eaf..30040ce144b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1995,9 +1995,12 @@ else print ''; // Supplier - print ''.$langs->trans('Supplier').''; - print yn($object->fournisseur); - print ''; + if (! empty($conf->fournisseur->enabled)) + { + print ''.$langs->trans('Supplier').''; + print yn($object->fournisseur); + print ''; + } // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 697ae315fb3..5733ffa9568 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -180,7 +180,7 @@ if ($result > 0) print ''; } - if ($object->fournisseur) + if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) { print ''; print $langs->trans('SupplierCode').'';