54 public $errors = array();
60 public $signature =
'';
66 public $signature_line =
'';
68 public $amounts =
null;
86 public $fk_object = 0;
92 public $certified =
false;
103 public $date_creation;
108 public $date_modification;
110 public $date_object = 0;
112 public $ref_object =
'';
114 public $object_data =
null;
115 public $object_version =
'';
117 public $user_fullname =
'';
123 public $trackedevents = array();
147 $this->trackedevents = array();
151 $this->trackedevents[
'BILL_VALIDATE'] =
'logBILL_VALIDATE';
152 $this->trackedevents[
'BILL_DELETE'] =
'logBILL_DELETE';
153 $this->trackedevents[
'BILL_SENTBYMAIL'] =
'logBILL_SENTBYMAIL';
154 $this->trackedevents[
'DOC_DOWNLOAD'] =
'BlockedLogBillDownload';
155 $this->trackedevents[
'DOC_PREVIEW'] =
'BlockedLogBillPreview';
156 $this->trackedevents[
'PAYMENT_CUSTOMER_CREATE'] =
'logPAYMENT_CUSTOMER_CREATE';
157 $this->trackedevents[
'PAYMENT_CUSTOMER_DELETE'] =
'logPAYMENT_CUSTOMER_DELETE';
175 $this->trackedevents[
'DON_VALIDATE'] =
'logDON_VALIDATE';
176 $this->trackedevents[
'DON_DELETE'] =
'logDON_DELETE';
178 $this->trackedevents[
'DONATION_PAYMENT_CREATE'] =
'logDONATION_PAYMENT_CREATE';
179 $this->trackedevents[
'DONATION_PAYMENT_DELETE'] =
'logDONATION_PAYMENT_DELETE';
193 $this->trackedevents[
'MEMBER_SUBSCRIPTION_CREATE'] =
'logMEMBER_SUBSCRIPTION_CREATE';
194 $this->trackedevents[
'MEMBER_SUBSCRIPTION_MODIFY'] =
'logMEMBER_SUBSCRIPTION_MODIFY';
195 $this->trackedevents[
'MEMBER_SUBSCRIPTION_DELETE'] =
'logMEMBER_SUBSCRIPTION_DELETE';
200 $this->trackedevents[
'PAYMENT_VARIOUS_CREATE'] =
'logPAYMENT_VARIOUS_CREATE';
201 $this->trackedevents[
'PAYMENT_VARIOUS_MODIFY'] =
'logPAYMENT_VARIOUS_MODIFY';
202 $this->trackedevents[
'PAYMENT_VARIOUS_DELETE'] =
'logPAYMENT_VARIOUS_DELETE';
207 $moduleposenabled = (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) ||
getDolGlobalString(
'BANK_ENABLE_POS_CASHCONTROL'));
208 if ($moduleposenabled) {
209 $this->trackedevents[
'CASHCONTROL_VALIDATE'] =
'logCASHCONTROL_VALIDATE';
215 $tmparrayofmoresupportedevents = explode(
',',
getDolGlobalString(
'BLOCKEDLOG_ADD_ACTIONS_SUPPORTED'));
216 foreach ($tmparrayofmoresupportedevents as $val) {
217 $this->trackedevents[$val] =
'log'.$val;
233 if ($this->element ===
'facture') {
234 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
237 if (
$object->fetch($this->fk_object) > 0) {
243 if ($this->element ===
'invoice_supplier') {
244 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
247 if (
$object->fetch($this->fk_object) > 0) {
252 } elseif ($this->element ===
'payment') {
253 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
256 if (
$object->fetch($this->fk_object) > 0) {
261 } elseif ($this->element ===
'payment_supplier') {
262 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
265 if (
$object->fetch($this->fk_object) > 0) {
270 } elseif ($this->element ===
'payment_donation') {
271 require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
274 if (
$object->fetch($this->fk_object) > 0) {
279 } elseif ($this->element ===
'payment_various') {
280 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
283 if (
$object->fetch($this->fk_object) > 0) {
288 } elseif ($this->element ===
'don' || $this->element ===
'donation') {
289 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
292 if (
$object->fetch($this->fk_object) > 0) {
297 } elseif ($this->element ===
'subscription') {
298 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
301 if (
$object->fetch($this->fk_object) > 0) {
306 } elseif ($this->element ===
'cashcontrol') {
307 require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
310 if (
$object->fetch($this->fk_object) > 0) {
315 } elseif ($this->element ===
'stockmouvement') {
316 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
319 if (
$object->fetch($this->fk_object) > 0) {
324 } elseif ($this->element ===
'project') {
325 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
328 if (
$object->fetch($this->fk_object) > 0) {
333 } elseif ($this->action ==
'MODULE_SET') {
334 return '<i class="opacitymedium">'.$langs->trans(
"BlockedLogEnabled").
'</i>';
335 } elseif ($this->action ==
'MODULE_RESET') {
336 if ($this->signature ==
'0000000000') {
337 return '<i class="opacitymedium">'.$langs->trans(
"BlockedLogDisabled").
'</i>';
339 return '<i class="opacitymedium">'.$langs->trans(
"BlockedLogDisabledBis").
'</i>';
343 return '<i class="opacitymedium">'.$langs->trans(
'ImpossibleToReloadObject', $this->element, $this->fk_object).
'</i>';
352 global $langs, $cachedUser;
354 if (empty($cachedUser)) {
356 $cachedUser = array();
359 if (empty($cachedUser[$this->fk_user])) {
360 $u =
new User($this->db);
361 if ($u->fetch($this->fk_user) > 0) {
362 $cachedUser[$this->fk_user] = $u;
366 if (!empty($cachedUser[$this->fk_user])) {
367 return $cachedUser[$this->fk_user]->getNomUrl(1);
370 return $langs->trans(
'ImpossibleToRetrieveUser', $this->fk_user);
384 global $langs, $user, $mysoc;
386 if (is_object($fuser)) {
393 $this->action = $action;
395 $this->amounts = $amounts;
397 if (
$object->element ==
'payment' ||
$object->element ==
'payment_supplier') {
399 } elseif (
$object->element ==
'payment_salary') {
400 $this->date_object =
$object->datev;
401 } elseif (
$object->element ==
'payment_donation' ||
$object->element ==
'payment_various') {
403 } elseif (
$object->element ==
'subscription') {
404 $this->date_object =
$object->dateh;
405 } elseif (
$object->element ==
'cashcontrol') {
406 $this->date_object =
$object->date_creation;
407 } elseif (property_exists(
$object,
'date')) {
409 $this->date_object =
$object->date;
410 } elseif (property_exists(
$object,
'datem')) {
412 $this->date_object =
$object->datem;
418 $this->element =
$object->element;
420 $this->fk_object =
$object->id;
424 $this->object_data =
new stdClass();
426 $arrayoffieldstoexclude = array(
427 'table_element',
'fields',
'ref_previous',
'ref_next',
'origin',
'origin_id',
'oldcopy',
'picto',
'error',
'errors',
'model_pdf',
'modelpdf',
'last_main_doc',
'civility_id',
'contact',
'contact_id',
428 'table_element_line',
'ismultientitymanaged',
'isextrafieldmanaged',
437 'fk_delivery_address',
439 'restrictiononfksoc',
443 if ($this->element ==
'cashcontrol') {
444 $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array(
445 'name',
'lastname',
'firstname',
'region',
'region_id',
'region_code',
'state',
'state_id',
'state_code',
'country',
'country_id',
'country_code',
446 'total_ht',
'total_tva',
'total_ttc',
'total_localtax1',
'total_localtax2',
447 'barcode_type',
'barcode_type_code',
'barcode_type_label',
'barcode_type_coder',
'mode_reglement_id',
'cond_reglement_id',
'mode_reglement',
'cond_reglement',
'shipping_method_id',
448 'fk_incoterms',
'label_incoterms',
'location_incoterms',
'lines'));
452 if (empty(
$object->thirdparty) && method_exists(
$object,
'fetch_thirdparty')) {
455 if (!empty(
$object->thirdparty)) {
456 $this->object_data->thirdparty =
new stdClass();
458 foreach (
$object->thirdparty as $key => $value) {
459 if (in_array($key, $arrayoffieldstoexclude)) {
462 if (!in_array($key, array(
463 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
464 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
468 if (!is_object($value) && !is_null($value) && $value !==
'') {
469 $this->object_data->thirdparty->$key = $value;
475 if (!empty($mysoc)) {
476 $this->object_data->mycompany =
new stdClass();
478 foreach ($mysoc as $key => $value) {
479 if (in_array($key, $arrayoffieldstoexclude)) {
482 if (!in_array($key, array(
483 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
484 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
488 if (!is_object($value) && !is_null($value) && $value !==
'') {
489 $this->object_data->mycompany->$key = $value;
496 $this->fk_user = $user->id;
497 $this->user_fullname = $user->getFullName($langs);
501 if ($this->element ==
'facture') {
502 foreach (
$object as $key => $value) {
503 if (in_array($key, $arrayoffieldstoexclude)) {
506 if (!in_array($key, array(
507 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'datev',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public',
'lines'
511 if ($key ==
'lines') {
513 foreach ($value as $tmpline) {
515 foreach ($tmpline as $keyline => $valueline) {
516 if (!in_array($keyline, array(
517 'ref',
'multicurrency_code',
'multicurrency_total_ht',
'multicurrency_total_tva',
'multicurrency_total_ttc',
'qty',
'product_type',
'vat_src_code',
'tva_tx',
'info_bits',
'localtax1_tx',
'localtax2_tx',
'total_ht',
'total_tva',
'total_ttc',
'total_localtax1',
'total_localtax2'
522 if (empty($this->object_data->invoiceline[$lineid]) || !is_object($this->object_data->invoiceline[$lineid])) {
523 $this->object_data->invoiceline[$lineid] =
new stdClass();
526 if (!is_object($valueline) && !is_null($valueline) && $valueline !==
'') {
527 $this->object_data->invoiceline[$lineid]->$keyline = $valueline;
531 } elseif (!is_object($value) && !is_null($value) && $value !==
'') {
532 $this->object_data->$key = $value;
537 $this->object_data->ref =
$object->newref;
539 } elseif ($this->element ==
'invoice_supplier') {
540 foreach (
$object as $key => $value) {
541 if (in_array($key, $arrayoffieldstoexclude)) {
544 if (!in_array($key, array(
545 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public'
549 if (!is_object($value) && !is_null($value) && $value !==
'') {
550 $this->object_data->$key = $value;
555 $this->object_data->ref =
$object->newref;
557 } elseif ($this->element ==
'payment' || $this->element ==
'payment_supplier' || $this->element ==
'payment_donation' || $this->element ==
'payment_various') {
561 $this->object_data->ref =
$object->ref;
562 $this->object_data->date = $datepayment;
563 $this->object_data->type_code =
dol_getIdFromCode($this->db, $paymenttypeid,
'c_paiement',
'id',
'code');
565 if (!empty(
$object->num_payment)) {
566 $this->object_data->payment_num =
$object->num_payment;
568 if (!empty(
$object->note_private)) {
569 $this->object_data->note_private =
$object->note_private;
578 $paymentpartnumber = 0;
579 foreach (
$object->amounts as $objid => $amount) {
580 if (empty($amount)) {
584 $totalamount += $amount;
587 if ($this->element ==
'payment_supplier') {
588 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
590 } elseif ($this->element ==
'payment') {
591 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
592 $tmpobject =
new Facture($this->db);
593 } elseif ($this->element ==
'payment_donation') {
594 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
595 $tmpobject =
new Don($this->db);
596 } elseif ($this->element ==
'payment_various') {
597 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
601 if (!is_object($tmpobject)) {
605 $result = $tmpobject->fetch($objid);
608 $this->error = $tmpobject->error;
609 $this->errors = $tmpobject->errors;
610 dol_syslog(
"Failed to fetch object with id ".$objid, LOG_ERR);
615 $paymentpart->amount = $amount;
617 if (!in_array($this->element, array(
'payment_donation',
'payment_various'))) {
618 $result = $tmpobject->fetch_thirdparty();
620 $this->error =
'Failed to fetch thirdparty for object with id '.$tmpobject->id;
621 $this->errors[] = $this->error;
622 dol_syslog(
"Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR);
624 } elseif ($result < 0) {
625 $this->error = $tmpobject->error;
626 $this->errors = $tmpobject->errors;
630 $paymentpart->thirdparty =
new stdClass();
631 foreach ($tmpobject->thirdparty as $key => $value) {
632 if (in_array($key, $arrayoffieldstoexclude)) {
635 if (!in_array($key, array(
636 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
637 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
641 if (!is_object($value) && !is_null($value) && $value !==
'') {
642 $paymentpart->thirdparty->$key = $value;
648 if ($this->element ==
'payment_donation') {
649 $paymentpart->donation =
new stdClass();
651 $paymentpart->invoice =
new stdClass();
654 if ($this->element !=
'payment_various') {
655 foreach ($tmpobject as $key => $value) {
656 if (in_array($key, $arrayoffieldstoexclude)) {
659 if (!in_array($key, array(
660 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public'
664 if (!is_object($value) && !is_null($value) && $value !==
'') {
665 if ($this->element ==
'payment_donation') {
666 $paymentpart->donation->$key = $value;
667 } elseif ($this->element ==
'payment_various') {
668 $paymentpart->various->$key = $value;
670 $paymentpart->invoice->$key = $value;
675 $paymentpartnumber++;
676 $this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
679 } elseif (!empty(
$object->amount)) {
680 $totalamount =
$object->amount;
683 $this->object_data->amount = $totalamount;
686 $this->object_data->ref =
$object->newref;
688 } elseif ($this->element ==
'payment_salary') {
689 $this->object_data->amounts = array(
$object->amount);
692 $this->object_data->ref =
$object->newref;
694 } elseif ($this->element ==
'subscription') {
695 foreach (
$object as $key => $value) {
696 if (in_array($key, $arrayoffieldstoexclude)) {
699 if (!in_array($key, array(
700 'id',
'datec',
'dateh',
'datef',
'fk_adherent',
'amount',
'import_key',
'statut',
'note'
704 if (!is_object($value) && !is_null($value) && $value !==
'') {
705 $this->object_data->$key = $value;
710 $this->object_data->ref =
$object->newref;
712 } elseif ($this->element ==
'stockmouvement') {
713 foreach (
$object as $key => $value) {
714 if (in_array($key, $arrayoffieldstoexclude)) {
717 if (!is_object($value) && !is_null($value) && $value !==
'') {
718 $this->object_data->$key = $value;
723 foreach (
$object as $key => $value) {
724 if (in_array($key, $arrayoffieldstoexclude)) {
727 if (!is_object($value) && !is_null($value) && $value !==
'') {
728 $this->object_data->$key = $value;
733 $this->object_data->ref =
$object->newref;
739 $this->object_data = json_decode(json_encode($this->object_data, JSON_FORCE_OBJECT),
false);
755 $this->error =
'BadParameter';
759 $sql =
"SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,";
760 $sql .=
" b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data, b.object_version";
761 $sql .=
" FROM ".MAIN_DB_PREFIX.
"blockedlog as b";
763 $sql .=
" WHERE b.rowid = ".((int) $id);
766 $resql = $this->db->query(
$sql);
768 $obj = $this->db->fetch_object($resql);
770 $this->
id = $obj->rowid;
771 $this->entity = $obj->entity;
773 $this->date_creation = $this->db->jdate($obj->date_creation);
774 $this->date_modification = $this->db->jdate($obj->tms);
776 $this->amounts = (
float) $obj->amounts;
777 $this->action = $obj->action;
778 $this->element = $obj->element;
780 $this->fk_object = $obj->fk_object;
781 $this->date_object = $this->db->jdate($obj->date_object);
782 $this->ref_object = $obj->ref_object;
784 $this->fk_user = $obj->fk_user;
785 $this->user_fullname = $obj->user_fullname;
788 $this->object_version = $obj->object_version;
790 $this->signature = $obj->signature;
791 $this->signature_line = $obj->signature_line;
792 $this->certified = ($obj->certified == 1);
796 $langs->load(
"blockedlog");
797 $this->error = $langs->trans(
"RecordNotFound");
801 $this->error = $this->db->error();
817 $aaa = json_encode($data);
854 $res = $this->db->query(
"UPDATE ".MAIN_DB_PREFIX.
"blockedlog SET certified=1 WHERE rowid=".((
int) $this->id));
869 public function create($user, $forcesignature =
'')
871 global $conf, $langs, $hookmanager;
873 $langs->load(
'blockedlog');
878 $this->amounts = (
float) $this->amounts;
880 dol_syslog(get_class($this).
'::create action='.$this->action.
' fk_user='.$this->fk_user.
' user_fullname='.$this->user_fullname, LOG_DEBUG);
883 if (!isset($this->amounts)) {
884 $this->error = $langs->trans(
"BlockLogNeedAmountsValue");
889 if (empty($this->element)) {
890 $this->error = $langs->trans(
"BlockLogNeedElement");
895 if (empty($this->action)) {
896 $this->error = $langs->trans(
"BadParameterWhenCallingCreateOfBlockedLog");
900 if (empty($this->fk_user)) {
901 $this->user_fullname =
'(Anonymous)';
904 $this->date_creation =
dol_now();
906 $this->object_version = ((
float) DOL_VERSION);
915 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
917 $this->signature_line =
dol_hash($keyforsignature,
'5');
918 $this->signature =
dol_hash($previoushash.$keyforsignature,
'5');
919 if ($forcesignature) {
920 $this->signature = $forcesignature;
924 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"blockedlog (";
925 $sql .=
" date_creation,";
928 $sql .=
" signature,";
929 $sql .=
" signature_line,";
931 $sql .=
" fk_object,";
932 $sql .=
" date_object,";
933 $sql .=
" ref_object,";
934 $sql .=
" object_data,";
935 $sql .=
" object_version,";
936 $sql .=
" certified,";
938 $sql .=
" user_fullname,";
940 $sql .=
") VALUES (";
941 $sql .=
"'".$this->db->idate($this->date_creation).
"',";
942 $sql .=
"'".$this->db->escape($this->action).
"',";
943 $sql .= $this->amounts.
",";
944 $sql .=
"'".$this->db->escape($this->signature).
"',";
945 $sql .=
"'".$this->db->escape($this->signature_line).
"',";
946 $sql .=
"'".$this->db->escape($this->element).
"',";
947 $sql .= $this->fk_object.
",";
948 $sql .=
"'".$this->db->idate($this->date_object).
"',";
949 $sql .=
"'".$this->db->escape($this->ref_object).
"',";
951 $sql .=
"'".$this->db->escape($this->object_version).
"',";
953 $sql .= $this->fk_user.
",";
954 $sql .=
"'".$this->db->escape($this->user_fullname).
"',";
955 $sql .= ($this->entity ? $this->entity : $conf->entity);
966 $res = $this->db->query(
$sql);
968 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"blockedlog");
977 $this->db->rollback();
981 $this->error = $this->db->error();
982 $this->db->rollback();
998 if (empty($previoushash)) {
1005 $signature =
dol_hash($previoushash.$keyforsignature,
'sha256');
1008 $res = ($signature === $this->signature);
1011 $this->error =
'Signature KO';
1015 if ($returnarray == 1) {
1016 unset($keyforsignature);
1017 return array(
'checkresult' => $res,
'calculatedsignature' => $signature,
'previoushash' => $previoushash);
1019 return array(
'checkresult' => $res,
'calculatedsignature' => $signature,
'previoushash' => $previoushash,
'keyforsignature' => $keyforsignature);
1022 unset($keyforsignature);
1037 if (((
int) $this->object_version) >= 18) {
1038 return $this->date_creation.
'|'.$this->action.
'|'.$this->amounts.
'|'.$this->ref_object.
'|'.$this->date_object.
'|'.$this->user_fullname.
'|'.json_encode($this->object_data, JSON_FORCE_OBJECT);
1040 return $this->date_creation.
'|'.$this->action.
'|'.$this->amounts.
'|'.$this->ref_object.
'|'.$this->date_object.
'|'.$this->user_fullname.
'|'.print_r($this->object_data,
true);
1056 $previoussignature =
'';
1058 $sql =
"SELECT rowid, signature FROM ".MAIN_DB_PREFIX.
"blockedlog";
1059 $sql .=
" WHERE entity = ".((int) $conf->entity);
1061 $sql .=
" AND rowid < ".(int) $beforeid;
1063 $sql .=
" ORDER BY rowid DESC LIMIT 1";
1064 $sql .= ($withlock ?
" FOR UPDATE " :
"");
1066 $resql = $this->db->query(
$sql);
1068 $obj = $this->db->fetch_object($resql);
1070 $previoussignature = $obj->signature;
1077 if (empty($previoussignature)) {
1082 return $previoussignature;
1101 public function getLog($element, $fk_object, $limit = 0, $sortfield =
'', $sortorder =
'', $search_fk_user = -1, $search_start = -1, $search_end = -1, $search_ref =
'', $search_amount =
'', $search_code =
'')
1109 if ($element ==
'all') {
1110 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1111 WHERE entity=".$conf->entity;
1112 } elseif ($element ==
'not_certified') {
1113 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1114 WHERE entity=".$conf->entity.
" AND certified = 0";
1115 } elseif ($element ==
'just_certified') {
1116 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1117 WHERE entity=".$conf->entity.
" AND certified = 1";
1119 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1120 WHERE entity=".$conf->entity.
" AND element = '".$this->db->escape($element).
"'";
1126 if ($search_fk_user > 0) {
1129 if ($search_start > 0) {
1130 $sql .=
" AND date_creation >= '".$this->db->idate($search_start).
"'";
1132 if ($search_end > 0) {
1133 $sql .=
" AND date_creation <= '".$this->db->idate($search_end).
"'";
1135 if ($search_ref !=
'') {
1138 if ($search_amount !=
'') {
1141 if ($search_code !=
'' && $search_code !=
'-1') {
1145 $sql .= $this->db->order($sortfield, $sortorder);
1146 $sql .= $this->db->plimit($limit + 1);
1148 $res = $this->db->query(
$sql);
1153 while ($obj = $this->db->fetch_object($res)) {
1163 $b->fetch($obj->rowid);
1185 global $db, $conf, $mysoc;
1188 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1189 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
1190 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1194 dolibarr_set_const($db,
'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint,
'chaine', 0,
'Numeric Unique Fingerprint', $conf->entity);
1196 $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT = $fingerprint;
1199 return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT;
1215 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog";
1216 $sql .=
" WHERE entity = ".$conf->entity;
1217 if ($ignoresystem) {
1218 $sql .=
" AND action not in ('MODULE_SET','MODULE_RESET')";
1220 $sql .= $this->db->plimit(1);
1222 $res = $this->db->query(
$sql);
1223 if ($res !==
false) {
1224 $obj = $this->db->fetch_object($res);
1232 dol_syslog(
"Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem.
" is ".json_encode($result));
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Class to manage Blocked Log.
getSignature()
Return the signature (hash) of the "genesis-block" (Block 0).
getObjectLink()
Try to retrieve source object (it it still exists).
alreadyUsed($ignoresystem=0)
Check if module was already used or not for at least one recording.
buildKeyForSignature()
Return a string for signature.
create($user, $forcesignature='')
Create blocked log in database.
dolEncodeBlockedData($data, $mode=0)
Encode data.
loadTrackedEvents()
Load list of tracked events into $this->trackedevents.
getLog($element, $fk_object, $limit=0, $sortfield='', $sortorder='', $search_fk_user=-1, $search_start=-1, $search_end=-1, $search_ref='', $search_amount='', $search_code='')
Return array of log objects (with criteria)
__construct(DoliDB $db)
Constructor.
setObjectData(&$object, $action, $amounts, $fuser=null)
Populate properties of log from object data.
getPreviousHash($withlock=0, $beforeid=0)
Get previous signature/hash in chain.
checkSignature($previoushash='', $returnarray=0)
Check if current signature still correct compared to the value in chain.
dolDecodeBlockedData($data, $mode=0)
Decode data.
fetch($id)
Get object from database.
setCertified()
Set block certified by authority.
Class to manage cash fence.
Class to manage Dolibarr database access.
Class to manage donations.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage stock movements.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of donations.
Class to manage various payments.
Class to manage projects.
Class to manage subscriptions of foundation members.
Class to manage Dolibarr users.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
jsonOrUnserialize($stringtodecode)
Decode an encode string.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
div float
Buy price without taxes.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.