diff --git a/ChangeLog b/ChangeLog index b3417c85c05..d99ed9a5836 100644 --- a/ChangeLog +++ b/ChangeLog @@ -152,6 +152,7 @@ NEW: #4301 For Developers or integrators: +NEW: Compatible with PHP 7.4 NEW: Code for extrafields uses the new array $extrafields->attributes NEW: Can set a filter on object linked in modulebuilder. NEW: Can defined a position of numbering submodules for thirdparties diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 6068e6ec0c1..ebc4a29793c 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -357,25 +357,25 @@ class BookKeeping extends CommonObject $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->doc_date)."'"; $sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'"); - $sql .= ",'".$this->db->escape($this->doc_type)."'"; - $sql .= ",'".$this->db->escape($this->doc_ref)."'"; - $sql .= ",".$this->fk_doc; - $sql .= ",".$this->fk_docdet; - $sql .= ",'".$this->db->escape($this->thirdparty_code)."'"; - $sql .= ",'".$this->db->escape($this->subledger_account)."'"; - $sql .= ",'".$this->db->escape($this->subledger_label)."'"; - $sql .= ",'".$this->db->escape($this->numero_compte)."'"; - $sql .= ",'".$this->db->escape($this->label_compte)."'"; - $sql .= ",'".$this->db->escape($this->label_operation)."'"; - $sql .= ",".$this->debit; - $sql .= ",".$this->credit; - $sql .= ",".$this->montant; - $sql .= ",'".$this->db->escape($this->sens)."'"; - $sql .= ",'".$this->db->escape($this->fk_user_author)."'"; - $sql .= ",'".$this->db->idate($now)."'"; - $sql .= ",'".$this->db->escape($this->code_journal)."'"; - $sql .= ",'".$this->db->escape($this->journal_label)."'"; - $sql .= ",".$this->db->escape($this->piece_num); + $sql .= ", '".$this->db->escape($this->doc_type)."'"; + $sql .= ", '".$this->db->escape($this->doc_ref)."'"; + $sql .= ", ".$this->fk_doc; + $sql .= ", ".$this->fk_docdet; + $sql .= ", ".(!empty($this->thirdparty_code)?("'".$this->db->escape($this->thirdparty_code)."'"):"NULL"); + $sql .= ", ".(!empty($this->subledger_account)?("'".$this->db->escape($this->subledger_account)."'"):"NULL"); + $sql .= ", ".(!empty($this->subledger_label)?("'".$this->db->escape($this->subledger_label)."'"):"NULL"); + $sql .= ", '".$this->db->escape($this->numero_compte)."'"; + $sql .= ", ".(!empty($this->label_operation)?("'".$this->db->escape($this->label_operation)."'"):"NULL"); + $sql .= ", '".$this->db->escape($this->label_operation)."'"; + $sql .= ", ".$this->debit; + $sql .= ", ".$this->credit; + $sql .= ", ".$this->montant; + $sql .= ", ".(!empty($this->sens)?("'".$this->db->escape($this->sens)."'"):"NULL"); + $sql .= ", '".$this->db->escape($this->fk_user_author)."'"; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", '".$this->db->escape($this->code_journal)."'"; + $sql .= ", ".(!empty($this->journal_label)?("'".$this->db->escape($this->journal_label)."'"):"NULL"); + $sql .= ", ".$this->db->escape($this->piece_num); $sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ")"; diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index cfbeb29c7c3..a2eead267af 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -142,14 +142,14 @@ $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' '; if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) { // Button off, click to enable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= ''; } @@ -174,8 +174,8 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) $adht = new AdherentType($db); print ''; print $langs->trans("ForceMemberType"); - print ''; - $listofval = array(-1 => $langs->trans("Undefined")); + print ''; + $listofval = array(); $listofval += $adht->liste_array(); $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1:0); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 20854f57279..30ecafcf3e4 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -691,14 +691,14 @@ if ($rowid > 0) print ''; print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($conf->banque->enabled)) { - print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); } print "\n"; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 1dfb49a6c05..0364b829b2c 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -825,10 +825,13 @@ if ($mode == 'common') $warningmessage = ''; if (!empty($arrayofwarnings[$modName])) { - print ''."\n"; + print ''."\n"; foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) { - $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code); + if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) + { + $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code); + } } } if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) diff --git a/htdocs/bom/admin/index.html b/htdocs/bom/admin/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/bom/admin/setup.php b/htdocs/bom/admin/setup.php deleted file mode 100644 index 6abad8e3d58..00000000000 --- a/htdocs/bom/admin/setup.php +++ /dev/null @@ -1,129 +0,0 @@ - - * Copyright (C) 2019 Maxime Kohlhaas - * Copyright (C) 2019 Frédéric France - * - * 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 bom/admin/setup.php - * \ingroup bom - * \brief Bom setup page. - */ - -// Load Dolibarr environment -require '../../main.inc.php'; -// Libraries -require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; -require_once '../lib/bom.lib.php'; -//require_once "../class/myclass.class.php"; - -// Translations -$langs->loadLangs(array("admin", "mrp")); - -// Access control -if (!$user->admin) accessforbidden(); - -// Parameters -$action = GETPOST('action', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); - -$arrayofparameters = array( - 'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), - 'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) -); - - -/* - * Actions - */ -include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; - -/* - * View - */ - -$page_name = "BomSetup"; -llxHeader('', $langs->trans($page_name)); - -// Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; - -print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom'); - -// Configuration header -$head = bomAdminPrepareHead(); -dol_fiche_head($head, 'settings', '', -1, "bom"); - -// Setup page goes here -echo $langs->trans("BomSetupPage").'

'; - - -if ($action == 'edit') -{ - print '
'; - print ''; - print ''; - - print ''; - print ''; - - foreach ($arrayofparameters as $key => $val) - { - print ''; - } - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
'; - - print '
'; - print ''; - print '
'; - - print '
'; - print '
'; -} -else -{ - if (!empty($arrayofparameters)) - { - print ''; - print ''; - - foreach ($arrayofparameters as $key => $val) - { - print ''; - } - - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print ''.$conf->global->$key.'
'; - - print '
'; - print ''.$langs->trans("Modify").''; - print '
'; - } - else - { - print '
'.$langs->trans("NothingToSetup"); - } -} - - -// Page end -dol_fiche_end(); - -llxFooter(); -$db->close(); diff --git a/htdocs/cashdesk/tpl/validation2.tpl.php b/htdocs/cashdesk/tpl/validation2.tpl.php index 624f4ef9701..eab69c6b35d 100644 --- a/htdocs/cashdesk/tpl/validation2.tpl.php +++ b/htdocs/cashdesk/tpl/validation2.tpl.php @@ -48,9 +48,9 @@ $langs->loadLangs(array("main","bills")); -

trans("ShowInvoice"); ?>

+

trans("ShowInvoice"); ?>


-

trans("PrintTicket"); ?>

+

trans("PrintTicket"); ?>

diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 2de1b00c683..94b19771159 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -514,9 +514,10 @@ class ActionComm extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); - // Now insert assignedusers + // Now insert assigned users if (!$error) { + //dol_syslog(var_export($this->userassigned, true)); foreach ($this->userassigned as $key => $val) { if (!is_array($val)) // For backward compatibility when val=id @@ -524,16 +525,20 @@ class ActionComm extends CommonObject $val = array('id'=>$val); } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; + if ($val['id'] > 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->errors[] = $this->db->lasterror(); - } - //var_dump($sql);exit; + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + dol_syslog('Error to process userassigned: '.$this->db->lasterror(), LOG_ERR); + $this->errors[] = $this->db->lasterror(); + } + //var_dump($sql);exit; + } } } @@ -541,7 +546,7 @@ class ActionComm extends CommonObject { if (!empty($this->socpeopleassigned)) { - foreach ($this->socpeopleassigned as $id => $Tab) + foreach ($this->socpeopleassigned as $id => $val) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; @@ -550,6 +555,7 @@ class ActionComm extends CommonObject if (!$resql) { $error++; + dol_syslog('Error to process socpeopleassigned: '.$this->db->lasterror(), LOG_ERR); $this->errors[] = $this->db->lasterror(); } } @@ -558,8 +564,6 @@ class ActionComm extends CommonObject if (!$error) { - $action = 'create'; - // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -1721,6 +1725,13 @@ class ActionComm extends CommonObject } $diff++; } + + $parameters=array('filters' => $filters, 'eventarray' => &$eventarray); + $reshook=$hookmanager->executeHooks('addMoreEventsExport', $parameters); // Note that $action and $object may have been modified by hook + if ($reshook > 0) + { + $eventarray = $hookmanager->resArray; + } } else { diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index dbceabf642e..2a32e173d3b 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry @@ -238,6 +238,7 @@ print ''; print ''; +print '
'; print ''; print ''; print ''; @@ -261,6 +262,7 @@ print ''; print "
'.$langs->trans("TransferFrom").''.$langs->trans("TransferTo").''.$langs->trans("Date").''.$langs->trans("Description").''.$langs->trans("Amount").'
"; +print '
'; print '
'; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index f4a88f8eba2..2db276ebbbe 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -456,7 +456,7 @@ if ($id) print '
'; print '
'; - print ''; + print '
'; // Label print ''; diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 2a56122d6f3..37ff26b0b4b 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -134,7 +134,7 @@ if ($object->id) print '
'.$langs->trans("Label").''.$object->label.'
'; - print ''; + print ''; print ''; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2cacb885fa9..3f3bffc6cd2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -780,6 +780,23 @@ if (empty($reshook)) } } + // If some payments were already done, we change the amount to pay using same prorate + if (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { + $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. + if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) { + $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc); + foreach($amount_ht as $vatrate => $val) { + $amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU'); + $amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU'); + $amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_ht[$line->tva_tx] = price2num($multicurrency_amount_ht[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_tva[$line->tva_tx] = price2num($multicurrency_amount_tva[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_ttc[$line->tva_tx] = price2num($multicurrency_amount_ttc[$vatrate] * $ratio, 'MU'); + } + } + } + //var_dump($amount_ht);var_dump($amount_tva);var_dump($amount_ttc);exit; + // Insert one discount by VAT rate category $discount = new DiscountAbsolute($db); if ($object->type == Facture::TYPE_CREDIT_NOTE) @@ -1520,7 +1537,7 @@ if (empty($reshook)) if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; // View third's localtaxes for NOW and do not use value from origin. - // TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? + // TODO Is this really what we want ? Yes if source is template invoice but what if proposal or order ? $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); @@ -5014,7 +5031,9 @@ elseif ($id > 0 || !empty($ref)) print ''.$langs->trans('ConvertExcessReceivedToReduc').''; } // For credit note - if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && $object->getSommePaiement() == 0) { + if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate + && (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) + ) { print ''.$langs->trans('ConvertToReduc').''; } // For deposit invoice diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index e4a4a275029..75dcb837df9 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -327,28 +327,6 @@ class Paiement extends CommonObject //var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit; - /* Why this ? We can remove i think. - // If there is withdrawals request to do and not done yet on the invoice the payment is on, we wait before closing. - $mustwait=0; - $sqlrequest ="SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX."prelevement_facture_demande"; - $sqlrequest.="WHERE fk_facture = ".$invoice->id." AND traite = 0"; - ... - - $listofpayments=$invoice->getListOfPayments(); - foreach($listofpayments as $paym) - { - // This payment on invoice $invoice might be the one we record or another one - if ($paym['type']=='PRE') - { - if (! empty($conf->prelevement->enabled)) - { - // if not, $mustwait++; // This will disable automatic close on invoice to allow to process - - } - } - } - */ - //Invoice types that are eligible for changing status to paid $affected_types = array( Facture::TYPE_STANDARD, diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index a9eb9d52433..4050d081fe4 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -49,10 +49,10 @@ class BonPrelevement extends CommonObject */ public $table_element = 'prelevement_bons'; - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'payment'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'payment'; public $date_echeance; public $raison_sociale; @@ -116,7 +116,7 @@ class BonPrelevement extends CommonObject $this->fetched = 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add invoice to withdrawal * @@ -132,7 +132,7 @@ class BonPrelevement extends CommonObject */ public function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) { - // phpcs:enable + // phpcs:enable $result = 0; $line_id = 0; @@ -196,8 +196,8 @@ class BonPrelevement extends CommonObject if ($concat == 1) { /* - * We aggregate the lines - */ + * We aggregate the lines + */ $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes"; $sql .= " WHERE fk_prelevement_bons = ".$this->id; @@ -219,8 +219,8 @@ class BonPrelevement extends CommonObject else { /* - * No aggregate - */ + * No aggregate + */ $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_lignes ("; $sql .= "fk_prelevement_bons"; $sql .= ", fk_soc"; @@ -335,7 +335,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set credite and set status of linked invoices. Still used ?? * @@ -343,7 +343,7 @@ class BonPrelevement extends CommonObject */ public function set_credite() { - // phpcs:enable + // phpcs:enable global $user, $conf; $error = 0; @@ -351,7 +351,7 @@ class BonPrelevement extends CommonObject if ($this->db->begin()) { $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; - $sql .= " SET statut = 1"; + $sql .= " SET statut = ".self::STATUS_TRANSFERED; $sql .= " WHERE rowid = ".$this->id; $sql .= " AND entity = ".$conf->entity; @@ -392,8 +392,8 @@ class BonPrelevement extends CommonObject } /* - * End of procedure - */ + * End of procedure + */ if (!$error) { $this->db->commit(); @@ -414,7 +414,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set direct debit order to "credited" status. * @@ -424,7 +424,7 @@ class BonPrelevement extends CommonObject */ public function set_infocredit($user, $date) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $error = 0; @@ -437,11 +437,11 @@ class BonPrelevement extends CommonObject { $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons "; $sql .= " SET fk_user_credit = ".$user->id; - $sql .= ", statut = 2"; + $sql .= ", statut = ".self::STATUS_CREDITED; $sql .= ", date_credit = '".$this->db->idate($date)."'"; $sql .= " WHERE rowid=".$this->id; $sql .= " AND entity = ".$conf->entity; - $sql .= " AND statut = 1"; + $sql .= " AND statut = ".self::STATUS_TRANSFERED; if ($this->db->query($sql)) { @@ -483,7 +483,8 @@ class BonPrelevement extends CommonObject $paiement->datepaye = $date; $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice $paiement->paiementid = 3; // - $paiement->num_paiement = $this->ref; // Set ref of direct debit note + $paiement->num_payment = $this->ref; // Set ref of direct debit note + $paiement->num_paiement = $this->ref; // For bacward compatibility $paiement->id_prelevement = $this->id; $paiement_id = $paiement->create($user); @@ -525,12 +526,12 @@ class BonPrelevement extends CommonObject } /* - * End of procedure - */ + * End of procedure + */ if ($error == 0) { $this->date_credit = $date; - $this->statut = 1; + $this->statut = self::STATUS_CREDITED; $this->db->commit(); return 0; @@ -560,7 +561,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set withdrawal to transmited status * @@ -571,7 +572,7 @@ class BonPrelevement extends CommonObject */ public function set_infotrans($user, $date, $method) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $error = 0; @@ -639,9 +640,9 @@ class BonPrelevement extends CommonObject $arr = array(); /* - * Returns all invoices presented - * within a withdrawal receipt - */ + * Returns all invoices presented + * within a withdrawal receipt + */ $sql = "SELECT fk_facture"; if ($amounts) $sql .= ", SUM(pl.amount)"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; @@ -685,7 +686,7 @@ class BonPrelevement extends CommonObject return $arr; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns amount of withdrawal * @@ -693,7 +694,7 @@ class BonPrelevement extends CommonObject */ public function SommeAPrelever() { - // phpcs:enable + // phpcs:enable global $conf; $sql = "SELECT sum(pfd.amount) as nb"; @@ -724,7 +725,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get number of invoices to withdrawal * TODO delete params banque and agence when not necesary @@ -735,7 +736,7 @@ class BonPrelevement extends CommonObject */ public function NbFactureAPrelever($banque = 0, $agence = 0) { - // phpcs:enable + // phpcs:enable global $conf; $sql = "SELECT count(f.rowid) as nb"; @@ -769,7 +770,7 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a withdraw * TODO delete params banque and agence when not necesary @@ -784,7 +785,7 @@ class BonPrelevement extends CommonObject */ public function Create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG); @@ -797,8 +798,8 @@ class BonPrelevement extends CommonObject $error = 0; $datetimeprev = time(); - //Choice the date of the execution direct debit - if (!empty($executiondate)) $datetimeprev = $executiondate; + //Choice the date of the execution direct debit + if (!empty($executiondate)) $datetimeprev = $executiondate; $month = strftime("%m", $datetimeprev); $year = strftime("%Y", $datetimeprev); @@ -929,12 +930,12 @@ class BonPrelevement extends CommonObject // Return warning /*$i=0; - foreach ($this->thirdparty_in_error as $key => $val) - { - if ($i < 10) setEventMessages($val, null, 'warnings'); - else setEventMessages('More error were discarded...', null, 'warnings'); - $i++; - }*/ + foreach ($this->thirdparty_in_error as $key => $val) + { + if ($i < 10) setEventMessages($val, null, 'warnings'); + else setEventMessages('More error were discarded...', null, 'warnings'); + $i++; + }*/ if (count($factures_prev) > 0) { @@ -952,16 +953,16 @@ class BonPrelevement extends CommonObject if ($ok) { /* - * We are in real mode. - * We create withdraw receipt and build withdraw into disk - */ + * We are in real mode. + * We create withdraw receipt and build withdraw into disk + */ $this->db->begin(); $now = dol_now(); /* - * Traitements - */ + * Traitements + */ if (!$error) { $ref = substr($year, -2).$month; @@ -1017,8 +1018,8 @@ class BonPrelevement extends CommonObject if (!$error) { /* - * Create withdrawal receipt in database - */ + * Create withdrawal receipt in database + */ if (count($factures_prev) > 0) { foreach ($factures_prev as $fac) // Add a link in database for each invoice @@ -1027,17 +1028,17 @@ class BonPrelevement extends CommonObject $fact = new Facture($this->db); $fact->fetch($fac[0]); /* - * Add standing order - * - * - * $fac[3] : banque - * $fac[4] : guichet - * $fac[5] : number - * $fac[6] : cle rib - * $fac[7] : amount - * $fac[8] : client nom - * $fac[2] : client id - */ + * Add standing order + * + * + * $fac[3] : banque + * $fac[4] : guichet + * $fac[5] : number + * $fac[6] : cle rib + * $fac[7] : amount + * $fac[8] : client nom + * $fac[2] : client id + */ $ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6]); if ($ri <> 0) { @@ -1066,8 +1067,8 @@ class BonPrelevement extends CommonObject if (!$error) { /* - * Create direct debit order in a XML file - */ + * Create direct debit order in a XML file + */ dol_syslog(__METHOD__."::Init withdraw receipt for ".count($factures_prev)." invoices", LOG_DEBUG); @@ -1104,8 +1105,8 @@ class BonPrelevement extends CommonObject //var_dump($factures_prev);exit; /* - * Update total - */ + * Update total + */ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql .= " SET amount = ".price2num($this->total); $sql .= " WHERE rowid = ".$this->id; @@ -1118,13 +1119,13 @@ class BonPrelevement extends CommonObject dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR); } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } if (!$error) { @@ -1160,10 +1161,10 @@ class BonPrelevement extends CommonObject if (!$notrigger) { - // Call trigger - $result = $this->call_trigger('DIRECT_DEBIT_ORDER_DELETE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('DIRECT_DEBIT_ORDER_DELETE', $user); + if ($result < 0) $error++; + // End call triggers } if (!$error) @@ -1210,11 +1211,11 @@ class BonPrelevement extends CommonObject /** * Returns clickable name (with picto) * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string URL of target */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) @@ -1280,7 +1281,7 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a notification def by id * @@ -1289,7 +1290,7 @@ class BonPrelevement extends CommonObject */ public function DeleteNotificationById($rowid) { - // phpcs:enable + // phpcs:enable $result = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; @@ -1305,7 +1306,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a notification * @@ -1315,7 +1316,7 @@ class BonPrelevement extends CommonObject */ public function DeleteNotification($user, $action) { - // phpcs:enable + // phpcs:enable $result = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; @@ -1331,7 +1332,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a notification * @@ -1342,7 +1343,7 @@ class BonPrelevement extends CommonObject */ public function AddNotification($db, $user, $action) { - // phpcs:enable + // phpcs:enable $result = 0; if ($this->DeleteNotification($user, $action) == 0) @@ -1376,7 +1377,7 @@ class BonPrelevement extends CommonObject * File is generated with name this->filename * * @param string $format FRST, RCUR or ALL - * @param string $executiondate Date to execute transfer + * @param string $executiondate Date to execute transfer * @return int 0 if OK, <0 if KO */ public function generate($format = 'ALL', $executiondate = '') @@ -1414,7 +1415,7 @@ class BonPrelevement extends CommonObject $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S'); $date_actu = $now; - if (!empty($executiondate)) $date_actu = $executiondate; + if (!empty($executiondate)) $date_actu = $executiondate; $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S'); @@ -1554,12 +1555,12 @@ class BonPrelevement extends CommonObject fclose($this->file); if (!empty($conf->global->MAIN_UMASK)) - @chmod($this->file, octdec($conf->global->MAIN_UMASK)); - return $result; + @chmod($this->file, octdec($conf->global->MAIN_UMASK)); + return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write recipient of request (customer) * @@ -1576,7 +1577,7 @@ class BonPrelevement extends CommonObject */ public function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom = '') { - // phpcs:enable + // phpcs:enable fputs($this->file, "06"); fputs($this->file, "08"); // Prelevement ordinaire @@ -1647,7 +1648,7 @@ class BonPrelevement extends CommonObject return $pre.'-'.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write recipient of request (customer) * @@ -1667,15 +1668,15 @@ class BonPrelevement extends CommonObject * @param string $row_bic rib.bic AS bic, * @param string $row_datec rib.datec, * @param string $row_drum rib.rowid used to generate rum - * @param string $row_rum rib.rum Rum defined on company bank account + * @param string $row_rum rib.rum Rum defined on company bank account * @return string Return string with SEPA part DrctDbtTxInf */ public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum, $row_rum) { - // phpcs:enable - global $conf; + // phpcs:enable + global $conf; - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $CrLf = "\n"; $Rowing = sprintf("%06d", $row_idfac); @@ -1690,7 +1691,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR = ''; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.round($row_somme, 2).''.$CrLf; @@ -1722,8 +1723,8 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf; - // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max + // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf; + // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1731,7 +1732,7 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write sender of request (me) * @@ -1739,7 +1740,7 @@ class BonPrelevement extends CommonObject */ public function EnregEmetteur() { - // phpcs:enable + // phpcs:enable fputs($this->file, "03"); fputs($this->file, "08"); // Prelevement ordinaire @@ -1798,7 +1799,7 @@ class BonPrelevement extends CommonObject fputs($this->file, "\n"); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write sender of request (me). * Note: The tag PmtInf is opened here but closed into caller @@ -1813,7 +1814,7 @@ class BonPrelevement extends CommonObject */ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST') { - // phpcs:enable + // phpcs:enable // SEPA INITIALISATION global $conf; @@ -1892,13 +1893,13 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; - $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; - $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$CrLf;*/ + $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; + $XML_SEPA_INFO .= ' '.$CrLf; + $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; + $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; + $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; + $XML_SEPA_INFO .= ' '.$CrLf; + $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -1921,7 +1922,7 @@ class BonPrelevement extends CommonObject return $XML_SEPA_INFO; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write end * @@ -1930,7 +1931,7 @@ class BonPrelevement extends CommonObject */ public function EnregTotal($total) { - // phpcs:enable + // phpcs:enable fputs($this->file, "08"); fputs($this->file, "08"); // Prelevement ordinaire @@ -1995,7 +1996,7 @@ class BonPrelevement extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return status label for a status * diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index fecc5a96aa1..5bb218d46cd 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -108,6 +108,10 @@ class ChargeSociales extends CommonObject public $fk_project; + const STATUS_UNPAID = 0; + const STATUS_PAID = 1; + + /** * Constructor * @@ -495,43 +499,23 @@ class ChargeSociales extends CommonObject // Load translation files required by the page $langs->loadLangs(array("customers","bills")); - if ($mode == 0 || $mode == 1) + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - if ($status == 0) return $langs->trans("Unpaid"); - elseif ($status == 1) return $langs->trans("Paid"); - } - elseif ($mode == 2) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - elseif ($mode == 3) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6'); - } - elseif ($mode == 4) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - elseif ($mode == 5) - { - if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); - } - elseif ($mode == 6) - { - if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); + $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); + if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); + if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); } - else return "Error, mode/status not found"; + $statusType = 'status1'; + if ($status == 0 && $alreadypaid > 0) $statusType = 'status3'; + if ($status == 1) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index b6381ccc7ca..ee0794e4b16 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -107,7 +107,8 @@ abstract class CommonInvoice extends CommonObject } /** - * Return amount of payments already done + * Return amount of payments already done. This must include ONLY the record into the payment table. + * Payments dones using discounts, credit notes, etc are not included. * * @param int $multicurrency Return multicurrency_amount instead of amount * @return int Amount of payment already done, <0 if KO @@ -337,6 +338,51 @@ abstract class CommonInvoice extends CommonObject $i++; } $this->db->free($resql); + + //look for credit notes and discounts and deposits + $sql = ''; + if ($this->element == 'facture' || $this->element == 'invoice') + { + $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$this->id; + $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) + } + elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') + { + $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$this->id; + $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) + } + + if ($sql) { + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency) { + $retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref); + } + else { + $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref); + } + $i++; + } + } + else + { + $this->error = $this->db->lasterror(); + dol_print_error($this->db); + return array(); + } + $this->db->free($resql); + } + return $retarray; } else diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dfe8535b3bc..498fa314315 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7494,7 +7494,7 @@ abstract class CommonObject if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now); if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. - if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data + if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data $keys = array(); $values = array(); @@ -7729,6 +7729,7 @@ abstract class CommonObject if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now); if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. + if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data $keys = array(); $values = array(); diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index d89db86aa10..ca40910aacd 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -546,7 +546,7 @@ class DiscountAbsolute * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * * @param CommonInvoice $invoice Object invoice (customer of supplier) - * @param int $multicurrency Return multicurrency_amount instead of amount + * @param int $multicurrency 1=Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ public function getSumDepositsUsed($invoice, $multicurrency = 0) @@ -578,7 +578,7 @@ class DiscountAbsolute if ($resql) { $obj = $this->db->fetch_object($resql); - if ($multicurrency) return $obj->multicurrency_amount; + if ($multicurrency == 1) return $obj->multicurrency_amount; else return $obj->amount; } else @@ -592,7 +592,7 @@ class DiscountAbsolute * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment * * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency Return multicurrency_amount instead of amount + * @param int $multicurrency 1=Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and excess received amount otherwise */ public function getSumCreditNotesUsed($invoice, $multicurrency = 0) @@ -624,7 +624,7 @@ class DiscountAbsolute if ($resql) { $obj = $this->db->fetch_object($resql); - if ($multicurrency) return $obj->multicurrency_amount; + if ($multicurrency == 1) return $obj->multicurrency_amount; else return $obj->amount; } else diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 304a7a248a3..460dbe6e90c 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -109,8 +109,10 @@ class Interfaces $handle = opendir($newdir); if (is_resource($handle)) { + $fullpathfiles = array(); while (($file = readdir($handle)) !== false) { + $reg=array(); if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) { $part1 = $reg[1]; @@ -274,6 +276,7 @@ class Interfaces { while (($file = readdir($handle)) !== false) { + $reg = array(); if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) { if (preg_match('/\.back$/', $file)) continue; diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index e54de5a91d2..4f6d6750040 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -221,7 +221,7 @@ class Translate if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir { - dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); + dol_syslog("Error: ".get_class($this)."::load was called for domain=".$domain." but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); return -1; } @@ -428,7 +428,7 @@ class Translate if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir { - dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); + dol_syslog("Error: ".get_class($this)."::loadFromDatabase was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); return -1; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7d82336dd16..909d16d39e6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4677,6 +4677,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_sell dol_syslog("get_localtax tva=".$vatrate." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '')."/country_code=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj); $vatratecleaned = $vatrate; + $reg = array(); if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" { $vatratecleaned = trim($reg[1]); @@ -4921,13 +4922,14 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local); // Search local taxes - $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; + $sql = "SELECT t.taux as rate, t.code, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; if ($firstparamisid) $sql .= " WHERE t.rowid = ".(int) $vatrate; else { $vatratecleaned = $vatrate; $vatratecode = ''; + $reg = array(); if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "x.x (yy)" { $vatratecleaned = $reg[1]; @@ -4945,17 +4947,20 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi if ($resql) { $obj = $db->fetch_object($resql); + + $vateratestring = $obj->rate.($obj->code ? ' ('.$obj->code.')' : ''); + if ($local == 1) { - return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } elseif ($local == 2) { - return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); + return array($obj->localtax2_type, get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } else { - return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vateratestring, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vateratestring, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 994b71a416d..075ba0efb84 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1260,12 +1260,14 @@ class pdf_einstein extends ModelePDFCommandes { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 68fa5f179e7..6342cd6ce74 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1393,12 +1393,14 @@ class pdf_eratosthene extends ModelePDFCommandes { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index e7770981d09..4594a9d63cd 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * 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 @@ -162,7 +162,7 @@ class doc_generic_contract_odt extends ModelePDFContract $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; } - // Add select to upload a new template file. TODO Copy this feature on other admin pages. + // Add input to upload a new template file. $texte .= '
'.$langs->trans("UploadNewTemplate").' '; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index ae34fd3f8e1..64aa3c52e25 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -595,7 +595,7 @@ class pdf_crabe extends ModelePDFFactures { $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxprogress, $curY); - $pdf->MultiCell($this->postotalht - $this->posxprogress - 1, 3, $progress, 0, 'R'); + $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R'); } // Total HT line @@ -1618,12 +1618,14 @@ class pdf_crabe extends ModelePDFFactures { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index ecaa4ba14a0..3e00e2cab68 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1834,12 +1834,14 @@ class pdf_sponge extends ModelePDFFactures { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index 83752de24e7..83495ca1af6 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -99,7 +99,7 @@ class modCashDesk extends DolibarrModules 'type'=>'top', // This is a Top menu entry 'titre'=>'PointOfSaleShort', 'mainmenu'=>'cashdesk', - 'url'=>'/cashdesk/index.php?user=__LOGIN__', + 'url'=>'/cashdesk/index.php?user=__USER_LOGIN__', 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>900, 'enabled'=>'$conf->cashdesk->enabled', diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 4391c52d482..9219de5863c 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1467,12 +1467,14 @@ class pdf_azur extends ModelePDFPropales { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index b26b8831f32..1e67ac6485c 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1503,12 +1503,14 @@ class pdf_cyan extends ModelePDFPropales { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 61536e1d154..374e740ea40 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -356,35 +356,36 @@ if ($nolinesbefore) { "> - multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $coldisplay++; ?> "> - "> - "> global->PRODUCT_USE_UNITS) - { + if (! empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; print $form->selectUnits($line->fk_unit, "units"); print ''; } $remise_percent = $buyer->remise_percent; - if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') - { + if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') { $remise_percent = $seller->remise_supplier_percent; } $coldisplay++; @@ -397,8 +398,7 @@ if ($nolinesbefore) { $coldisplay++; print ''; } - if (!empty($usemargins)) - { + if (!empty($usemargins)) { if (!empty($user->rights->margins->creer)) { $coldisplay++; ?> @@ -434,208 +434,208 @@ if ($nolinesbefore) { if (is_object($objectline)) { print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); } + if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { - ?> - -> - global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> - - element) && $object->element == 'contrat') - { - print $langs->trans("DateStartPlanned").' '; - print $form->selectDate($date_start, "date_start", $usehm, $usehm, 1, "addproduct"); - print '   '.$langs->trans("DateEndPlanned").' '; - print $form->selectDate($date_end, "date_end", $usehm, $usehm, 1, "addproduct"); + print ''."\n"; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ''; } + print ''; + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + if (!empty($object->element) && $object->element == 'contrat') + { + print $langs->trans("DateStartPlanned").' '; + print $form->selectDate($date_start, "date_start", $usehm, $usehm, 1, "addproduct"); + print '   '.$langs->trans("DateEndPlanned").' '; + print $form->selectDate($date_end, "date_end", $usehm, $usehm, 1, "addproduct"); + } + else + { + print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); + print ' '.$langs->trans('to').' '; + print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); + }; + print ''; - print ''; - print "\n"; + if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) { + print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");'; + } + } + print ''; + print ''; + print ''."\n"; } - print " + +print ''; + +print "\n"; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index e72da40d6b0..26958aed875 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -954,8 +954,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } else { - $error ="Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors); - $this->error=$error; + $this->error="Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors); $this->errors=$actioncomm->errors; dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR); diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 16d5a3659a5..5744a29db48 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -118,9 +118,6 @@ class InterfaceStripe // Data and type of action are stored into $object and $action global $langs, $db, $conf; - // Load translation files required by the page - $langs->loadLangs(array("members","other","users","mails")); - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index dba7392a9e4..807804ed5fe 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1639,7 +1639,7 @@ class FactureFournisseur extends CommonInvoice $result = $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc if ($result > 0) { - $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + if (empty($pu)) $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice // is remise percent not keyed but present for the product we add it if ($remise_percent == 0 && $prod->remise_percent != 0) @@ -1691,6 +1691,7 @@ class FactureFournisseur extends CommonInvoice $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 957561466c7..4e6523ff6cb 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -361,7 +361,7 @@ if (empty($reshook)) else { $idprod = GETPOST('idprod', 'int'); - $price_ht = ''; + $price_ht = GETPOST('price_ht'); $tva_tx = ''; } @@ -420,15 +420,14 @@ if (empty($reshook)) } } - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - if (($prod_entry_mode != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { $productsupplier = new ProductFournisseur($db); $idprod = 0; if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + + $reg = array(); if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { $idprod = $reg[1]; @@ -470,7 +469,22 @@ if (empty($reshook)) if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if ($price_ht != '' || $price_ht_devise != '') { + $price_base_type = 'HT'; + $pu = price2num($price_ht, 'MU'); + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + } else { + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency + $pu = $productsupplier->fourn_pu; + $pu_ht_devise = 0; + } else { + $pu = $productsupplier->fourn_pu; + $pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice; + /*var_dump($pu); + var_dump($pu_ht_devise);exit;*/ + } + } $ref_supplier = $productsupplier->ref_supplier; @@ -480,7 +494,6 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - $pu = $productsupplier->fourn_pu; if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value $result = $object->addline( @@ -503,7 +516,9 @@ if (empty($reshook)) $date_end, $array_options, $productsupplier->fk_unit, - $productsupplier->fourn_multicurrency_unitprice + $pu_ht_devise, + '', + 0 ); } if ($idprod == -99 || $idprod == 0) @@ -2200,7 +2215,7 @@ elseif (!empty($object->id)) print ''; - if (!empty($conf->multicurrency->enabled)) + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { // Multicurrency Amount HT print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 9f08e944ee0..9872874a1d0 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -99,8 +99,11 @@ if (!empty($user->socid)) $socid = $user->socid; $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft); +$usercancreate = $user->rights->fournisseur->facture->creer; + $permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->fournisseur->facture->creer; // Used by the include of actions_lineupdown.inc.php $permissiontoadd = $user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php @@ -402,7 +405,7 @@ if (empty($reshook)) $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); } - elseif ($action == "setabsolutediscount" && $user->rights->fournisseur->facture->creer) + elseif ($action == "setabsolutediscount" && $usercancreate) { // POST[remise_id] or POST[remise_id_for_payment] @@ -460,7 +463,7 @@ if (empty($reshook)) } } // Convertir en reduc - elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) + elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); $object->fetch_thirdparty(); @@ -472,12 +475,13 @@ if (empty($reshook)) $canconvert = 0; if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not refunded completely and not already converted and amount of payment is 0 (see also the real condition used as the condition to show button converttoreduc) if ($canconvert) { $db->begin(); $amount_ht = $amount_tva = $amount_ttc = array(); + $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array(); // Loop on each vat rate $i = 0; @@ -492,6 +496,20 @@ if (empty($reshook)) } } + // If some payments were already done, we change the amount to pay using same prorate + if (! empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { + $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. + if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) { + $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc); + foreach($amount_ht as $vatrate => $val) { + $amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU'); + $amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU'); + $amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU'); + } + } + } + //var_dump($amount_ht);var_dump($amount_tva);var_dump($amount_ttc);exit; + // Insert one discount by VAT rate category $discount = new DiscountAbsolute($db); if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) @@ -513,6 +531,7 @@ if (empty($reshook)) { // If we're on a standard invoice, we have to get excess paid to create a discount in TTC without VAT + // Total payments $sql = 'SELECT SUM(pf.amount) as total_paiements'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.getEntity('c_paiement').')'; @@ -526,7 +545,20 @@ if (empty($reshook)) $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; - $discount->amount_ht = $discount->amount_ttc = $total_paiements - $object->total_ttc; + // Total credit note and deposit + $total_creditnote_and_deposit = 0; + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_invoice_supplier_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_invoice_supplier = ".$object->id; + $resql = $db->query($sql); + if (!empty($resql)) { + while ($obj = $db->fetch_object($resql)) { + $total_creditnote_and_deposit += $obj->amount_ttc; + } + } else dol_print_error($db); + + $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; @@ -600,7 +632,7 @@ if (empty($reshook)) } // Create - elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) + elseif ($action == 'add' && $usercancreate) { if ($socid > 0) $object->socid = GETPOST('socid', 'int'); @@ -632,7 +664,7 @@ if (empty($reshook)) if (!$error) { // This is a replacement invoice - $result = $object->fetch(GETPOST('fac_replacement'), 'int'); + $result = $object->fetch(GETPOST('fac_replacement', 'int')); $object->fetch_thirdparty(); $object->ref = GETPOST('ref', 'nohtml'); @@ -1143,7 +1175,7 @@ if (empty($reshook)) else { $idprod = GETPOST('idprod', 'int'); - $price_ht = ''; + $price_ht = GETPOST('price_ht'); $tva_tx = ''; } @@ -1209,6 +1241,7 @@ if (empty($reshook)) $idprod = 0; if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + $reg = array(); if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { $idprod = $reg[1]; @@ -1250,7 +1283,20 @@ if (empty($reshook)) if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if ($price_ht != '' || $price_ht_devise != '') { + $price_base_type = 'HT'; + $pu = price2num($price_ht, 'MU'); + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + } else { + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency + $pu = $productsupplier->fourn_pu; + $pu_ht_devise = 0; + } else { + $pu = $productsupplier->fourn_pu; + $pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice; + } + } $ref_supplier = $productsupplier->ref_supplier; @@ -1260,7 +1306,6 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - $pu = $productsupplier->fourn_pu; if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value $result = $object->addline( @@ -1283,8 +1328,9 @@ if (empty($reshook)) $array_options, $productsupplier->fk_unit, 0, - $productsupplier->fourn_multicurrency_unitprice, - $ref_supplier + $pu_ht_devise, + $ref_supplier, + '' ); } if ($idprod == -99 || $idprod == 0) @@ -3129,7 +3175,9 @@ else print ''; } // For credit note - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() == 0) { + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer + && (! empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) + ) { print ''; } // For deposit invoice diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 2ef48bc9f0b..4d29f03003e 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -180,7 +180,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ /*************************************************************************************** * - * Migration des donnees + * Migration of data * ***************************************************************************************/ $db->begin(); @@ -553,6 +553,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ print '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'
'; + + $sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'"; + $db->query($sql, 1); + + // We always commit. // Process is designed so we can run it several times whatever is situation. $db->commit(); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 902790cc23a..e6ea4390fd8 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -61,7 +61,7 @@ Payment=Payment PaymentBack=Payment back CustomerInvoicePaymentBack=Payment back Payments=Payments -PaymentsBack=Payments back +PaymentsBack=Refunds paymentInInvoiceCurrency=in invoices currency PaidBack=Paid back DeletePayment=Delete payment @@ -78,7 +78,7 @@ ReceivedCustomersPaymentsToValid=Received customers payments to validate PaymentsReportsForYear=Payments reports for %s PaymentsReports=Payments reports PaymentsAlreadyDone=Payments already done -PaymentsBackAlreadyDone=Payments back already done +PaymentsBackAlreadyDone=Refunds already done PaymentRule=Payment rule PaymentMode=Payment Type PaymentTypeDC=Debit/Credit Card diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index e33d1112deb..964bd7c436c 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -79,3 +79,5 @@ InvoiceIsAlreadyValidated=Invoice is already validated NoLinesToBill=No lines to bill CustomReceipt=Custom Receipt ReceiptName=Receipt Name +ProductSupplements=Product Supplements +SupplementCategory=Supplement category diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 79c4978b660..a565ecb59b8 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -251,9 +251,9 @@ ShowListTicketWithTrackId=Display ticket list from track ID ShowTicketWithTrackId=Display ticket from track ID TicketPublicDesc=You can create a support ticket or check from an existing ID. YourTicketSuccessfullySaved=Ticket has been successfully saved! -MesgInfosPublicTicketCreatedWithTrackId=A new ticket has been created with ID %s. +MesgInfosPublicTicketCreatedWithTrackId=A new ticket has been created with ID %s and Ref %s. PleaseRememberThisId=Please keep the tracking number that we might ask you later. -TicketNewEmailSubject=Ticket creation confirmation +TicketNewEmailSubject=Ticket creation confirmation - Ref %s TicketNewEmailSubjectCustomer=New support ticket TicketNewEmailBody=This is an automatic email to confirm you have registered a new ticket. TicketNewEmailBodyCustomer=This is an automatic email to confirm a new ticket has just been created into your account. @@ -272,7 +272,7 @@ Subject=Subject ViewTicket=View ticket ViewMyTicketList=View my ticket list ErrorEmailMustExistToCreateTicket=Error: email address not found in our database -TicketNewEmailSubjectAdmin=New ticket created +TicketNewEmailSubjectAdmin=New ticket created - Ref %s TicketNewEmailBodyAdmin=

Ticket has just been created with ID #%s, see information:

SeeThisTicketIntomanagementInterface=See ticket in management interface TicketPublicInterfaceForbidden=The public interface for the tickets was not enabled diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 427217bec10..6a724db9d87 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -105,6 +105,10 @@ class Loan extends CommonObject public $fk_project; + const STATUS_UNPAID = 0; + const STATUS_PAID = 1; + + /** * Constructor * @@ -425,47 +429,29 @@ class Loan extends CommonObject */ public function LibStatut($status, $mode = 0, $alreadypaid = -1) { - // phpcs:enable + // phpcs:enable global $langs; - $langs->loadLangs(array("customers", "bills")); - if ($mode == 0 || $mode == 1) + // Load translation files required by the page + $langs->loadLangs(array("customers","bills")); + + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - if ($status == 0) return $langs->trans("Unpaid"); - elseif ($status == 1) return $langs->trans("Paid"); - } - elseif ($mode == 2) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - elseif ($mode == 3) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6'); - } - elseif ($mode == 4) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - elseif ($mode == 5) - { - if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); - } - elseif ($mode == 6) - { - if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); + $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); + if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); + if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); } - else return "Error, mode/status not found"; + $statusType = 'status1'; + if ($status == 0 && $alreadypaid > 0) $statusType = 'status3'; + if ($status == 1) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index a8192155b63..d1a01cd11b1 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -49,7 +49,8 @@ if (!$sortorder) $sortorder = "DESC"; $search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); -$filtre = GETPOST("filtre"); + +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search $optioncss = GETPOST('optioncss', 'alpha'); // Purge search criteria @@ -77,10 +78,6 @@ $sql .= " WHERE l.entity = ".$conf->entity; if ($search_amount) $sql .= natural_search("l.capital", $search_amount, 1); if ($search_ref) $sql .= " AND l.rowid = ".$db->escape($search_ref); if ($search_label) $sql .= natural_search("l.label", $search_label); -if ($filtre) { - $filtre = str_replace(":", "=", $filtre); - $sql .= " AND ".$filtre; -} $sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend"; $sql .= $db->order($sortfield, $sortorder); @@ -108,10 +105,10 @@ if ($resql) $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_label) $param.="&search_label=".urlencode($search_user); - if ($search_amount) $param.="&search_amount=".urlencode($search_amount_ht); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_ref) $param.="&search_ref=".urlencode($search_ref); + if ($search_label) $param.="&search_label=".urlencode($search_label); + if ($search_amount) $param.="&search_amount=".urlencode($search_amount); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); $newcardbutton=''; if ($user->rights->loan->write) @@ -130,6 +127,8 @@ if ($resql) print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit); + $moreforfilter = ''; + print '
'; print ''."\n"; @@ -157,7 +156,7 @@ if ($resql) print_liste_field_titre(''); print "\n"; - while ($i < min($num, $limit)) + while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); $loan_static->id = $obj->rowid; @@ -190,6 +189,14 @@ if ($resql) $i++; } + // If no record found + if ($num == 0) + { + $colspan = 7; + //foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''; + } + print "
'.$langs->trans("NoRecordFound").'
"; print '
'; print "\n"; diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index 4410e598204..a951b9c9b0f 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -48,17 +48,17 @@ $linkback = ''; // Ref loan -$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); -$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); +$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); +$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); - $morehtmlref .= '
'.$langs->trans('Project').' '; + $morehtmlref .= '
'.$langs->trans('Project').' : '; if ($user->rights->loan->write) { if ($action != 'classify') - $morehtmlref .= '
'.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + //$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= '
'; @@ -83,6 +83,9 @@ if (!empty($conf->projet->enabled)) } } $morehtmlref .= '
'; + +$morehtmlright = ''; + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); if ($action == 'createecheancier') { @@ -140,8 +143,6 @@ if ($action == 'updateecheancier') { $echeance = new LoanSchedule($db); $echeance->fetchAll($object->id); -$var = !$var; - ?>