Skip to content

Commit 0953156

Browse files
committed
Debug v23
1 parent a009bf4 commit 0953156

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

htdocs/blockedlog/class/blockedlog.class.php

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
547547
}
548548
}
549549

550-
// ref
550+
// ref object
551551
$this->ref_object = ((!empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases
552552
// type of object
553553
$this->element = $object->element;
@@ -595,7 +595,13 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
595595
'fk_incoterms', 'label_incoterms', 'location_incoterms', 'lines'));
596596
}
597597

598-
if (!empty($object->thirdparty)) {
598+
// For customer payment and supplier payment, the thirdparty can be added in payment detail
599+
$addthirdpartyatpaymentlevel = 0;
600+
if (!empty($object->thirdparty) && !in_array($this->element, array('payment', 'payment_supplier'))) {
601+
$addthirdpartyatpaymentlevel = 1;
602+
}
603+
604+
if (!empty($object->thirdparty) && !$addthirdpartyatpaymentlevel) {
599605
$this->object_data->thirdparty = new stdClass();
600606

601607
foreach ($object->thirdparty as $key => $value) {
@@ -652,7 +658,7 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
652658
$valuequalifiedforstorage = true; // We accept '' value for some fields
653659
$value = (string) $value;
654660
}
655-
if (!is_null($value) && empty($value) && in_array($key, array('tva_assuj'))) {
661+
if (!is_null($value) && empty($value) && in_array($key, array('tva_assuj', 'localtax1_assuj', 'localtax2_assuj'))) {
656662
$valuequalifiedforstorage = true; // We accept zero value for amounts
657663
}
658664
if (!is_null($value) && (string) $value !== '') {
@@ -753,6 +759,33 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
753759
if (!empty($object->newref)) {
754760
$this->object_data->ref = $object->newref;
755761
}
762+
763+
// Add data for action emails
764+
if ($action == 'BILL_SENTBYMAIL') {
765+
$emailobj = new stdClass();
766+
$emailobj->email_from = $object->email_from;
767+
//$emailobj->email_to = $object->email_to;
768+
$emailobj->email_msgid = $object->email_msgid;
769+
$emailobj->email_subject = $object->email_subject;
770+
771+
$this->object_data->action_email_sent = $emailobj;
772+
}
773+
774+
// Add data for action doc_preview
775+
if ($action == 'DOC_PREVIEW') {
776+
$docpreviewobj = new stdClass();
777+
$docpreviewobj->pos_print_counter = $object->pos_print_counter;
778+
779+
//$this->object_data->action_doc_preview = $docpreviewobj;
780+
}
781+
782+
// Add data for action doc_download
783+
if ($action == 'DOC_DOWNLOAD') {
784+
$docdownloadobj = new stdClass();
785+
$docdownloadobj->pos_print_counter = $object->pos_print_counter;
786+
787+
//$this->object_data->action_doc_download = $docdownloadobj;
788+
}
756789
} elseif ($this->element == 'invoice_supplier') {
757790
'@phan-var-force FactureFournisseur $object';
758791
foreach ($object as $key => $value) {
@@ -849,7 +882,9 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
849882
$paymentpart = new stdClass();
850883
$paymentpart->amount = $amount;
851884

852-
if (!in_array($this->element, array('payment_donation', 'payment_various'))) {
885+
// If we want to add thirdparty on each payment level
886+
// (seems not necessary as we have one thirdparty per payment on invoice level)
887+
if ($addthirdpartyatpaymentlevel) {
853888
$result = $tmpobject->fetch_thirdparty();
854889
if ($result == 0) {
855890
$this->error = 'Failed to fetch thirdparty for object with id '.$tmpobject->id;
@@ -870,7 +905,7 @@ public function setObjectData(&$object, $action, $amounts, $fuser = null)
870905
// List of thirdparty fields qualified
871906
if (!in_array($key, array(
872907
'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode',
873-
'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
908+
'tva_intra', 'tva_assuj', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur'
874909
))) {
875910
continue; // Discard if not into a dedicated list
876911
}

htdocs/compta/facture/class/facture.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $notused = 0, $fetch_sit
22322232
$sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
22332233
$sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
22342234
$sql .= ', f.fk_incoterms, f.location_incoterms';
2235-
$sql .= ', f.module_source, f.pos_source, f.pos_print_counter';
2235+
$sql .= ', f.module_source, f.pos_source, f.pos_print_counter, f.email_sent_counter';
22362236
$sql .= ", i.libelle as label_incoterms";
22372237
$sql .= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement";
22382238
$sql .= ", f.payment_reference, f.dispute_status";
@@ -2361,6 +2361,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $notused = 0, $fetch_sit
23612361
$this->module_source = $obj->module_source;
23622362
$this->pos_source = $obj->pos_source;
23632363
$this->pos_print_counter = $obj->pos_print_counter;
2364+
$this->email_sent_counter = $obj->email_sent_counter;
23642365

23652366
// Multicurrency
23662367
$this->fk_multicurrency = $obj->fk_multicurrency;

htdocs/core/actions_sendmails.inc.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,11 @@
457457
// If sending email for invoice, we increase the counter of invoices sent by email
458458
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET email_sent_counter = email_sent_counter + 1";
459459
$sql .= " WHERE rowid = ".((int) $object->id);
460-
$db->query($sql);
460+
461+
$resql = $db->query($sql);
462+
if ($resql) {
463+
$object->email_sent_counter += 1;
464+
}
461465
}
462466

463467
$result = $object->call_trigger($triggersendname, $user); // @phan-suppress-current-line PhanPossiblyUndeclaredGlobalVariable

htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
9696
|| $action === 'MEMBER_SUBSCRIPTION_CREATE' || $action === 'MEMBER_SUBSCRIPTION_MODIFY' || $action === 'MEMBER_SUBSCRIPTION_DELETE'
9797
|| $action === 'DON_VALIDATE' || (($action === 'DON_MODIFY' || $action === 'DON_DELETE') && ($object->statut != 0 || $object->status != 0))
9898
|| $action === 'CASHCONTROL_VALIDATE'
99-
|| (in_array($object->element, array('facture', 'supplier_invoice')) && $action === 'DOC_DOWNLOAD' && ($object->statut != 0 || $object->status != 0))
100-
|| (in_array($object->element, array('facture', 'supplier_invoice')) && $action === 'DOC_PREVIEW' && ($object->statut != 0 || $object->status != 0))
99+
|| (in_array($object->element, array('facture', 'supplier_invoice')) && $action === 'DOC_PREVIEW' && ($object->statut != 0 || $object->status != 0 || $object->module_source != ''))
100+
|| (in_array($object->element, array('facture', 'supplier_invoice')) && $action === 'DOC_DOWNLOAD' && ($object->statut != 0 || $object->status != 0 || $object->module_source != ''))
101101
|| (getDolGlobalString('BLOCKEDLOG_ADD_ACTIONS_SUPPORTED') && in_array($action, explode(',', getDolGlobalString('BLOCKEDLOG_ADD_ACTIONS_SUPPORTED'))))
102102
) {
103103
$qualified++;

0 commit comments

Comments
 (0)