From 9436b1d046c1d67d62f232963743d2120100f83c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 09:26:40 +0200 Subject: [PATCH 01/27] New: Prepare to be able to defined a bcc for each type of email sent from dolibarr. --- htdocs/core/actions_sendmails.inc.php | 10 ++++++++-- htdocs/societe/soc.php | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 3af164abfab..337cf59c9b0 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -26,7 +26,8 @@ // $id must be defined // $actiontypecode must be defined - +// $paramname must be defined +// $mode must be defined /* * Add file in email form @@ -115,6 +116,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; $message = $_POST['message']; $sendtocc = $_POST['sendtocc']; + $sendtobcc=''; + if ($mode == 'emailfromproposal') $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO); + if ($mode == 'emailfromorder') $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO); + if ($mode == 'emailfrominvoice') $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO); + $deliveryreceipt = $_POST['deliveryreceipt']; if ($action == 'send' || $action == 'relance') @@ -141,7 +147,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Send mail require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1); if ($mailfile->error) { $mesgs[]='
'.$mailfile->error.'
'; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 7ca032cf422..d1bdfa898d4 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -513,6 +513,7 @@ if (empty($reshook)) $id=$socid; $actiontypecode='AC_OTH_AUTO'; $paramname='socid'; + $mode='emailfromthirdparty'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; From 20d6920a0cbfd57bac67eda377208234fe6fb697 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 09:27:40 +0200 Subject: [PATCH 02/27] Add comment --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c16af4c5b24..a289b43c4a9 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -170,7 +170,7 @@ class CMailFile } } - // Add autocopy to + // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO; // Action according to choosed sending method From 17aed0f360b9499a19990d83819f63282cfdbb44 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 09:28:07 +0200 Subject: [PATCH 03/27] Prepare to be able to send bcc according to email type. --- htdocs/langs/en_US/admin.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 00a5a2dc3b4..1176a3ab7e9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -257,6 +257,9 @@ MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=SMTP/SMTPS Host (Not defined into MAIN_MAIL_EMAIL_FROM=Sender e-mail for automatic emails (By default in php.ini: %s) MAIN_MAIL_ERRORS_TO=Sender e-mail used for error returns emails sent MAIN_MAIL_AUTOCOPY_TO= Send systematically a hidden carbon-copy of all sent emails to +MAIN_MAIL_AUTOCOPY_PROPOSAL_TO= Send systematically a hidden carbon-copy of proposals sent by email to +MAIN_MAIL_AUTOCOPY_ORDER_TO= Send systematically a hidden carbon-copy of orders sent by email to +MAIN_MAIL_AUTOCOPY_INVOICE_TO= Send systematically a hidden carbon-copy of invoice sent by emails to MAIN_DISABLE_ALL_MAILS=Disable all e-mails sendings (for test purposes or demos) MAIN_MAIL_SENDMODE=Method to use to send EMails MAIN_MAIL_SMTPS_ID=SMTP ID if authentication required From 164c9e0b750c129608c9a07ed6c9fdf89d5fa527 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 09:28:58 +0200 Subject: [PATCH 04/27] New: Can defined a bcc for each email type. --- htdocs/comm/propal.php | 3 ++- htdocs/commande/fiche.php | 7 ++++--- htdocs/compta/facture.php | 7 ++++--- htdocs/compta/facture/impayees.php | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 486ca39c18e..b1747ca066d 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -565,6 +565,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $replyto = $_POST ['replytoname'] . ' <' . $_POST ['replytomail'] . '>'; $message = $_POST ['message']; $sendtocc = $_POST ['sendtocc']; + $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO); $deliveryreceipt = $_POST ['deliveryreceipt']; if (dol_strlen($_POST ['subject'])) @@ -591,7 +592,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G // Envoi de la propal require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, - 1); if ($mailfile->error) { setEventMessage($mailfile->error, 'errors'); } else { diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index a82eb5dda05..05429abbd7e 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -617,7 +617,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { } } } - + // if price ht is forced (ie: calculated by margin rate and cost price) if (! empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); @@ -1192,6 +1192,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>'; $message = GETPOST('message'); $sendtocc = GETPOST('sendtocc'); + $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO); $deliveryreceipt = GETPOST('deliveryreceipt'); if ($action == 'send') { @@ -1220,7 +1221,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G // Send mail require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, - 1); if ($mailfile->error) { setEventMessage($mailfile->error, 'errors'); } else { @@ -2434,7 +2435,7 @@ if ($action == 'create' && $user->rights->commande->creer) { include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/')); $file = $fileparams ['fullname']; - + // Define output language $outputlangs = $langs; $newlang = ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 056d5168234..989f7f46abd 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1152,7 +1152,7 @@ else if ($action == 'addline' && $user->rights->facture->creer) $pu_ttc = $prod->price_ttc; $price_min = $prod->price_min; $price_base_type = $prod->price_base_type; - + // We define price for product if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) { @@ -1181,7 +1181,7 @@ else if ($action == 'addline' && $user->rights->facture->creer) } } } - + // if price ht is forced (ie: calculated by margin rate and cost price) if (! empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); @@ -1559,6 +1559,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $replyto = $_POST['replytoname'] . ' <' . $_POST['replytomail'] . '>'; $message = $_POST['message']; $sendtocc = $_POST['sendtocc']; + $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO); $deliveryreceipt = $_POST['deliveryreceipt']; if ($action == 'send') { @@ -1601,7 +1602,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Send mail require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, - 1); if ($mailfile->error) { setEventMessage($mailfile->error, 'errors'); } else { diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index b3d95870838..99f3a0ba082 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -121,6 +121,7 @@ if ($action == 'presend' && GETPOST('sendmail')) $subject = GETPOST('subject'); $message = GETPOST('message'); $sendtocc = GETPOST('sentocc'); + $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO); $substitutionarray=array( '__ID__' => $object->id, @@ -151,7 +152,7 @@ if ($action == 'presend' && GETPOST('sendmail')) // Send mail require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'); - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1); if ($mailfile->error) { $resultmasssend.='
'.$mailfile->error.'
'; From f863604621112a217938d6df84ce2f45093c2e58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 12:28:10 +0200 Subject: [PATCH 05/27] Prepare table for email templates. --- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 17 ++++++++--------- .../mysql/tables/llx_c_email_template.sql | 15 +++++++-------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 97186c9ae75..e8a62f9d05d 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -925,21 +925,20 @@ DROP TABLE llx_texts; DROP TABLE llx_c_email_templates; -CREATE table llx_c_email_templates +create table llx_c_email_templates ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id - module varchar(32), -- Nom du module en rapport avec le modele + module varchar(32), -- Nom du module en rapport avec le modele type_template varchar(32), -- template for which type of email (send invoice by email, send order, ...) - sortorder smallint, -- Ordre affichage - - private smallint DEFAULT 0 NOT NULL, -- Template public or private - fk_user integer, -- Id utilisateur si modele prive, sinon null + private smallint DEFAULT 0 NOT NULL, -- Template public or private + fk_user integer, -- Id utilisateur si modele prive, sinon null datec datetime, tms timestamp, - - label varchar(255), - content text + label varchar(255), -- Label of predefined email + position smallint, -- Position + topic text, -- Predefined topic + content text -- Predefined text )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_email_template.sql b/htdocs/install/mysql/tables/llx_c_email_template.sql index 9390f934bc3..875314bf4c8 100644 --- a/htdocs/install/mysql/tables/llx_c_email_template.sql +++ b/htdocs/install/mysql/tables/llx_c_email_template.sql @@ -21,15 +21,14 @@ create table llx_c_email_templates ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id - module varchar(32), -- Nom du module en rapport avec le modele + module varchar(32), -- Nom du module en rapport avec le modele type_template varchar(32), -- template for which type of email (send invoice by email, send order, ...) - sortorder smallint, -- Ordre affichage - - private smallint DEFAULT 0 NOT NULL, -- Template public or private - fk_user integer, -- Id utilisateur si modele prive, sinon null + private smallint DEFAULT 0 NOT NULL, -- Template public or private + fk_user integer, -- Id utilisateur si modele prive, sinon null datec datetime, tms timestamp, - - label varchar(255), - content text + label varchar(255), -- Label of predefined email + position smallint, -- Position + topic text, -- Predefined topic + content text -- Predefined text )ENGINE=innodb; From ee3f92a1686868b38eb52bcba518eeea842e3869 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 18:22:01 +0200 Subject: [PATCH 06/27] Fix: When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. --- htdocs/societe/soc.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b88642cd83d..0e4d7932856 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1069,12 +1069,11 @@ else $res=$object->fetch_optionals($object->id,$extralabels); //if ($res < 0) { dol_print_error($db); exit; } - $head = societe_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company'); - + // Load object modCodeTiers $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') @@ -1110,7 +1109,9 @@ else { $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); } - + + $object->oldcopy=dol_clone($object); + if (GETPOST('nom')) { // We overwrite with values if posted @@ -1142,7 +1143,7 @@ else $object->barcode = GETPOST('barcode'); $object->forme_juridique_code = GETPOST('forme_juridique_code'); $object->default_lang = GETPOST('default_lang'); - + $object->tva_assuj = GETPOST('assujtva_value'); $object->tva_intra = GETPOST('tva_intra'); $object->status = GETPOST('status'); @@ -1179,7 +1180,7 @@ else print ''; print ''; if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; - + print ''; // Name @@ -1247,6 +1248,7 @@ else if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) { $tmpcode=$object->code_fournisseur; + if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) $tmpcode=$object->oldcopy->code_fournisseur; if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1); print ''; } From 5027222c339a13bb802685fd4f7c834ea408de7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 18:28:06 +0200 Subject: [PATCH 07/27] Fix: When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. --- htdocs/societe/soc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 0e4d7932856..3c916fd2b29 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1216,6 +1216,7 @@ else if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) { $tmpcode=$object->code_client; + if (empty($tmpcode) && ! empty($object->oldcopy->code_client)) $tmpcode=$object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0); print ''; } @@ -1248,7 +1249,7 @@ else if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) { $tmpcode=$object->code_fournisseur; - if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) $tmpcode=$object->oldcopy->code_fournisseur; + if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) $tmpcode=$object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1); print ''; } From e95a9cad03bb5a11c5f80ad629cb888db687e1e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 19:32:24 +0200 Subject: [PATCH 08/27] New: When force of bcc is set, we show it onto email form. --- htdocs/core/class/html.formmail.class.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 7d5f1a3bf2e..69880f8fd29 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -439,7 +439,7 @@ class FormMail } $out.= "\n"; } - + // CCC if (! empty($this->withtoccc) || is_array($this->withtoccc)) { @@ -459,7 +459,12 @@ class FormMail $out.= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1); } } - //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); + + $showinfobcc=''; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'commande_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; + if ($showinfobcc) $out.=' + '.$showinfobcc; $out.= "\n"; } @@ -475,9 +480,9 @@ class FormMail else { $defaultvaluefordeliveryreceipt=0; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt=1; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'commande_send') $defaultvaluefordeliveryreceipt=1; if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt=1; + if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'commande_send') $defaultvaluefordeliveryreceipt=1; + if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt=1; $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:$defaultvaluefordeliveryreceipt), 1); } From 2624632fdea270c3fed5c6926033e6d614ef741c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 19:55:14 +0200 Subject: [PATCH 09/27] Fix: bad test commande_send -> order_send --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 69880f8fd29..261754801a9 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -462,7 +462,7 @@ class FormMail $showinfobcc=''; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'commande_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; if ($showinfobcc) $out.=' + '.$showinfobcc; $out.= "\n"; @@ -481,7 +481,7 @@ class FormMail { $defaultvaluefordeliveryreceipt=0; if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt=1; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'commande_send') $defaultvaluefordeliveryreceipt=1; + if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt=1; if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt=1; $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:$defaultvaluefordeliveryreceipt), 1); } From 0397fa7dc356e98597b0644b2d17ba03f562e123 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 21:18:36 +0200 Subject: [PATCH 10/27] Fix: mb_strtolower function does not exists on all PHP versions. --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1641aeb132c..cdf05a2c29d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -838,7 +838,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass } // Show page nb only on iso languages (so default Helvetica font) - if (mb_strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') + if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { $pdf->SetXY(-20,-$posy); //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; From f33df3419c158cc24541ebb739e7b304a69df539 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 21:18:36 +0200 Subject: [PATCH 11/27] Fix: mb_strtolower function does not exists on all PHP versions. --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a9eb6c0d6e6..f2add422714 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -838,7 +838,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass } // Show page nb only on iso languages (so default Helvetica font) - if (mb_strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') + if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { $pdf->SetXY(-20,-$posy); //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; From 0514fa02d5953c9c761dd1088934b1912c8f8ba9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 00:06:27 +0200 Subject: [PATCH 12/27] Clean path dolibarr_main_url_root to avoid duplicate /. --- htdocs/conf/conf.php.example | 4 ++-- htdocs/filefunc.inc.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 990a10c2500..32adc4b87c9 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -12,8 +12,8 @@ //################### // dolibarr_main_url_root -// This parameter defines the root URL of your Dolibarr index.php page. -// It must link to the htdocs directory htdocs. +// This parameter defines the root URL of your Dolibarr index.php page without ending "/". +// It must link to the directory htdocs. // In most cases, this is autodetected but it's still required // * to show full url bookmarks for some services (ie: agenda rss export url, ...) // * or when using Apache dir aliases (autodetect fails) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index c30388050cf..6f8a2bb9b2c 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -92,7 +92,7 @@ if (! empty($dolibarr_main_prod)) ini_set('display_errors','Off'); // Clean parameters $dolibarr_main_data_root=trim($dolibarr_main_data_root); -$dolibarr_main_url_root=trim($dolibarr_main_url_root); +$dolibarr_main_url_root=trim(preg_replace('/\/+$/','',$dolibarr_main_url_root)); $dolibarr_main_url_root_alt=(empty($dolibarr_main_url_root_alt)?'':trim($dolibarr_main_url_root_alt)); $dolibarr_main_document_root=trim($dolibarr_main_document_root); $dolibarr_main_document_root_alt=(empty($dolibarr_main_document_root_alt)?'':trim($dolibarr_main_document_root_alt)); From b182b2ff44e9d5957034ef06067df2f2b978330d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 00:11:42 +0200 Subject: [PATCH 13/27] Update changelog --- ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0f260470db4..58bfffebd2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,15 @@ English Dolibarr ChangeLog Fix: [ bug #1523 ] suite bug #1334 : filtre et ordre de tri conjoints ne s'appliquent pas. Fix: Fusion PDF button on unpaid invoice is no more displayed Fix: Unpaid invoice launch fusion PDF action even if it is only search (with enter keyboard input instead of lens click) +Fix: Pb when showing log list of holiday module with some mysql versions. +Fix: Error with bad timezone pushed by some browsers. +Fix: shipping list SQL request was not filtering on shipping element +Fix: debian package provided by dolibarr team must use embedded libraries. +Fix: [ bug #1528 ] Leopard Services numeration module description is not translated. +Fix: [ bug #1523 ] suite bug #1334 : filtre et ordre de tri conjoints ne s'appliquent pas +Fix: [ bug #1534 ] Unknown error when deleting a product photo under special circumstances +Fix: Update impayees.php +Fix: Fix Link product, In list view and label product ***** ChangeLog for 3.5.4 compared to 3.5.3 ***** Fix: Hide title of event when agenda module disabled. From 1751b58ef8ab1dd0876dfed16851effd2fb3023e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 00:46:00 +0200 Subject: [PATCH 14/27] New: Can add __PROJECT_REF__ and __TIHRPARTY_NAME__ into email topic or content template. --- ChangeLog | 1 + htdocs/comm/propal.php | 8 ++++++-- htdocs/commande/fiche.php | 8 ++++++-- htdocs/compta/facture.php | 15 +++++++++++---- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 136d94828bc..aba40b26e58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,7 @@ For users: Differentiate text and img. Use label into quick search form. Use accesskey on form search. +- New: Can add __PROJECT_REF__ and __TIHRPARTY_NAME__ into email topic or content template. - Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action - Fix: [ bug #1470, #1472, #1473] User trigger problem - Fix: [ bug #1489, #1491 ] Intervention trigger problem diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b1747ca066d..35ab381a35f 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -2289,6 +2289,8 @@ if ($action == 'create') { */ if ($action == 'presend') { + $object->fetch_projet(); + $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/')); @@ -2341,7 +2343,7 @@ if ($action == 'create') { if (empty($object->ref_client)) { $formmail->withtopic = $outputlangs->trans('SendPropalRef', '__PROPREF__'); } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendPropalRef', '__PROPREF__(__REFCLIENT__)'); + $formmail->withtopic = $outputlangs->trans('SendPropalRef', '__PROPREF__ (__REFCLIENT__)'); } $formmail->withfile = 2; $formmail->withbody = 1; @@ -2352,6 +2354,8 @@ if ($action == 'create') { $formmail->substit ['__PROPREF__'] = $object->ref; $formmail->substit ['__SIGNATURE__'] = $user->signature; $formmail->substit ['__REFCLIENT__'] = $object->ref_client; + $formmail->substit ['__THIRPARTY_NAME__'] = $object->thirdparty->name; + $formmail->substit ['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); $formmail->substit ['__PERSONALIZED__'] = ''; $formmail->substit ['__CONTACTCIVNAME__'] = ''; @@ -2362,7 +2366,7 @@ if ($action == 'create') { if (is_array($contactarr) && count($contactarr) > 0) { foreach ($contactarr as $contact) { - if ($contact ['libelle'] == $langs->trans('TypeContact_propal_external_CUSTOMER')) { + if ($contact ['libelle'] == $langs->trans('TypeContact_propal_external_CUSTOMER')) { // TODO Use code and not label $contactstatic = new Contact($db); $contactstatic->fetch($contact ['id']); $custcontact = $contactstatic->getFullName($langs, 1); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 05429abbd7e..1d59311404e 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2431,6 +2431,8 @@ if ($action == 'create' && $user->rights->commande->creer) { */ if ($action == 'presend') { + $object->fetch_projet(); + $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/')); @@ -2483,7 +2485,7 @@ if ($action == 'create' && $user->rights->commande->creer) { if (empty($object->ref_client)) { $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__(__REFCLIENT__)'); + $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); } $formmail->withfile = 2; $formmail->withbody = 1; @@ -2493,6 +2495,8 @@ if ($action == 'create' && $user->rights->commande->creer) { $formmail->substit ['__ORDERREF__'] = $object->ref; $formmail->substit ['__SIGNATURE__'] = $user->signature; $formmail->substit ['__REFCLIENT__'] = $object->ref_client; + $formmail->substit ['__THIRPARTY_NAME__'] = $object->thirdparty->name; + $formmail->substit ['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); $formmail->substit ['__PERSONALIZED__'] = ''; $formmail->substit ['__CONTACTCIVNAME__'] = ''; @@ -2502,7 +2506,7 @@ if ($action == 'create' && $user->rights->commande->creer) { if (is_array($contactarr) && count($contactarr) > 0) { foreach ($contactarr as $contact) { - if ($contact ['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { + if ($contact ['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { // TODO Use code and not label $contactstatic = new Contact($db); $contactstatic->fetch($contact ['id']); $custcontact = $contactstatic->getFullName($langs, 1); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 989f7f46abd..de636bf5bdb 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3638,11 +3638,15 @@ if ($action == 'create') $somethingshown = $formactions->showactions($object, 'invoice', $socid); print ''; - } else { + } + else + { /* - * Affiche formulaire mail + * Action presend (or prerelance) */ + $object->fetch_projet(); + // By default if $action=='presend' $titreform = 'SendBillByMail'; $topicmail = 'SendBillRef'; @@ -3710,8 +3714,9 @@ if ($action == 'create') if (empty($object->ref_client)) { $formmail->withtopic = $outputlangs->transnoentities($topicmail, '__FACREF__'); } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->transnoentities($topicmail, '__FACREF__(__REFCLIENT__)'); + $formmail->withtopic = $outputlangs->transnoentities($topicmail, '__FACREF__ (__REFCLIENT__)'); } + $formmail->withfile = 2; $formmail->withbody = 1; $formmail->withdeliveryreceipt = 1; @@ -3720,6 +3725,8 @@ if ($action == 'create') $formmail->substit ['__FACREF__'] = $object->ref; $formmail->substit ['__SIGNATURE__'] = $user->signature; $formmail->substit ['__REFCLIENT__'] = $object->ref_client; + $formmail->substit ['__THIRPARTY_NAME__'] = $object->thirdparty->name; + $formmail->substit ['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); $formmail->substit ['__PERSONALIZED__'] = ''; $formmail->substit ['__CONTACTCIVNAME__'] = ''; @@ -3730,7 +3737,7 @@ if ($action == 'create') if (is_array($contactarr) && count($contactarr) > 0) { foreach ($contactarr as $contact) { - if ($contact ['libelle'] == $langs->trans('TypeContact_facture_external_BILLING')) { + if ($contact ['libelle'] == $langs->trans('TypeContact_facture_external_BILLING')) { // TODO Use code and not label require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; From 273b9029b8b48acdce0cec15ed502bd56a43af8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 01:45:31 +0200 Subject: [PATCH 15/27] Fix: mb_strtolower function does not exists on all PHP versions. Conflicts: htdocs/core/lib/pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1f9bcc20cd7..40248cd6596 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -835,7 +835,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass } // Show page nb only on iso languages (so default Helvetica font) - if (pdf_getPDFFont($outputlangs) == 'Helvetica') + if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { $pdf->SetXY(-20,-$posy); //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; From 168f71ac18466a75d871c0a0e81043c3ae8a0ca3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Aug 2014 17:45:41 +0200 Subject: [PATCH 16/27] Fix: Log of leaves was broken on some mysql versions. --- htdocs/holiday/class/holiday.class.php | 8 ++++---- htdocs/holiday/define_holiday.php | 2 +- htdocs/holiday/view_log.php | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 024ab5c30a9..05fef5dd47a 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -886,7 +886,7 @@ class Holiday extends CommonObject $month = date('m',$now); $lastUpdate = $this->getConfCP('lastUpdate'); $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; - //print 'month: '.$month.' '.$lastUpdate.' '.$monthLastUpdate; + //print 'month: '.$month.' '.$lastUpdate.' '.$monthLastUpdate;exit; // Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp if ($month != $monthLastUpdate) @@ -1618,7 +1618,7 @@ class Holiday extends CommonObject $sql.= ")"; $this->db->begin(); - +print $sql;exit; dol_syslog(get_class($this)."::addLogCP sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { @@ -1674,12 +1674,12 @@ class Holiday extends CommonObject // Filtrage de séléction if(!empty($filter)) { - $sql.= $filter; + $sql.= " ".$filter; } // Ordre d'affichage if(!empty($order)) { - $sql.= $order; + $sql.= " ".$order; } dol_syslog(get_class($this)."::fetchLog sql=".$sql, LOG_DEBUG); diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index f167422f503..1bf8a2716cc 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -71,7 +71,7 @@ if ($action == 'update' && isset($_POST['update_cp'])) $comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : ''); // We add the modification to the log - $holiday->addLogCP($user->id,$userID, $langs->trans('ManualUpdate').$comment,$userValue); + $holiday->addLogCP($user->id,$userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment,$userValue); // Update of the days of the employee $holiday->updateSoldeCP($userID,$userValue); diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index bdd855c7bad..e0a66e76dc3 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2014 Laurent Destailleur * Copyright (C) 2011 Dimitri Mouillard * * This program is free software; you can redistribute it and/or modify @@ -37,7 +37,7 @@ if(!$user->rights->holiday->view_log) accessforbidden(); /* * View -*/ + */ $langs->load('users'); @@ -45,7 +45,7 @@ llxHeader(array(),$langs->trans('CPTitreMenu')); $cp = new Holiday($db); -//Recent changes are more important than old changes +// Recent changes are more important than old changes $log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC',''); print_fiche_titre($langs->trans('LogCP')); From 9b9e51d50fb764a7031c0b07c8942c675e79c9a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 01:48:51 +0200 Subject: [PATCH 17/27] Fix: removed debug --- htdocs/holiday/class/holiday.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 989a1aa6355..9067a9996e6 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1626,7 +1626,7 @@ class Holiday extends CommonObject $sql.= ")"; $this->db->begin(); -print $sql;exit; + dol_syslog(get_class($this)."::addLogCP sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { From 8f73c7a82a41d4ac8afa7a448336d7929833ec4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 01:49:22 +0200 Subject: [PATCH 18/27] Fix: Remove debug --- htdocs/holiday/class/holiday.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 05fef5dd47a..f8a837e879f 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1618,7 +1618,7 @@ class Holiday extends CommonObject $sql.= ")"; $this->db->begin(); -print $sql;exit; + dol_syslog(get_class($this)."::addLogCP sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { From 83564b2b049863a0c33acf0b1a472529178bd839 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 02:43:50 +0200 Subject: [PATCH 19/27] Fix: Table holiday_user was not initialized anymore. --- htdocs/holiday/class/holiday.class.php | 61 ++++++++++++++++---------- htdocs/holiday/define_holiday.php | 7 ++- htdocs/holiday/fiche.php | 3 +- 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 553555c47ab..fdc43fe8106 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -79,7 +79,7 @@ class Holiday extends CommonObject /** - * updateSold + * updateSold. Update sold and check table of users for holidays is complete. If not complete. * * @return int Return 1 */ @@ -986,25 +986,31 @@ class Holiday extends CommonObject */ function createCPusers($single=false,$userid='') { - // Si c'est l'ensemble des utilisateurs à ajoutés - if(!$single) + // Si c'est l'ensemble des utilisateurs à ajouter + if (! $single) { dol_syslog(get_class($this).'::createCPusers'); - foreach($this->fetchUsers(false,true) as $users) { + $arrayofusers = $this->fetchUsers(false,true); + + foreach($arrayofusers as $users) + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; $sql.= " (fk_user, nb_holiday)"; $sql.= " VALUES ('".$users['rowid']."','0')"; - $this->db->query($sql); + $resql=$this->db->query($sql); + if (! $resql) dol_print_error($this->db); } - } else { + } + else + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; $sql.= " (fk_user, nb_holiday)"; $sql.= " VALUES ('".$userid."','0')"; - $this->db->query($sql); + $resql=$this->db->query($sql); + if (! $resql) dol_print_error($this->db); } - } /** @@ -1051,7 +1057,7 @@ class Holiday extends CommonObject * uniquement pour vérifier si il existe de nouveau utilisateur * * @param boolean $liste si vrai retourne une liste, si faux retourne un array - * @param boolean $type si vrai retourne pour Dolibarr si faux retourne pour CP + * @param boolean $type si vrai retourne pour Dolibarr, si faux retourne pour CP * @return string retourne un tableau de tout les utilisateurs actifs */ function fetchUsers($liste=true,$type=true) @@ -1262,49 +1268,55 @@ class Holiday extends CommonObject function verifNbUsers($userDolibarrWithoutCP,$userCP) { if (empty($userCP)) $userCP=0; - dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarr.' userCP='.$userCP); + dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); // On vérifie les users Dolibarr sans CP if ($userDolibarrWithoutCP > 0) { - $this->updateConfCP('nbUser',$userDolibarr); + $this->db->begin(); + + $this->updateConfCP('nbUser',$userDolibarrWithoutCP); $listUsersCP = $this->fetchUsers(true,false); // On séléctionne les utilisateurs qui ne sont pas déjà dans le module $sql = "SELECT u.rowid, u.lastname, u.firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.rowid NOT IN(".$listUsersCP.")"; - - $result = $this->db->query($sql); - - // Si pas d'erreur SQL - if($result) { + if ($listUsersCP != '') $sql.= " WHERE u.rowid NOT IN(".$listUsersCP.")"; + $resql = $this->db->query($sql); + if ($resql) + { $i = 0; $num = $this->db->num_rows($resql); - while($i < $num) { - + while($i < $num) + { $obj = $this->db->fetch_object($resql); + $uid = $obj->rowid; // On ajoute l'utilisateur - $this->createCPusers(true,$obj->rowid); + //print "Add user rowid = ".$uid." into database holiday"; + + $result = $this->createCPusers(true,$uid); $i++; } - + $this->db->commit(); } else { // Erreur SQL $this->error="Error ".$this->db->lasterror(); + $this->db->rollback(); return -1; } } else { - // Si il y a moins d'utilisateur Dolibarr que dans le module CP + $this->db->begin(); - $this->updateConfCP('nbUser',$userDolibarr); + // Si il y a moins d'utilisateur Dolibarr que dans le module CP + + $this->updateConfCP('nbUser',$userDolibarrWithoutCP); $listUsersDolibarr = $this->fetchUsers(true,true); @@ -1331,10 +1343,11 @@ class Holiday extends CommonObject $i++; } - + $this->db->commit(); } else { // Erreur SQL $this->error="Error ".$this->db->lasterror(); + $this->db->rollback(); return -1; } } diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 3c5fda7afd9..62e8fc698c9 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -43,14 +43,17 @@ $action=GETPOST('action'); */ $form = new Form($db); +$userstatic=new User($db); +$holiday = new Holiday($db); + llxHeader(array(),$langs->trans('CPTitreMenu')); print_fiche_titre($langs->trans('MenuConfCP')); -$holiday = new Holiday($db); +$holiday->updateSold(); // Create users into table holiday if they don't exists. TODO Remove if we use field into table user. + $listUsers = $holiday->fetchUsers(false,false); -$userstatic=new User($db); // Si il y a une action de mise à jour if ($action == 'update' && isset($_POST['update_cp'])) diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php index 0092a6e25c9..9fc3e278ac5 100644 --- a/htdocs/holiday/fiche.php +++ b/htdocs/holiday/fiche.php @@ -761,8 +761,9 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; } else print $form->select_users(GETPOST('userid')?GETPOST('userid'):$user->id,'userid',0,'',0); + //var_dump($cp->getConfCP('nbHolidayDeducted')); $nb_holiday = $cp->getCPforUser($user->id) / $cp->getConfCP('nbHolidayDeducted'); - print '   '.$langs->trans('SoldeCPUser', round($nb_holiday,0)).''; + print '   '.$langs->trans('SoldeCPUser', round($nb_holiday,2)).''; print ''; print ''; print ''; From 2bfde7ba309be2ff356b0ee1fd894bfe19f4aab7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 03:01:17 +0200 Subject: [PATCH 20/27] Add table llx_holiday_types to store type of leave. --- htdocs/holiday/admin/tomergewithholiday.php | 226 ++++++++++++++++++ htdocs/holiday/img/add.png | Bin 0 -> 3208 bytes htdocs/holiday/img/delete.png | Bin 0 -> 3350 bytes htdocs/holiday/img/edit.png | Bin 0 -> 3307 bytes .../install/mysql/migration/3.6.0-3.7.0.sql | 14 ++ .../mysql/tables/llx_holiday_types.sql | 30 +++ htdocs/theme/eldy/style.css.php | 35 +++ 7 files changed, 305 insertions(+) create mode 100755 htdocs/holiday/admin/tomergewithholiday.php create mode 100755 htdocs/holiday/img/add.png create mode 100755 htdocs/holiday/img/delete.png create mode 100755 htdocs/holiday/img/edit.png create mode 100755 htdocs/install/mysql/tables/llx_holiday_types.sql diff --git a/htdocs/holiday/admin/tomergewithholiday.php b/htdocs/holiday/admin/tomergewithholiday.php new file mode 100755 index 00000000000..7ff795a455b --- /dev/null +++ b/htdocs/holiday/admin/tomergewithholiday.php @@ -0,0 +1,226 @@ + + * Copyright (C) 2011 Dimitri Mouillard + * Copyright (C) 2012 Regis Houssin + * + * 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 . + */ + +/** + * Page module configuration paid holiday. + * + * \file holiday.php + * \ingroup holiday + * \brief Page module configuration paid holiday. + */ + +require '../../main.inc.php'; +require DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +require_once DOL_DOCUMENT_ROOT. '/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT. '/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT. '/user/class/usergroup.class.php'; + +// Si pas administrateur +if (! $user->admin) accessforbidden(); + + +/* + * View + */ + +// Vérification si module activé +if (empty($conf->holiday->enabled)) print $langs->trans('NotActiveModCP'); + +llxheader('',$langs->trans('TitleAdminCP')); + +print_fiche_titre($langs->trans('MenuCPTypes')); + +echo '
'; + +echo '
'; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; + +$types = $db->query( + "SELECT * + FROM llx_congespayes_types + WHERE deleteAt IS NULL + ORDER BY label" +); + +while($type = $db->fetch_array($types)) +{ + echo' + + + + + + + + + + + + + '; +} + +echo ' + + + + + + +
' . $langs->trans('TypeLabel') . '' . $langs->trans('TypeDescription') . '' . $langs->trans('TypeAffect') . '' . $langs->trans('TypeDelay') . '' . $langs->trans('nbCongesDeductedCPMini') . '' . $langs->trans('nbCongesEveryMonthCPMini') . '
'.$type['label'].''.($type['description']?$type['description']:'N/A').' + '.($type['affect']?$langs->trans('TypeAffectYes'):$langs->trans('TypeAffectNo')).' + '.$type['delay'].''.$type['nbCongesDeducted'].''.$type['nbCongesEveryMonth'].' + + +
+ +
+ +'; + +echo ''; + +llxFooter(); + +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/holiday/img/add.png b/htdocs/holiday/img/add.png new file mode 100755 index 0000000000000000000000000000000000000000..d15cb50d8357f798867c21d9adf994fed6cfb45e GIT binary patch literal 3208 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 literal 0 HcmV?d00001 diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index e8a62f9d05d..54aea6de52d 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -945,3 +945,17 @@ create table llx_c_email_templates UPDATE llx_c_regions SET rowid = 0 where rowid = 1; DELETE FROM llx_c_departements WHERE fk_region NOT IN (select rowid from llx_c_regions) AND fk_region IS NOT NULL AND fk_region <> 0; ALTER TABLE llx_c_departements ADD CONSTRAINT fk_departements_fk_region FOREIGN KEY (fk_region) REFERENCES llx_c_regions (rowid); + + +CREATE TABLE llx_holiday_types ( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + label varchar(45) NOT NULL, + description varchar(255) NOT NULL, + affect int(1) NOT NULL, + delay int(1) NOT NULL, + insertAt DATETIME NOT NULL, + updateAt DATETIME, + deleteAt DATETIME, + nbCongesDeducted varchar(255) NOT NULL, + nbCongesEveryMonth varchar(255) NOT NULL +); diff --git a/htdocs/install/mysql/tables/llx_holiday_types.sql b/htdocs/install/mysql/tables/llx_holiday_types.sql new file mode 100755 index 00000000000..4fa2c5e387f --- /dev/null +++ b/htdocs/install/mysql/tables/llx_holiday_types.sql @@ -0,0 +1,30 @@ +-- =================================================================== +-- Copyright (C) 2014 Laurent Destailleur +-- +-- 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 . +-- +-- =================================================================== + +CREATE TABLE llx_holiday_types ( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + label varchar(45) NOT NULL, + description varchar(255) NOT NULL, + affect int(1) NOT NULL, + delay int(1) NOT NULL, + insertAt DATETIME NOT NULL, + updateAt DATETIME, + deleteAt DATETIME, + nbCongesDeducted varchar(255) NOT NULL, + nbCongesEveryMonth varchar(255) NOT NULL +); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 319a58131ab..76a6a43f9bb 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2564,6 +2564,41 @@ a.cke_dialog_ui_button } +/* ============================================================================== */ +/* Holiday */ +/* ============================================================================== */ + +#types .btn { + cursor: pointer; +} + +#types .btn-primary { + font-weight: bold; +} + +#types form { + padding: 20px; +} + +#types label { + display:inline-block; + width:100px; + margin-right: 20px; + padding: 4px; + text-align: right; + vertical-align: top; +} + +#types input.text, #types textarea { + width: 400px; +} + +#types textarea { + height: 100px; +} + + + /* ============================================================================== */ /* JSGantt */ /* ============================================================================== */ From bbb58dd365c65a9aefb1b2eeb178bd084e220ce7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 03:09:59 +0200 Subject: [PATCH 21/27] New: Add navigation on year on page of leaves. --- htdocs/holiday/view_log.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index dba8969adca..5f18a524acc 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -26,6 +26,7 @@ require('../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Protection if external user if ($user->societe_id > 0) accessforbidden(); @@ -33,6 +34,12 @@ if ($user->societe_id > 0) accessforbidden(); // Si l'utilisateur n'a pas le droit de lire cette page if(!$user->rights->holiday->view_log) accessforbidden(); +$year=GETPOST('year'); +if (empty($year)) +{ + $tmpdate=dol_getdate(dol_now()); + $year=$tmpdate['year']; +} /* @@ -41,14 +48,14 @@ if(!$user->rights->holiday->view_log) accessforbidden(); $langs->load('users'); -llxHeader(array(),$langs->trans('CPTitreMenu')); +llxHeader(array(),$langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.')'); $cp = new Holiday($db); // Recent changes are more important than old changes -$log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC',''); +$log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC', " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year,1,1))."' AND '".$db->idate(dol_get_last_day($year,12,1))."'"); // Load $cp->logs -print_fiche_titre($langs->trans('LogCP')); +print_fiche_titre($langs->trans('LogCP'),''.img_previous().' '.$langs->trans("Year").':'.$year.' '.img_next().''); print ''; print ''; From 4bd257f00780ea78365d8200000546404f9e1c0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 03:23:16 +0200 Subject: [PATCH 22/27] New: Work on type of leave. --- htdocs/holiday/class/holiday.class.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index fdc43fe8106..aac5464fea5 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1733,6 +1733,30 @@ class Holiday extends CommonObject } } + + /** + * Tous les types + * + * @return boolean Return array with list of types + */ + function getTypes() + { + $result = $this->db->query("SELECT rowid, type, affect FROM " . MAIN_DB_PREFIX . "holiday_types"); + $num = $this->db->num_rows($result); + if ($num) + { + while ($obj = $this->db->fetch_object($result)) + { + $types[] = array('rowid'=> $obj->rowid, 'type'=> $obj->type, 'affect'=>$obj->affect); + } + + return $types; + } + + return array(); + } + + /** * Initialise an instance with random values. * Used to build previews or test instances. From 85748711b55cb4e1ba1ad54a2382737bd80d2ffb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 09:08:28 +0200 Subject: [PATCH 23/27] Fix: Table holiday_user was not initialized anymore. Conflicts: htdocs/holiday/class/holiday.class.php htdocs/holiday/fiche.php --- htdocs/holiday/class/holiday.class.php | 61 ++++++++++++++++---------- htdocs/holiday/define_holiday.php | 7 ++- htdocs/holiday/fiche.php | 32 +++++++------- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index f8a837e879f..0d661018481 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -77,7 +77,7 @@ class Holiday extends CommonObject /** - * updateSold + * updateSold. Update sold and check table of users for holidays is complete. If not complete. * * @return int Return 1 */ @@ -983,25 +983,31 @@ class Holiday extends CommonObject */ function createCPusers($single=false,$userid='') { - // Si c'est l'ensemble des utilisateurs à ajoutés - if(!$single) + // Si c'est l'ensemble des utilisateurs à ajouter + if (! $single) { dol_syslog(get_class($this).'::createCPusers'); - foreach($this->fetchUsers(false,true) as $users) { + $arrayofusers = $this->fetchUsers(false,true); + + foreach($arrayofusers as $users) + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; $sql.= " (fk_user, nb_holiday)"; $sql.= " VALUES ('".$users['rowid']."','0')"; - $this->db->query($sql); + $resql=$this->db->query($sql); + if (! $resql) dol_print_error($this->db); } - } else { + } + else + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; $sql.= " (fk_user, nb_holiday)"; $sql.= " VALUES ('".$userid."','0')"; - $this->db->query($sql); + $resql=$this->db->query($sql); + if (! $resql) dol_print_error($this->db); } - } /** @@ -1048,7 +1054,7 @@ class Holiday extends CommonObject * uniquement pour vérifier si il existe de nouveau utilisateur * * @param boolean $liste si vrai retourne une liste, si faux retourne un array - * @param boolean $type si vrai retourne pour Dolibarr si faux retourne pour CP + * @param boolean $type si vrai retourne pour Dolibarr, si faux retourne pour CP * @return string retourne un tableau de tout les utilisateurs actifs */ function fetchUsers($liste=true,$type=true) @@ -1263,50 +1269,56 @@ class Holiday extends CommonObject function verifNbUsers($userDolibarrWithoutCP,$userCP) { if (empty($userCP)) $userCP=0; - dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarr.' userCP='.$userCP); + dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); // On vérifie les users Dolibarr sans CP if ($userDolibarrWithoutCP > 0) { - $this->updateConfCP('nbUser',$userDolibarr); + $this->db->begin(); + + $this->updateConfCP('nbUser',$userDolibarrWithoutCP); $listUsersCP = $this->fetchUsers(true,false); // On séléctionne les utilisateurs qui ne sont pas déjà dans le module $sql = "SELECT u.rowid, u.lastname, u.firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.rowid NOT IN(".$listUsersCP.")"; - - $result = $this->db->query($sql); - - // Si pas d'erreur SQL - if($result) { + if ($listUsersCP != '') $sql.= " WHERE u.rowid NOT IN(".$listUsersCP.")"; + $resql = $this->db->query($sql); + if ($resql) + { $i = 0; $num = $this->db->num_rows($resql); - while($i < $num) { - + while($i < $num) + { $obj = $this->db->fetch_object($resql); + $uid = $obj->rowid; // On ajoute l'utilisateur - $this->createCPusers(true,$obj->rowid); + //print "Add user rowid = ".$uid." into database holiday"; + + $result = $this->createCPusers(true,$uid); $i++; } - + $this->db->commit(); } else { // Erreur SQL $this->error="Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::verifNbUsers ".$this->error, LOG_ERR); + $this->db->rollback(); return -1; } } else { - // Si il y a moins d'utilisateur Dolibarr que dans le module CP + $this->db->begin(); - $this->updateConfCP('nbUser',$userDolibarr); + // Si il y a moins d'utilisateur Dolibarr que dans le module CP + + $this->updateConfCP('nbUser',$userDolibarrWithoutCP); $listUsersDolibarr = $this->fetchUsers(true,true); @@ -1333,11 +1345,12 @@ class Holiday extends CommonObject $i++; } - + $this->db->commit(); } else { // Erreur SQL $this->error="Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::verifNbUsers ".$this->error, LOG_ERR); + $this->db->rollback(); return -1; } } diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 1bf8a2716cc..4e1540c99e5 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -43,14 +43,17 @@ $action=GETPOST('action'); */ $form = new Form($db); +$userstatic=new User($db); +$holiday = new Holiday($db); + llxHeader(array(),$langs->trans('CPTitreMenu')); print_fiche_titre($langs->trans('MenuConfCP')); -$holiday = new Holiday($db); +$holiday->updateSold(); // Create users into table holiday if they don't exists. TODO Remove if we use field into table user. + $listUsers = $holiday->fetchUsers(false,false); -$userstatic=new User($db); // Si il y a une action de mise à jour if ($action == 'update' && isset($_POST['update_cp'])) diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php index 0ff0194d5cf..2f6c52eaf86 100644 --- a/htdocs/holiday/fiche.php +++ b/htdocs/holiday/fiche.php @@ -237,9 +237,9 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') if($user->rights->holiday->delete) { $error=0; - + $db->begin(); - + $cp = new Holiday($db); $cp->fetch($id); @@ -251,12 +251,12 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') { $result=$cp->delete($id); } - else + else { $error = $langs->trans('ErrorCantDeleteCP'); } } - + if (! $error) { $db->commit(); @@ -265,7 +265,7 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') } else { - $db->rollback(); + $db->rollback(); } } } @@ -384,7 +384,7 @@ if($action == 'confirm_valid') $verif = $cp->update($user->id); // Si pas d'erreur SQL on redirige vers la fiche de la demande - if ($verif > 0) + if ($verif > 0) { // Calculcate number of days consummed $nbopenedday=num_open_day($cp->date_debut,$cp->date_fin,0,1); @@ -470,7 +470,7 @@ if ($action == 'confirm_refuse') $verif = $cp->update($user->id); // Si pas d'erreur SQL on redirige vers la fiche de la demande - if ($verif > 0) + if ($verif > 0) { // To $destinataire = new User($db); @@ -541,7 +541,7 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') if (($cp->statut == 2 || $cp->statut == 3) && ($user->id == $cp->fk_validator || $user->id == $cp->fk_user)) { $db->begin(); - + $oldstatus = $cp->statut; $cp->date_cancel = dol_now(); $cp->fk_user_cancel = $user->id; @@ -568,16 +568,16 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') $error = $langs->trans('ErrorCantDeleteCP'); } } - + if (! $error) { - $db->commit(); + $db->commit(); } else { $db->rollback(); } - + // Si pas d'erreur SQL on redirige vers la fiche de la demande if (! $error && $result > 0) { @@ -874,7 +874,7 @@ else if($user->id == $cp->fk_user || $user->rights->holiday->lire_tous) { - if ($action == 'delete') + if ($action == 'delete') { if($user->rights->holiday->delete) { @@ -943,8 +943,8 @@ else print $langs->trans($listhalfday[$starthalfday]); print ''; print ''; - } - else + } + else { print ''; print ''; @@ -965,8 +965,8 @@ else print $langs->trans($listhalfday[$endhalfday]); print ''; print ''; - } - else + } + else { print ''; print ''; From 2d524f2edc0f88c30354c54e5968bff6dbe80f5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 09:09:22 +0200 Subject: [PATCH 24/27] Fix: Holiday module was broken. Initializaion of amount of holidays failed. --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 58bfffebd2e..44239e48fc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ English Dolibarr ChangeLog -------------------------------------------------------------- ***** ChangeLog for 3.5.5 compared to 3.5.4 ***** +Fix: Holiday module was broken. Initializaion of amount of holidays failed. Fix: [ bug #1523 ] suite bug #1334 : filtre et ordre de tri conjoints ne s'appliquent pas. Fix: Fusion PDF button on unpaid invoice is no more displayed Fix: Unpaid invoice launch fusion PDF action even if it is only search (with enter keyboard input instead of lens click) From 2169a8668db04c5663f26ec0d58d19b7d3361473 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 09:18:44 +0200 Subject: [PATCH 25/27] Fix: PHPCS --- htdocs/holiday/admin/tomergewithholiday.php | 1 - htdocs/holiday/define_congespayes.php | 126 ++++++++++++++++++ .../mysql/tables/llx_holiday_types.sql | 4 +- 3 files changed, 128 insertions(+), 3 deletions(-) create mode 100755 htdocs/holiday/define_congespayes.php diff --git a/htdocs/holiday/admin/tomergewithholiday.php b/htdocs/holiday/admin/tomergewithholiday.php index 7ff795a455b..c301e1ba348 100755 --- a/htdocs/holiday/admin/tomergewithholiday.php +++ b/htdocs/holiday/admin/tomergewithholiday.php @@ -223,4 +223,3 @@ echo ''; llxFooter(); $db->close(); -?> \ No newline at end of file diff --git a/htdocs/holiday/define_congespayes.php b/htdocs/holiday/define_congespayes.php new file mode 100755 index 00000000000..cd3b818b208 --- /dev/null +++ b/htdocs/holiday/define_congespayes.php @@ -0,0 +1,126 @@ + + * Copyright (C) 2011 Dimitri Mouillard + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file define_congespayes.php + * \ingroup congespayes + * \brief File that defines the balance of paid leave of users. + * \version $Id: define_congespayes.php,v 1.00 2011/09/15 11:00:00 dmouillard Exp $ + * \author dmouillard@teclib.com + * \remarks File that defines the balance of paid leave of users. + */ + +require('../main.inc.php'); +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; + +// Protection if external user +if ($user->societe_id > 0) accessforbidden(); + +// If the user does not have perm to read the page +if(!$user->rights->holiday->define_holiday) accessforbidden(); + + +/* + * View + */ + +llxHeader(array(),$langs->trans('CPTitreMenu')); + + +print_fiche_titre($langs->trans('MenuConfCP')); + +$congespayes = new Holidays($db); +$listUsers = $congespayes->fetchUsers(false, true); + +// Si il y a une action de mise à jour +if (isset($_POST['action']) && $_POST['action'] == 'update') { + + $fk_type = $_POST['fk_type']; + + foreach ($_POST['nb_conges'] as $user_id => $compteur) { + if (!empty($compteur)) { + $userValue = str_replace(',', '.', $compteur); + $userValue = number_format($userValue, 2, '.', ''); + } else { + $userValue = '0.00'; + } + $congespayes->updateSoldeCP($user_id,$userValue,$fk_type); + } + + print '
'; + print $langs->trans('UpdateConfCPOK'); + print '
'; + +} + +$var = true; +$i = 0; + +foreach($congespayes->getTypes() as $type) +{ + if($type['affect']==1) + { + print '
'; + + print '

'.$type['label'].'

'; + + print '
' . "\n"; + print ''; + print ''; + + print '
'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')
'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')
'; + print ""; + print ''; + print ''; + print ''; + + foreach ($listUsers as $users) { + $var = !$var; + print ''; + print ''; + print '' . "\n"; + print ''; + + $i++; + } + + echo ""; + print ''; + echo ""; + + print '
' . $langs->trans('Employee') . '' . $langs->trans('Counter') . '
' . $users['name'] . ' ' . $users['firstname'] . ''; + print ''; + print ' jours
'; + print ''; + + print ''; + } +} + +// Fin de page +$db->close(); +llxFooter(); +?> diff --git a/htdocs/install/mysql/tables/llx_holiday_types.sql b/htdocs/install/mysql/tables/llx_holiday_types.sql index 4fa2c5e387f..242483b5974 100755 --- a/htdocs/install/mysql/tables/llx_holiday_types.sql +++ b/htdocs/install/mysql/tables/llx_holiday_types.sql @@ -20,8 +20,8 @@ CREATE TABLE llx_holiday_types ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, label varchar(45) NOT NULL, description varchar(255) NOT NULL, - affect int(1) NOT NULL, - delay int(1) NOT NULL, + affect integer NOT NULL, + delay integer NOT NULL, insertAt DATETIME NOT NULL, updateAt DATETIME, deleteAt DATETIME, From f91e847562c22613de572030a4b7b029c70b45e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 09:23:37 +0200 Subject: [PATCH 26/27] Qual: Removed had coded value for version. --- build/doxygen/dolibarr-doxygen-build.pl | 21 +++++++++++++++++++-- build/doxygen/dolibarr-doxygen.doxyfile | 2 +- build/doxygen/doxygen_header.html | 16 ++++++++-------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/build/doxygen/dolibarr-doxygen-build.pl b/build/doxygen/dolibarr-doxygen-build.pl index 65fc027ca32..f8c8c480081 100755 --- a/build/doxygen/dolibarr-doxygen-build.pl +++ b/build/doxygen/dolibarr-doxygen-build.pl @@ -30,8 +30,25 @@ if (! -s $CONFFILE) exit 1; } -print "Running doxygen, please wait...\n"; -$result=`doxygen $OPTIONS $CONFFILE 2>&1`; +$SOURCE="../.."; + +# Get version $MAJOR, $MINOR and $BUILD +$result = open( IN, "< " . $SOURCE . "/htdocs/filefunc.inc.php" ); +if ( !$result ) { die "Error: Can't open descriptor file " . $SOURCE . "/htdocs/filefunc.inc.php\n"; } +while () { + if ( $_ =~ /define\('DOL_VERSION','([\d\.a-z\-]+)'\)/ ) { $PROJVERSION = $1; break; } +} +close IN; +($MAJOR,$MINOR,$BUILD)=split(/\./,$PROJVERSION,3); +if ($MINOR eq '') { die "Error can't detect version into ".$SOURCE . "/htdocs/filefunc.inc.php"; } + + +$version=$MAJOR.".".$MINOR.".".$BUILD; + + +print "Running doxygen for version ".$version.", please wait...\n"; +print "cat $CONFFILE | sed -e 's/x\.y\.z/".$version."/' | doxygen $OPTIONS - 2>&1\n"; +$result=`cat $CONFFILE | sed -e 's/x\.y\.z/$version/' | doxygen $OPTIONS - 2>&1`; print $result; diff --git a/build/doxygen/dolibarr-doxygen.doxyfile b/build/doxygen/dolibarr-doxygen.doxyfile index 7a6bcb43119..912c72b4d69 100644 --- a/build/doxygen/dolibarr-doxygen.doxyfile +++ b/build/doxygen/dolibarr-doxygen.doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = dolibarr # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 3.5 +PROJECT_NUMBER = x.y.z # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/build/doxygen/doxygen_header.html b/build/doxygen/doxygen_header.html index 8d367cccb67..363d408d43c 100755 --- a/build/doxygen/doxygen_header.html +++ b/build/doxygen/doxygen_header.html @@ -35,15 +35,15 @@ File added into doxygen generated documentation
- + + + -
From cffc92a5c0af09f33a55e753f002d2e48055fee0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 09:46:09 +0200 Subject: [PATCH 27/27] Fix: PHPCS --- .../{define_congespayes.php => tomergewithdefine_holiday.php} | 1 - 1 file changed, 1 deletion(-) rename htdocs/holiday/{define_congespayes.php => tomergewithdefine_holiday.php} (99%) diff --git a/htdocs/holiday/define_congespayes.php b/htdocs/holiday/tomergewithdefine_holiday.php similarity index 99% rename from htdocs/holiday/define_congespayes.php rename to htdocs/holiday/tomergewithdefine_holiday.php index cd3b818b208..4bf904528a0 100755 --- a/htdocs/holiday/define_congespayes.php +++ b/htdocs/holiday/tomergewithdefine_holiday.php @@ -123,4 +123,3 @@ foreach($congespayes->getTypes() as $type) // Fin de page $db->close(); llxFooter(); -?>