From 46160614b84861e3a62b2f17e4f21f8f84c2f35a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 31 Dec 2020 03:30:18 +0100 Subject: [PATCH 01/20] Typo --- htdocs/adherents/card.php | 2 +- htdocs/admin/modules.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 418c5cc5674..94904d877e7 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1761,7 +1761,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($linktoelem) print ($somethingshown?'':'
').$linktoelem; */ - // Shon online payment link + // Show online payment link $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); if ($useonlinepayment) { diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 4316130e739..472777ee898 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1137,7 +1137,7 @@ if ($mode == 'deploy') { print ' '; - print ''; + print ''; if (!empty($conf->global->MAIN_UPLOAD_DOC)) { if ($user->admin) { From 0c95540ff0dc15ad0b8366ba3a9ec9ef350df0e3 Mon Sep 17 00:00:00 2001 From: Aisuko <17001223+AisukoWasTaken@users.noreply.github.com> Date: Fri, 1 Jan 2021 22:53:01 +0100 Subject: [PATCH 02/20] Fix wrong cast for pos_change The variable pos_change was cast in "int" where it should be cast in "float". It results in rounded value making the receipt showing wrong cash exchange. --- htdocs/compta/paiement/class/paiement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 28635a2df60..6b7f1612836 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -294,7 +294,7 @@ class Paiement extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", "; - $sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")"; + $sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((float) $this->pos_change).")"; $resql = $this->db->query($sql); if ($resql) From 3cb71ef53e6cbf775fbf920d314be8db8c4d65d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Jan 2021 22:55:22 +0100 Subject: [PATCH 03/20] Code comment --- htdocs/install/mysql/migration/repair.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 033db4620d1..6d662e64893 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -475,7 +475,7 @@ UPDATE llx_chargesociales SET date_creation = tms WHERE date_creation IS NULL; -- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; -- VMYSQL4.1 update llx_inventory set date_cre = null where DATE(STR_TO_DATE(date_cre, '%Y-%m-%d')) IS NULL; --- Note that you can manually set the default value of a date to CURRENT_TIMESTAMP with: +-- Note that you can manually set the default value of a date or datetime to CURRENT_TIMESTAMP with: --ALTER TABLE llx_table modify column columnname datetime DEFAULT CURRENT_TIMESTAMP; From 8ad9c3dbe9f556d771651281d22f429b6cabb4ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 09:07:16 +0100 Subject: [PATCH 04/20] fix migration for icstransfert --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 6c94c4299d3..26ec6377cc3 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -387,9 +387,6 @@ ALTER TABLE llx_bank ADD COLUMN origin_id integer; ALTER TABLE llx_bank ADD COLUMN origin_type varchar(64) NULL; ALTER TABLE llx_bank ADD COLUMN import_key varchar(14); -ALTER TABLE llx_bank_account ADD COLUMN ics varchar(32) NULL; -ALTER TABLE llx_bank_account ADD COLUMN ics_transfer varchar(32) NULL; - ALTER TABLE llx_menu MODIFY COLUMN enabled text; CREATE TABLE llx_ecm_files_extrafields diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 104670ce160..780568ba41b 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -39,3 +39,5 @@ UPDATE llx_adherent SET ref = rowid WHERE ref = '' or ref IS NULL; ALTER TABLE llx_adherent MODIFY COLUMN ref varchar(30) NOT NULL; ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity); +ALTER TABLE llx_bank_account ADD COLUMN ics varchar(32) NULL; +ALTER TABLE llx_bank_account ADD COLUMN ics_transfer varchar(32) NULL; From 4643e412821040d1cd31fe267dbc3f09190e9cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 09:35:57 +0100 Subject: [PATCH 05/20] remove unused code --- htdocs/core/actions_sendmails.inc.php | 262 +++++++++++--------------- 1 file changed, 105 insertions(+), 157 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 0be919de0dd..929d35d9730 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -33,8 +33,7 @@ /* * Add file in email form */ -if (GETPOST('addfile', 'alpha')) -{ +if (GETPOST('addfile', 'alpha')) { $trackid = GETPOST('trackid', 'aZ09'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -50,8 +49,7 @@ if (GETPOST('addfile', 'alpha')) /* * Remove file in email form */ -if (!empty($_POST['removedfile']) && empty($_POST['removAll'])) -{ +if (!empty($_POST['removedfile']) && empty($_POST['removAll'])) { $trackid = GETPOST('trackid', 'aZ09'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -69,24 +67,28 @@ if (!empty($_POST['removedfile']) && empty($_POST['removAll'])) /* * Remove all files in email form */ -if (GETPOST('removAll', 'alpha')) -{ +if (GETPOST('removAll', 'alpha')) { $trackid = GETPOST('trackid', 'aZ09'); $listofpaths = array(); $listofnames = array(); $listofmimes = array(); $keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid; - if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); - if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); - if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) { + $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) { + $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) { + $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + } include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->trackid = $trackid; - foreach ($listofpaths as $key => $value) - { + foreach ($listofpaths as $key => $value) { $pathtodelete = $value; $filetodelete = $listofnames[$key]; $result = dol_delete_file($pathtodelete, 1); // Delete uploded Files @@ -101,50 +103,56 @@ if (GETPOST('removAll', 'alpha')) /* * Send mail */ -if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected']) -{ - if (empty($trackid)) $trackid = GETPOST('trackid', 'aZ09'); +if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected']) { + if (empty($trackid)) { + $trackid = GETPOST('trackid', 'aZ09'); + } $subject = ''; $actionmsg = ''; $actionmsg2 = ''; $langs->load('mails'); - if (is_object($object)) - { + if (is_object($object)) { $result = $object->fetch($id); $sendtosocid = 0; // Id of related thirdparty - if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact'))) - { + if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact'))) { $resultthirdparty = $object->fetch_thirdparty(); $thirdparty = $object->thirdparty; - if (is_object($thirdparty)) $sendtosocid = $thirdparty->id; - } elseif ($object->element == 'member' || $object->element == 'user') - { + if (is_object($thirdparty)) { + $sendtosocid = $thirdparty->id; + } + } elseif ($object->element == 'member' || $object->element == 'user') { $thirdparty = $object; - if ($object->socid > 0) $sendtosocid = $object->socid; - } elseif ($object->element == 'expensereport') - { + if ($object->socid > 0) { + $sendtosocid = $object->socid; + } + } elseif ($object->element == 'expensereport') { $tmpuser = new User($db); $tmpuser->fetch($object->fk_user_author); $thirdparty = $tmpuser; - if ($object->socid > 0) $sendtosocid = $object->socid; - } elseif ($object->element == 'societe') - { + if ($object->socid > 0) { + $sendtosocid = $object->socid; + } + } elseif ($object->element == 'societe') { $thirdparty = $object; - if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id; - } elseif ($object->element == 'contact') - { + if (is_object($thirdparty) && $thirdparty->id > 0) { + $sendtosocid = $thirdparty->id; + } + } elseif ($object->element == 'contact') { $contact = $object; if ($contact->id > 0) { $contact->fetch_thirdparty(); $thirdparty = $contact->thirdparty; - if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id; + if (is_object($thirdparty) && $thirdparty->id > 0) { + $sendtosocid = $thirdparty->id; + } } - } else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported"); + } else { + dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported"); + } - if (is_object($hookmanager)) - { + if (is_object($hookmanager)) { $parameters = array(); $reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks } @@ -152,8 +160,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $thirdparty = $mysoc; } - if ($result > 0) - { + if ($result > 0) { $sendto = ''; $sendtocc = ''; $sendtobcc = ''; @@ -163,48 +170,40 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST // Define $sendto $receiver = $_POST['receiver']; - if (!is_array($receiver)) - { - if ($receiver == '-1') $receiver = array(); - else $receiver = array($receiver); + if (!is_array($receiver)) { + if ($receiver == '-1') { + $receiver = array(); + } else { + $receiver = array($receiver); + } } $tmparray = array(); - if (trim($_POST['sendto'])) - { + if (trim($_POST['sendto'])) { // Recipients are provided into free text $tmparray[] = trim($_POST['sendto']); } - if (count($receiver) > 0) - { + if (count($receiver) > 0) { // Recipient was provided from combo list - foreach ($receiver as $key=>$val) - { - if ($val == 'thirdparty') // Key selected means current third party ('thirdparty' may be used for current member or current user too) - { + foreach ($receiver as $key => $val) { + if ($val == 'thirdparty') { // Key selected means current third party ('thirdparty' may be used for current member or current user too) $tmparray[] = dol_string_nospecial($thirdparty->getFullName($langs), ' ', array(",")).' <'.$thirdparty->email.'>'; - } - elseif ($val == 'contact') // Key selected means current contact - { + } elseif ($val == 'contact') { // Key selected means current contact $tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>'; $sendtoid[] = $contact->id; - } elseif ($val) // $val is the Id of a contact - { + } elseif ($val) { // $val is the Id of a contact $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); $sendtoid[] = ((int) $val); } } } - if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) - { + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $receiveruser = $_POST['receiveruser']; - if (is_array($receiveruser) && count($receiveruser) > 0) - { + if (is_array($receiveruser) && count($receiveruser) > 0) { $fuserdest = new User($db); - foreach ($receiveruser as $key=>$val) - { + foreach ($receiveruser as $key => $val) { $tmparray[] = $fuserdest->user_get_property($val, 'email'); $sendtouserid[] = $val; } @@ -215,32 +214,27 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST // Define $sendtocc $receivercc = $_POST['receivercc']; - if (!is_array($receivercc)) - { - if ($receivercc == '-1') $receivercc = array(); - else $receivercc = array($receivercc); + if (!is_array($receivercc)) { + if ($receivercc == '-1') { + $receivercc = array(); + } else { + $receivercc = array($receivercc); + } } $tmparray = array(); - if (trim($_POST['sendtocc'])) - { + if (trim($_POST['sendtocc'])) { $tmparray[] = trim($_POST['sendtocc']); } - if (count($receivercc) > 0) - { - foreach ($receivercc as $key=>$val) - { - // Recipient was provided from combo list - if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too) - { + if (count($receivercc) > 0) { + foreach ($receivercc as $key => $val) { + if ($val == 'thirdparty') { // Key selected means currentthird party (may be usd for current member or current user too) + // Recipient was provided from combo list $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; - } - // Recipient was provided from combo list - elseif ($val == 'contact') // Key selected means current contact - { + } elseif ($val == 'contact') { // Key selected means current contact + // Recipient was provided from combo list $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; //$sendtoid[] = $contact->id; TODO Add also id of contact in CC ? - } elseif ($val) // $val is the Id of a contact - { + } elseif ($val) { // $val is the Id of a contact $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); //$sendtoid[] = ((int) $val); TODO Add also id of contact in CC ? } @@ -249,11 +243,9 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $receiverccuser = $_POST['receiverccuser']; - if (is_array($receiverccuser) && count($receiverccuser) > 0) - { + if (is_array($receiverccuser) && count($receiverccuser) > 0) { $fuserdest = new User($db); - foreach ($receiverccuser as $key=>$val) - { + foreach ($receiverccuser as $key => $val) { $tmparray[] = $fuserdest->user_get_property($val, 'email'); $sendtoccuserid[] = $val; } @@ -261,8 +253,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST } $sendtocc = implode(',', $tmparray); - if (dol_strlen($sendto)) - { + if (dol_strlen($sendto)) { // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -291,8 +282,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $sql .= ' WHERE rowid = '.(int) $reg[1]; $resql = $db->query($sql); $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>'; } } else { @@ -312,21 +302,20 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $sendtobcc = GETPOST('sendtoccc'); // Autocomplete the $sendtobcc // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO... - if (!empty($autocopy)) - { + if (!empty($autocopy)) { $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy)); } $deliveryreceipt = $_POST['deliveryreceipt']; - if ($action == 'send' || $action == 'relance') - { + if ($action == 'send' || $action == 'relance') { $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('at').' '.CMailFile::getValidAddress($sendto, 4, 0, 1); - if ($message) - { + if ($message) { $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc)); + if ($sendtocc) { + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc)); + } $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); $actionmsg = dol_concatdesc($actionmsg, $message); @@ -343,50 +332,6 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $filename = $attachedfiles['names']; $mimetype = $attachedfiles['mimes']; - // Feature to push mail sent into Sent folder - /* This code must be now included into the hook mail, method sendMailAfter - if (! empty($conf->dolimail->enabled)) - { - $mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# ' // TODO Use a better way to define Sent dir. - if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; - else - { - $mbid = $mailfromid[1]; - - // IMAP Postbox - $mailboxconfig = new IMAP($db); - $mailboxconfig->fetch($mbid); - if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref(); - - $mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox; - $mailboxconfig->userfolder_fetch(); - - if ($mailboxconfig->mailbox_save_sent_mails == 1) - { - - $folder=str_replace($ref, '', $mailboxconfig->folder_cache_key); - if (!$folder) $folder = "Sent"; // Default Sent folder - - $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password); - if (false === $mailboxconfig->mbox) - { - $info = false; - $err = $langs->trans('Error3_Imap_Connection_Error'); - setEventMessages($err,$mailboxconfig->element, null, 'errors'); - } - else - { - $mailboxconfig->mailboxid=$_POST['frommail']; - $mailboxconfig->foldername=$folder; - $from = $mailfromid[0] . $mailfromid[2]; - $imap=1; - } - - } - } - } - */ - // Make substitution in email content $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray['__EMAIL__'] = $sendto; @@ -398,38 +343,38 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $subject = make_substitutions($subject, $substitutionarray); $message = make_substitutions($message, $substitutionarray); - if (method_exists($object, 'makeSubstitution')) - { + if (method_exists($object, 'makeSubstitution')) { $subject = $object->makeSubstitution($subject); $message = $object->makeSubstitution($message); } // Send mail (substitutionarray must be done just before this) - if (empty($sendcontext)) $sendcontext = 'standard'; + if (empty($sendcontext)) { + $sendcontext = 'standard'; + } $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); - if ($mailfile->error) - { + if ($mailfile->error) { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); $action = 'presend'; } else { $result = $mailfile->sendfile(); - if ($result) - { + if ($result) { // Initialisation of datas of object to call trigger - if (is_object($object)) - { - if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically + if (is_object($object)) { + if (empty($actiontypecode)) { + $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically + } $object->socid = $sendtosocid; // To link to a company $object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array. $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $object->actionmsg = $actionmsg; // Long text (@todo Replace this with $message, we already have details of email in dedicated properties) - $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...); + $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...); $object->trackid = $trackid; - $object->fk_element = $object->id; - $object->elementtype = $object->element; + $object->fk_element = $object->id; + $object->elementtype = $object->element; if (is_array($attachedfiles) && count($attachedfiles) > 0) { $object->attachedfiles = $attachedfiles; } @@ -447,11 +392,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $object->email_msgid = $mailfile->msgid; // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated) - if (!empty($triggersendname) || !empty($trigger_name)) - { + if (!empty($triggersendname) || !empty($trigger_name)) { // Call trigger $result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers if ($error) { @@ -466,10 +412,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); setEventMessages($mesg, null, 'mesgs'); - $moreparam = ''; - if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2; - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam); - exit; + $moreparam = ''; + if (isset($paramname2) || isset($paramval2)) { + $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2; + } + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam); + exit; } else { $langs->load("other"); $mesg = '
'; From 5e692fa9db771f334afb13b6265f32a150fc0eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 09:47:29 +0100 Subject: [PATCH 06/20] doxygen --- htdocs/core/class/html.formmail.class.php | 66 ++++++++++++++++------- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index a4f936cfca0..fceaedffb98 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -120,8 +120,16 @@ class FormMail extends Form public $withtocc; public $withtoccc; public $withtopic; - public $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files - public $withmaindocfile; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) + + /** + * @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files + */ + public $withfile; + + /** + * @var int 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default) + */ + public $withmaindocfile; public $withbody; public $withfromreadonly; @@ -195,7 +203,9 @@ class FormMail extends Form // Set tmp user directory $vardir = $conf->user->dir_output."/".$user->id; $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path - if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir); + if (is_dir($upload_dir)) { + dol_delete_dir_recursive($upload_dir); + } $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined unset($_SESSION["listofpaths".$keytoavoidconflict]); @@ -219,15 +229,24 @@ class FormMail extends Form $listofnames = array(); $listofmimes = array(); - if (empty($file)) $file = basename($path); - if (empty($type)) $type = dol_mimetype($file); + if (empty($file)) { + $file = basename($path); + } + if (empty($type)) { + $type = dol_mimetype($file); + } $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined - if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); - if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); - if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); - if (!in_array($file, $listofnames)) - { + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) { + $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) { + $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) { + $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + } + if (!in_array($file, $listofnames)) { $listofpaths[] = $path; $listofnames[] = $file; $listofmimes[] = $type; @@ -252,11 +271,16 @@ class FormMail extends Form $listofmimes = array(); $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined - if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); - if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); - if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); - if ($keytodelete >= 0) - { + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) { + $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) { + $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) { + $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + } + if ($keytodelete >= 0) { unset($listofpaths[$keytodelete]); unset($listofnames[$keytodelete]); unset($listofmimes[$keytodelete]); @@ -281,9 +305,15 @@ class FormMail extends Form $listofmimes = array(); $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined - if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); - if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); - if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) { + $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) { + $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) { + $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + } return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); } From 2894dac22142ad4249dc18866e0bb9bd0fbd4d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 10:17:11 +0100 Subject: [PATCH 07/20] clean code --- htdocs/core/class/html.form.class.php | 57 ++++++++++++--------------- htdocs/langs/en_US/mails.lang | 5 ++- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7be97293938..240c94860a5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6707,24 +6707,20 @@ class Form } // Add code for jquery to use multiselect - if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) - { + if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { $out .= "\n".' '; - if ($acceptdelayedhtml) - { + if ($acceptdelayedhtml) { $delayedhtmlcontent .= $outdelayed; } else { $out .= $outdelayed; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 230c9a6b3bf..7fd93be7b71 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -174,5 +174,4 @@ Unanswered=Unanswered Answered=Answered IsNotAnAnswer=Is not answer (initial email) IsAnAnswer=Is an answer of an initial email -RecordCreatedByEmailCollector=Record created by the Email Collector %s from -email %s +RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s From eb3b0ad6729abf46f078489fe3acee2049351e82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 13:24:06 +0100 Subject: [PATCH 09/20] Fix warning --- htdocs/webservices/server_thirdparty.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 7c97159d0bb..a4f7e21221d 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -329,8 +329,9 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') 'supplier_code' => $thirdparty->code_fournisseur, 'customer_code_accountancy' => $thirdparty->code_compta, 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur, - 'fk_user_author' => $thirdparty->fk_user_author, + 'user_creation' => $thirdparty->fk_user_creat, 'date_creation' => dol_print_date($thirdparty->date_creation, 'dayhourrfc'), + 'user_modification' => $thirdparty->fk_user_modif, 'date_modification' => dol_print_date($thirdparty->date_modification, 'dayhourrfc'), 'address' => $thirdparty->address, 'zip' => $thirdparty->zip, From 791a509c6c0c7dd9e1aa6d9b9a7be5d9fac01401 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 13:26:50 +0100 Subject: [PATCH 10/20] Fix warning --- htdocs/webservices/server_thirdparty.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index a4f7e21221d..6d44fe41ff6 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -370,7 +370,9 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') { foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { - $thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key])); + if (isset($thirdparty->array_options['options_'.$key])) { + $thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key])); + } } } @@ -623,7 +625,9 @@ function updateThirdParty($authentication, $thirdparty) foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; - $object->array_options[$key] = $thirdparty[$key]; + if (isset($thirdparty[$key])) { + $object->array_options[$key] = $thirdparty[$key]; + } } } @@ -728,7 +732,9 @@ function getListOfThirdParties($authentication, $filterthirdparty) { foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { - $extrafieldsOptions['options_'.$key] = $obj->{$key}; + if (isset($obj->{$key})) { + $extrafieldsOptions['options_'.$key] = $obj->{$key}; + } } } From 2727fd70b7167025154922ae1b1094d802c34951 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 2 Jan 2021 14:00:24 +0100 Subject: [PATCH 11/20] FIX: Accountancy - Debug experimental function to validate movements --- htdocs/accountancy/closure/index.php | 88 ++++++++++++- htdocs/accountancy/closure/validate.php | 156 ------------------------ htdocs/core/menus/standard/eldy.lib.php | 4 - htdocs/langs/en_US/accountancy.lang | 4 +- 4 files changed, 89 insertions(+), 163 deletions(-) delete mode 100644 htdocs/accountancy/closure/validate.php diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index ed8fc8ecc7e..a8531ca0887 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -25,11 +25,16 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); +$socid = GETPOST('socid', 'int'); + +$action = GETPOST('action', 'aZ09'); + // Security check if (empty($conf->accounting->enabled)) { accessforbidden(); @@ -39,6 +44,7 @@ if ($user->socid > 0) if (!$user->rights->accounting->fiscalyear->write) accessforbidden(); +$object = new BookKeeping($db); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); @@ -60,14 +66,91 @@ $year_current = $year_start; /* * Actions */ +if ($action == 'validate_movements_confirm' && $user->rights->accounting->fiscalyear->write) { + $result = $object->fetchAll(); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + // Specify as export : update field date_validated on selected month/year + $error = 0; + $db->begin(); + + $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); + $date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); + + if (is_array($object->lines)) + { + foreach ($object->lines as $movement) + { + $now = dol_now(); + + $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " SET date_validated = '".$db->idate($now)."'"; + $sql .= " WHERE rowid = ".$movement->id; + $sql .= " AND doc_date >= '" . dol_print_date($date_start, 'dayrfc') . "'"; + $sql .= " AND doc_date <= '" . dol_print_date($date_end, 'dayrfc') . "'"; + + dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + $error++; + break; + } + } + } + + if (!$error) + { + $db->commit(); + setEventMessages($langs->trans("AllMovementsWereRecordedAsValidated"), null, 'mesgs'); + } else { + $error++; + $db->rollback(); + setEventMessages($langs->trans("NotAllMovementsCouldBeRecordedAsValidated"), null, 'errors'); + } + header("Location: ".$_SERVER['PHP_SELF']."?year=".$year_start); + exit; + } +} /* * View */ +$form = new Form($db); +$formaccounting = new FormAccounting($db); + llxHeader('', $langs->trans("Closure")); +if ($action == 'validate_movements') { + $form_question = array(); + + $month = isset($conf->global->SOCIETE_FISCAL_MONTH_START) ? intval($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $date_start = new DateTime(sprintf('%04d-%02d-%02d', $year_start, $month, 1)); + $date_end = new DateTime(sprintf('%04d-%02d-%02d', $year_start, $month, 1)); + $date_end->add(new DateInterval('P1Y')); + $date_end->sub(new DateInterval('P1D')); + + $form_question['date_start'] = array( + 'name' => 'date_start', + 'type' => 'date', + 'label' => $langs->trans('DateStart'), + 'value' => $date_start->format('Y-m-d') + ); + $form_question['date_end'] = array( + 'name' => 'date_end', + 'type' => 'date', + 'label' => $langs->trans('DateEnd'), + 'value' => $date_end->format('Y-m-d') + ); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?year='.$year_start, $langs->trans('ValidateMovements'), $langs->trans('DescValidateMovements', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'validate_movements_confirm', $form_question, '', 1, 300); + print $formconfirm; +} + $textprevyear = ''.img_previous().''; $textnextyear = ' '.img_next().''; @@ -80,9 +163,9 @@ print '
'; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateMovements").''; +$buttonvalidate = ''.$langs->trans("ValidateMovements").''; -print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); +print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonvalidate, '', 0, 1, 1); print '
'; print ''; @@ -104,6 +187,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; $sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; $sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; $sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy +$sql .= " AND date_validated IS NULL"; dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php deleted file mode 100644 index 1013ad1b6ce..00000000000 --- a/htdocs/accountancy/closure/validate.php +++ /dev/null @@ -1,156 +0,0 @@ - - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * \file htdocs/accountancy/closure/validate.php - * \ingroup Accountancy - * \brief Validate entries page - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); - -// Security check -if (empty($conf->accounting->enabled)) { - accessforbidden(); -} -if ($user->socid > 0) - accessforbidden(); - if (!$user->rights->accounting->fiscalyear->write) - accessforbidden(); - - -$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); -if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); -else { - $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year -} -$year_end = $year_start + 1; -$month_end = $month_start - 1; -if ($month_end < 1) -{ - $month_end = 12; - $year_end--; -} -$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); -$search_date_end = dol_get_last_day($year_end, $month_end); -$year_current = $year_start; - -/* - * Actions - */ - -if ($action == 'validate') -{ - $now = dol_now(); - - // Update database - $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " SET b.date_validated = '".$db->idate($now)."'"; - $sql .= ' WHERE b.date_validated IS NULL'; - - dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql1) { - $error++; - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } else { - $db->commit(); - } - // End clean database -} - - -/* - * View - */ - -llxHeader('', $langs->trans("ValidateMovements")); - -$textprevyear = ''.img_previous().''; -$textnextyear = ' '.img_next().''; - - -print load_fiche_titre($langs->trans("ValidateMovements")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); - -print $langs->trans("DescValidateMovements").'
'; -print '
'; - - -$y = $year_current; - -print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', '', -1, '', '', 0, '', 'class="right"', 0, 1, 1); - -print '
'; -print '
'; -print ''; -for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - print ''; -} -print ''; - -print ''; -$sql = "SELECT COUNT(b.rowid) as detail,"; -for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - $sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; -} -$sql .= " COUNT(b.rowid) as total"; -$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; -$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; -$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; -$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy - -dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - for ($i = 1; $i <= 12; $i++) { - print ''; - } - print ''; - } - - $db->free($resql); -} else { - print $db->lasterror(); // Show last sql error -} -print ''; -print "
'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'.$row[$i].'

'; - print ''; - print '
'.$row[13].'
\n"; - -print '
'; -print '
'; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 85b63a6f4e3..46950bdc50c 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1334,10 +1334,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Closure if (!empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->rights->accounting->fiscalyear->write, '', $mainmenu, 'closure'); - - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_closure/', $leftmenu)) { - $newmenu->add("/accountancy/closure/validate.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->fiscalyear->write); - } } // Reports diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index c7ce4ac6b0b..bda6502aeed 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -274,11 +274,13 @@ DescVentilExpenseReport=Consult here the list of expense report lines bound (or DescVentilExpenseReportMore=If you setup accounting account on type of expense report lines, the application will be able to make all the binding between your expense report lines and the accounting account of your chart of accounts, just in one click with the button "%s". If account was not set on fees dictionary or if you still have some lines not bound to any account, you will have to make a manual binding from the menu "%s". DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account +Closure=Annual closure DescClosure=Consult here the number of movements by month who are not validated & fiscal years already open OverviewOfMovementsNotValidated=Step 1/ Overview of movements not validated. (Necessary to close a fiscal year) +AllMovementsWereRecordedAsValidated=All movements were recorded as validated +NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated ValidateMovements=Validate movements DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible -SelectMonthAndValidate=Select month and validate movements ValidateHistory=Bind Automatically AutomaticBindingDone=Automatic binding done From a8d15fafd22707600afb54339ca1b6aef03914ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 14:17:54 +0100 Subject: [PATCH 12/20] Fix missing span --- htdocs/admin/limits.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index caf2192a9a3..ed3578522d4 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -293,7 +293,7 @@ if (empty($mysoc->country_code)) print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print " x ".$langs->trans("Quantity").": ".$qty; print " - ".$langs->trans("VAT").": ".$vat.'%'; - print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; + print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; $s = 10 / 3; $qty = 2; $vat = 10; $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array); From 601d4618d4c7bd50ab2e287df8f8ba1a3161cb76 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 14:52:37 +0100 Subject: [PATCH 13/20] Missing vat rates --- htdocs/install/mysql/data/llx_c_tva.sql | 27 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 793b29ab640..7156812fb01 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -35,6 +35,16 @@ delete from llx_c_tva; +-- ALGERIA (id country=13) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 131, 13, '0','0','TVA 0%', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 132, 13, '9','0','TVA 9%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 133, 13, '19','0','TVA 19%', 1); + +-- ANGOLA (id country=35) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 351, 35, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 352, 35, '7','0','VAT reduced rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 353, 35, '14','0','VAT standard rate',1); + -- ARGENTINA (id country=23) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (231, 23, '0','0','IVA Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (232, 23,'10.5','0','IVA reduced rate',1); @@ -202,6 +212,13 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 1 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 173, 17, '19','0','Algemeen BTW tarief',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 174, 17, '21','0','Algemeen BTW tarief (vanaf 1 oktober 2012)',0); +-- NEW CALEDONIA (id country=165) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1651, 165, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1652, 165, '3','0','VAT standard 3', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1653, 165, '6','0','VAT standard 6', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1654, 165, '11','0','VAT standard rate', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1655, 165, '22','0','VAT standard high', 1); + -- NEW ZEALAND (id country=166) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1661, 166, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1662, 166, '15','0','VAT standard rate', 1); @@ -361,16 +378,6 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (23 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2323,232, '8','0','VAT 8%',1); --- ALGERIA(id country=13) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 131, 13, '0','0','TVA 0%', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 132, 13, '9','0','TVA 9%',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 133, 13, '19','0','TVA 19%', 1); - --- ANGOLA (id country=35) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 351, 35, '0','0','VAT Rate 0', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 352, 35, '7','0','VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 353, 35, '14','0','VAT standard rate',1); - -- Example of code to insert a vat rate 0 for each country --delete from llx_c_tva where rowid = 1181; -- to delete a record that does not follow rules for rowid (fk_pays+'1') --insert into llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) SELECT CONCAT(c.rowid, '1'), c.rowid, 0, 0, 'No VAT', 1 from llx_c_country as c where c.rowid not in (select fk_pays from llx_c_tva); From d46eb08083a5239a0e9196d968e3b2b4bb556363 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 15:36:19 +0100 Subject: [PATCH 14/20] More log and use id to refresh/reload an invoice. --- htdocs/takepos/index.php | 5 +++-- htdocs/takepos/invoice.php | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 4bfeaa57b75..51b6334a2c9 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -155,6 +155,7 @@ var pageactions=0; var place=""; var editaction="qty"; var editnumber=""; +var invoiceid=0; /* var app = this; @@ -448,8 +449,8 @@ function TakeposOrderNotes() { } function Refresh() { - console.log("Refresh by reloading place="+place); - $("#poslines").load("invoice.php?place="+place, function() { + console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid); + $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 0909f1b3cca..f31bb90bfcd 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -742,7 +742,7 @@ function DolibarrTakeposPrinting(id) { $( document ).ready(function() { - console.log("Set customer info and sales in header"); + console.log("Set customer info and sales in header placeid= status=statut; ?>"); trans("Customer"); @@ -757,7 +757,14 @@ $( document ).ready(function() { global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) { + // By default, only invoices with a ref not already defined can in list of open invoice we can edit. + $sql .= " WHERE ref LIKE '(PROV-POS".$_SESSION["takeposterminal"]."-0%'"; + } else { + // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined + $sql .= " WHERE pos_source = ".$_SESSION["takeposterminal"]; + $sql .= " AND module_source = 'takepos'"; + } $sql .= $db->order('datec', 'ASC'); $resql = $db->query($sql); if ($resql) { @@ -767,7 +774,9 @@ $( document ).ready(function() { $num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref)); echo $num_sale; if (str_replace("-", "", $num_sale) > $max_sale) $max_sale = str_replace("-", "", $num_sale); - echo '\\\';Refresh();">'; + echo '\\\'; invoiceid=\\\''; + echo $obj->rowid; + echo '\\\'; Refresh();">'; if ($placeid == $obj->rowid) echo ""; echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser'); if ($placeid == $obj->rowid) echo ""; @@ -775,7 +784,7 @@ $( document ).ready(function() { } echo '$("#customerandsales").append(\'\');'; + echo '\\\'; invoiceid=0; Refresh();">\');'; } else { dol_print_error($db); } From 02ae06f24abdd2e7c45f704568c61e3778ef03a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 15:52:12 +0100 Subject: [PATCH 15/20] Fix warning --- htdocs/webservices/server_thirdparty.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 6d44fe41ff6..d7ded82cc3f 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -329,9 +329,9 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') 'supplier_code' => $thirdparty->code_fournisseur, 'customer_code_accountancy' => $thirdparty->code_compta, 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur, - 'user_creation' => $thirdparty->fk_user_creat, + 'user_creation' => $thirdparty->user_creation, 'date_creation' => dol_print_date($thirdparty->date_creation, 'dayhourrfc'), - 'user_modification' => $thirdparty->fk_user_modif, + 'user_modification' => $thirdparty->user_modification, 'date_modification' => dol_print_date($thirdparty->date_modification, 'dayhourrfc'), 'address' => $thirdparty->address, 'zip' => $thirdparty->zip, From 2d22c1d5d167622b46f97765cfd7b31dd5bfdc80 Mon Sep 17 00:00:00 2001 From: Aisuko <17001223+AisukoWasTaken@users.noreply.github.com> Date: Fri, 1 Jan 2021 22:53:01 +0100 Subject: [PATCH 16/20] Fix wrong cast for pos_change The variable pos_change was cast in "int" where it should be cast in "float". It results in rounded value making the receipt showing wrong cash exchange. --- htdocs/compta/paiement/class/paiement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 28635a2df60..6b7f1612836 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -294,7 +294,7 @@ class Paiement extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", "; - $sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")"; + $sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((float) $this->pos_change).")"; $resql = $this->db->query($sql); if ($resql) From ce0abd17fe543c12606f585ca9085925072deb5a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 16:18:16 +0100 Subject: [PATCH 17/20] Debug v13 --- htdocs/commande/card.php | 6 +++--- htdocs/compta/facture/card-rec.php | 8 ++++---- htdocs/contrat/card.php | 8 ++++---- htdocs/core/lib/functions.lib.php | 18 +++++++++++++----- htdocs/fourn/commande/card.php | 10 +++++----- htdocs/fourn/facture/card.php | 10 +++++----- htdocs/supplier_proposal/card.php | 10 +++++----- 7 files changed, 39 insertions(+), 31 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 213819b0915..2ea5c37bf39 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -631,9 +631,9 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); - $price_ht = GETPOST('price_ht'); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index b978de677a9..097585dbea0 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -437,9 +437,9 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); - $price_ht = GETPOST('price_ht'); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha'); if ($prod_entry_mode == 'free') { @@ -450,7 +450,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = GETPOST('remise_percent'.$predef); // Extrafields diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 2e692dc25c4..d07b8dcc60e 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -383,9 +383,9 @@ if (empty($reshook)) { // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); - $price_ht = price2num(GETPOST('price_ht')); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht')); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR'); if (GETPOST('prod_entry_mode', 'alpha') == 'free') { $idprod = 0; @@ -395,7 +395,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef)); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = ((GETPOST('remise_percent'.$predef) != '') ? GETPOST('remise_percent'.$predef) : 0); if ($qty == '') diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a156f35292e..8c1765620ec 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4810,7 +4810,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) - * 'CR'=Currency rate + * 'CR'=Foreign currency accurancy * Numeric = Nb of digits for rounding * @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done) * Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator). @@ -4871,10 +4871,18 @@ function price2num($amount, $rounding = '', $option = 0) if ($rounding) { $nbofdectoround = ''; - if ($rounding == 'MU') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; - elseif ($rounding == 'MT') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; - elseif ($rounding == 'MS') $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; - elseif ($rounding == 'CR') $nbofdectoround = 8; + if ($rounding == 'MU') { + $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; + } + elseif ($rounding == 'MT') { + $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; + } + elseif ($rounding == 'MS') { + $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; + } + elseif ($rounding == 'CR') { + $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8); + } elseif (is_numeric($rounding)) $nbofdectoround = $rounding; //print "RR".$amount.' - '.$nbofdectoround.'
'; if (dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0. diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 987b80aa3ea..710657e1c16 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -356,24 +356,24 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { $idprod = 0; - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod = GETPOST('idprod', 'int'); - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = GETPOST('remise_percent'.$predef); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c615817e36f..998ef884766 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1175,7 +1175,7 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -1183,17 +1183,17 @@ if (empty($reshook)) if ($prod_entry_mode == 'free') { $idprod = 0; - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod = GETPOST('idprod', 'int'); - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = GETPOST('remise_percent'.$predef); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index ae40784aa68..a571a207bc5 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -540,24 +540,24 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $ref_supplier = GETPOST('fourn_ref', 'alpha'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { $idprod = 0; - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod = GETPOST('idprod', 'int'); - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = GETPOST('remise_percent'.$predef); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); From fd4dab495f010fc170c94ab3e6d5a47be7e7f605 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 16:51:34 +0100 Subject: [PATCH 18/20] FIX Bad cleaning of VAT rate when numbers are into code --- htdocs/comm/propal/class/propal.class.php | 5 ++++- htdocs/commande/class/commande.class.php | 4 +++- htdocs/compta/facture/class/facture-rec.class.php | 11 ++++++++--- htdocs/compta/facture/class/facture.class.php | 4 +++- htdocs/contrat/class/contrat.class.php | 1 - htdocs/fichinter/class/fichinterrec.class.php | 4 +++- htdocs/fourn/class/fournisseur.commande.class.php | 4 +++- .../class/supplier_proposal.class.php | 11 ++++++++--- 8 files changed, 32 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 144374ab47c..9d6b6c201c5 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -602,6 +602,7 @@ class Propal extends CommonObject // Clean vat code $vat_src_code = ''; + $reg = array(); if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; @@ -779,7 +780,9 @@ class Propal extends CommonObject $qty = price2num($qty); $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); $pa_ht = price2num($pa_ht); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5402d31ba7d..49f8005980f 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3120,7 +3120,9 @@ class Commande extends CommonOrder $pu = price2num($pu); $pa_ht = price2num($pa_ht); $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index c5bd8a987ac..85ecb3f969d 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -849,7 +849,9 @@ class FactureRec extends CommonInvoice $qty = price2num($qty); $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); if (empty($txtva)) $txtva = 0; @@ -1031,8 +1033,10 @@ class FactureRec extends CommonInvoice $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } + $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); if (empty($txlocaltax1)) $txlocaltax1 = 0; if (empty($txlocaltax2)) $txlocaltax2 = 0; @@ -1059,6 +1063,7 @@ class FactureRec extends CommonInvoice // Clean vat code $vat_src_code = ''; + $reg = array(); if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4bfc36a3e78..392817b0368 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3311,7 +3311,9 @@ class Facture extends CommonInvoice $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); $pa_ht = price2num($pa_ht); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e38c24565dd..13f0ba644d0 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1502,7 +1502,6 @@ class Contrat extends CommonObject $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 5b3dfb3a2fc..2d678514182 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -473,7 +473,9 @@ class FichinterRec extends Fichinter if (!$info_bits) $info_bits = 0; $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } if ($price_base_type == 'HT') { $pu = $pu_ht; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index af283d8cdf0..123b1eb0046 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2633,7 +2633,9 @@ class CommandeFournisseur extends CommonOrder if (!$qty) $qty = 1; $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 33c80f9b6b1..9822c171cd8 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -423,10 +423,13 @@ class SupplierProposal extends CommonObject $qty = price2num($qty); $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - $pa_ht = price2num($pa_ht); + + $pa_ht = price2num($pa_ht); if ($price_base_type == 'HT') { $pu = $pu_ht; @@ -682,7 +685,9 @@ class SupplierProposal extends CommonObject $remise_percent = price2num($remise_percent); $qty = price2num($qty); $pu = price2num($pu); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); $pa_ht = price2num($pa_ht); From 982f8eb95d2be6300cbcdc2400a8bdf016a76335 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 17:03:26 +0100 Subject: [PATCH 19/20] Fix syntax error --- htdocs/contrat/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d07b8dcc60e..9b1a3b34808 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -385,7 +385,7 @@ if (empty($reshook)) $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht'), 'MU'); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR')); if (GETPOST('prod_entry_mode', 'alpha') == 'free') { $idprod = 0; From 2d1121031a886398a31594684785ed8040bc8558 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 17:04:08 +0100 Subject: [PATCH 20/20] var not defined --- htdocs/contrat/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 9b1a3b34808..64f8fd92477 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -89,6 +89,7 @@ $extralabelslines = $extrafields->fetch_name_optionals_label($object->table_elem $permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php +$error = 0; /*