From a43e7fd34e950f92becc4510a5aa2fc8ebee8227 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Jul 2013 12:39:01 +0200 Subject: [PATCH 01/16] Fix: Changelog --- ChangeLog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 06189a39564..003679cf3f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,12 +2,15 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 3.3.4 compared to 3.3.3 ***** + +- Fix: [ bug #1001 ] Social Contribution : State not correct + ***** ChangeLog for 3.3.3 compared to 3.3.2 ***** - Fix: [ bug #903 ] Fatal error: Call to undefined function dol_get_first_day() in htdocs/commande/liste.php - Fix: [ bug #934 ] Error on proformat invoice creation (pgsql) - Fix: [ bug #947 ] Can't create proposal lines with unit price = 0 -- Fix: [ bug #1001 ] Social Contribution : State not correct ***** ChangeLog for 3.3.2 compared to 3.3.1 ***** From bbaa344801c7a7c824db748759acee6374a88ab7 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 29 Jul 2013 12:17:24 +0200 Subject: [PATCH 02/16] Defaulted PDF model document with default value (set in admin) for Shipping and delivery --- htdocs/expedition/class/expedition.class.php | 5 +++++ htdocs/livraison/class/livraison.class.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 18147a67061..0fe0dbc1cc9 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -59,6 +59,7 @@ class Expedition extends CommonObject var $billed; var $note_public; var $note_private; + var $model_pdf; var $trueWeight; var $weight_units; @@ -162,6 +163,8 @@ class Expedition extends CommonObject global $conf, $langs; $now=dol_now(); + + if (empty($this->model_pdf)) $this->model_pdf=$conf->global->EXPEDITION_ADDON_PDF; require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; $error = 0; @@ -196,6 +199,7 @@ class Expedition extends CommonObject $sql.= ", size_units"; $sql.= ", note_private"; $sql.= ", note_public"; + $sql.= ", model_pdf"; $sql.= ") VALUES ("; $sql.= "'(PROV)'"; $sql.= ", ".$conf->entity; @@ -217,6 +221,7 @@ class Expedition extends CommonObject $sql.= ", ".$this->size_units; $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); + $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); $sql.= ")"; $resql=$this->db->query($sql); diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index ea1962be34c..9bcf349e373 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -59,6 +59,7 @@ class Livraison extends CommonObject var $date_delivery; // Date really received var $date_creation; var $date_valid; + var $model_pdf; /** @@ -89,6 +90,8 @@ class Livraison extends CommonObject global $conf; dol_syslog("Livraison::create"); + + if (empty($this->model_pdf)) $this->model_pdf=$conf->global->LIVRAISON_ADDON_PDF; $error = 0; @@ -112,6 +115,7 @@ class Livraison extends CommonObject $sql.= ", fk_address"; $sql.= ", note_private"; $sql.= ", note_public"; + $sql.= ", model_pdf"; $sql.= ") VALUES ("; $sql.= "'(PROV)'"; $sql.= ", ".$conf->entity; @@ -123,6 +127,7 @@ class Livraison extends CommonObject $sql.= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null"); $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); + $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); $sql.= ")"; dol_syslog("Livraison::create sql=".$sql, LOG_DEBUG); From d6f31d61bfb54ef14aa5bfbb473e923f130e5723 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 29 Jul 2013 12:21:52 +0200 Subject: [PATCH 03/16] Fix Typhon model $mysoc global is missing --- htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index 6db383e10e7..c61948fe8ee 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -537,7 +537,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ function _tableau_info(&$pdf, $object, $posy, $outputlangs) { - global $conf; + global $conf,$mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('','', $default_font_size); From f9c2910f845af6dc020d064a51aa308e75ac0ab8 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 30 Jul 2013 09:21:45 +0200 Subject: [PATCH 04/16] Fix : Numbering on supplier invoice was not saved and on shipment displayed error when ok --- htdocs/admin/expedition.php | 2 +- .../modules/supplier_invoice/mod_facture_fournisseur_tulip.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 1ac15bed9ed..4fff86e2c3a 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -64,7 +64,7 @@ if ($action == 'updateMask') if (isset($res)) { - if ($res < 0) + if ($res > 0) setEventMessage($langs->trans("SetupSaved")); else setEventMessage($langs->trans("Error"), 'errors'); diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 855cf4c74ae..db600493478 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -56,7 +56,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= '
'; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; From 3bc7d3c877a6b1f6ae1a97609b13c5aa2ed11431 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 30 Jul 2013 14:18:56 +0200 Subject: [PATCH 05/16] Fix extrafeild thirdparty import and export --- htdocs/core/modules/modSociete.class.php | 40 ++++++++++++++++++------ 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 73ce8eb8c01..b3c398ae12e 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -312,17 +312,37 @@ class modSociete extends DolibarrModules unset($this->export_entities_array[$r]['s.code_fournisseur']); } // Add extra fields - $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'contact'"; + $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople'"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_entities_array[$r][$fieldname]='contact'; - } + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $typeFilter="Text"; + switch($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter="Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter="Date"; + break; + case 'boolean': + $typeFilter="Boolean"; + break; + case 'sellist': + $typeFilter="List:".$obj->param; + break; + } + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; + $this->export_entities_array[$r][$fieldname]='contact'; + } } // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; @@ -346,7 +366,7 @@ class modSociete extends DolibarrModules $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r]=array('s.nom'=>"Name*",'s.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff","s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage','s.barcode'=>'BarCode','s.datec'=>"DateCreation"); // Add extra fields - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'company' AND entity = ".$conf->entity; + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity = ".$conf->entity; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -381,7 +401,7 @@ class modSociete extends DolibarrModules $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople','extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r]=array('s.fk_soc'=>'ThirdPartyName*','s.civilite'=>'UserTitle','s.lastname'=>"Name*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso",'s.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note_private'=>"Note",'s.note_public'=>"Note",'s.datec'=>"DateCreation"); // Add extra fields - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'contact' AND entity = ".$conf->entity; + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity = ".$conf->entity; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { From 4d3738410eb15c134b8c03ae37a8042bcd2a49e6 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 30 Jul 2013 15:18:19 +0200 Subject: [PATCH 06/16] update no_email column on unsubcribe link for contact --- htdocs/public/emailing/mailing-unsubscribe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index 3f86685fad3..ec95078808c 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -85,7 +85,7 @@ if (! empty($tag) && ($unsuscrib=='1')) $resql=$db->query($sql); //Update status communication of contact prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=-1 WHERE rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; + $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe contact : ".$sql, LOG_DEBUG); $resql=$db->query($sql); From f0bbdfddfbb1457953a29137cee2b658c168e3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Salvador?= Date: Wed, 31 Jul 2013 10:08:33 +0200 Subject: [PATCH 07/16] fixed bad function call causing select_produits_list to fail --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fd58b4263b8..3205206a11c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1400,7 +1400,7 @@ class Form $objp->remise = $objp2->remise; $objp->price_by_qty_rowid = $objp2->rowid; - $this->_construct_product_list_option($objp, $opt, $optJson, 0, $selected); + $this->constructProductListOption($objp, $opt, $optJson, 0, $selected); $j++; @@ -1414,7 +1414,7 @@ class Form } else { - $this->_construct_product_list_option($objp, $opt, $optJson, $price_level, $selected); + $this->constructProductListOption($objp, $opt, $optJson, $price_level, $selected); // Add new entry // "key" value of json key array is used by jQuery automatically as selected value // "label" value of json key array is used by jQuery automatically as text for combo box From 0b13781cbfe8f6dd612ef4eed8473f57b622bee3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Jul 2013 11:19:49 +0200 Subject: [PATCH 08/16] Fix: Search on contract ref --- htdocs/contrat/liste.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index 2042b5c45f7..bece4ebdf3c 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -80,7 +80,7 @@ $sql.= " AND c.entity = ".$conf->entity; if ($socid) $sql.= " AND s.rowid = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($search_nom) $sql.= " AND s.nom LIKE '%".$db->escape($search_nom)."%'"; -if ($search_contract) $sql.= " AND c.rowid = '".$db->escape($search_contract)."'"; +if ($search_contract) $sql.= " AND (".(is_numeric($search_contract)?"c.rowid = '".$db->escape($search_contract)."' OR ":'')." c.ref = '".$db->escape($search_contract)."')"; if ($sall) $sql.= " AND (s.nom LIKE '%".$db->escape($sall)."%' OR cd.label LIKE '%".$db->escape($sall)."%' OR cd.description LIKE '%".$db->escape($sall)."%')"; $sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut,"; $sql.= " s.nom, s.rowid"; From ecfca853a1158e9f94b19c902d731142ba615945 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Jul 2013 11:19:49 +0200 Subject: [PATCH 09/16] Fix: Search on contract ref --- htdocs/contrat/liste.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index 2042b5c45f7..bece4ebdf3c 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -80,7 +80,7 @@ $sql.= " AND c.entity = ".$conf->entity; if ($socid) $sql.= " AND s.rowid = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($search_nom) $sql.= " AND s.nom LIKE '%".$db->escape($search_nom)."%'"; -if ($search_contract) $sql.= " AND c.rowid = '".$db->escape($search_contract)."'"; +if ($search_contract) $sql.= " AND (".(is_numeric($search_contract)?"c.rowid = '".$db->escape($search_contract)."' OR ":'')." c.ref = '".$db->escape($search_contract)."')"; if ($sall) $sql.= " AND (s.nom LIKE '%".$db->escape($sall)."%' OR cd.label LIKE '%".$db->escape($sall)."%' OR cd.description LIKE '%".$db->escape($sall)."%')"; $sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut,"; $sql.= " s.nom, s.rowid"; From c4ebdf18e702e1d8838148d41ffadbb91ee592f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Jul 2013 11:22:52 +0200 Subject: [PATCH 10/16] Fix: search on contract ref --- htdocs/contrat/liste.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index bece4ebdf3c..3140834b626 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -80,7 +80,7 @@ $sql.= " AND c.entity = ".$conf->entity; if ($socid) $sql.= " AND s.rowid = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($search_nom) $sql.= " AND s.nom LIKE '%".$db->escape($search_nom)."%'"; -if ($search_contract) $sql.= " AND (".(is_numeric($search_contract)?"c.rowid = '".$db->escape($search_contract)."' OR ":'')." c.ref = '".$db->escape($search_contract)."')"; +if ($search_contract) $sql.= " AND (".(is_numeric($search_contract)?"c.rowid = ".$db->escape($search_contract)." OR ":'')." c.ref LIKE '%".$db->escape($search_contract)."%')"; if ($sall) $sql.= " AND (s.nom LIKE '%".$db->escape($sall)."%' OR cd.label LIKE '%".$db->escape($sall)."%' OR cd.description LIKE '%".$db->escape($sall)."%')"; $sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut,"; $sql.= " s.nom, s.rowid"; From 378842e05f65d7fbab1d28cc705a846efc9bbe6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Jul 2013 11:27:56 +0200 Subject: [PATCH 11/16] Fix: Better error management --- htdocs/contrat/fiche.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 3cc5824ddc5..2bfcbf0a726 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -916,20 +916,14 @@ else if ($id > 0 || ! empty($ref)) { $result=$object->fetch($id,$ref); - if ($result > 0) - { - $result=$object->fetch_lines(); - } - if ($result < 0) - { - dol_print_error($db,$object->error); - exit; - } + if ($result < 0) dol_print_error($db,$object->error); + $result=$object->fetch_lines(); + if ($result < 0) dol_print_error($db,$object->error); + $result=$object->fetch_thirdparty(); + if ($result < 0) dol_print_error($db,$object->error); dol_htmloutput_errors($mesg,''); - $object->fetch_thirdparty(); - $nbofservices=count($object->lines); $author = new User($db); From 384e3812eb73a15adafb472cacfb93397a54459b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Jul 2013 11:41:25 +0200 Subject: [PATCH 12/16] Fix: W3C. No form into TR. --- htdocs/contrat/fiche.php | 42 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 2bfcbf0a726..30aced500d7 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -1086,18 +1086,26 @@ else $productstatic=new Product($db); // Title line for service - print '
'; // Array with (n*2)+1 lines + //print '
'; // Array with (n*2)+1 lines $cursorline=1; while ($cursorline <= $nbofservices) { - print ''; - print ''; + //print ''; + //print ''; - print ''; // End td if line is 1 + /* print ''; // End td if line is 1 print ''; - print ''; + print '';*/ + $cursorline++; } - print '
'; - print $langs->trans("ServiceNb",$cursorline).'
'; + //print $langs->trans("ServiceNb",$cursorline).''; + // print ''; + + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; // Area with common detail of line - print ''; + print '
'; $sql = "SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.description, cd.price_ht, cd.qty,"; $sql.= " cd.tva_tx, cd.remise_percent, cd.info_bits, cd.subprice,"; @@ -1115,7 +1123,7 @@ else $total = 0; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -1230,13 +1238,7 @@ else } // Ligne en mode update else - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + { // Ligne carac print ""; print ''; print ''; - - print "\n"; } $db->free($result); } else - { + { dol_print_error($db); } @@ -1306,6 +1306,7 @@ else } print "
'.$langs->trans("Service").''.$langs->trans("ServiceNb",$cursorline).''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").'
'; @@ -1287,14 +1289,12 @@ else $form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update"); print '
"; + print "\n"; /* @@ -1515,13 +1516,14 @@ else print ''; } - print '
 
 
'; + //print ''; // Form to add new line if ($user->rights->contrat->creer && ($object->statut >= 0)) From fbd3f6e67f1802b65f18664ad11e3946437666b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Jul 2013 12:33:18 +0200 Subject: [PATCH 13/16] Fix: Maxi debug of scripts --- htdocs/langs/en_US/contracts.lang | 3 +- htdocs/langs/fr_FR/contracts.lang | 7 +- .../company/export-contacts-xls-example.php | 0 .../company/sync_contacts_dolibarr2ldap.php | 0 .../email_expire_services_to_customers.php | 121 ++++++++++++------ ...ail_expire_services_to_representatives.php | 39 +++--- .../email_unpaid_invoices_to_customers.php | 2 +- ...ail_unpaid_invoices_to_representatives.php | 6 +- scripts/withdrawals/build_withdrawal_file.php | 0 test/phpunit/ScriptsTest.php | 83 +++++++++++- 10 files changed, 192 insertions(+), 69 deletions(-) mode change 100644 => 100755 scripts/company/export-contacts-xls-example.php mode change 100644 => 100755 scripts/company/sync_contacts_dolibarr2ldap.php mode change 100644 => 100755 scripts/withdrawals/build_withdrawal_file.php diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index bab5a4451c4..eceac62999a 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -87,8 +87,9 @@ ExpiredSince=Expiration date RelatedContracts=Related contracts NoExpiredServices=No expired active services ListOfServicesToExpireWithDuration=List of Services to expire in %s days +ListOfServicesToExpireWithDurationNeg=List of Services expired from more than %s days ListOfServicesToExpire=List of Services to expire -Service=Service +NoteListOfYourExpiredServices=This list contains only services of contracts for third parties you are linked to as a sale representative. ##### Types de contacts ##### TypeContact_contrat_internal_SALESREPSIGN=Sales representative signing contract diff --git a/htdocs/langs/fr_FR/contracts.lang b/htdocs/langs/fr_FR/contracts.lang index 9cef9326f8e..36888df40b0 100644 --- a/htdocs/langs/fr_FR/contracts.lang +++ b/htdocs/langs/fr_FR/contracts.lang @@ -86,9 +86,10 @@ PaymentRenewContractId=Renouvellement service (numéro %s) ExpiredSince=Expiré le RelatedContracts=Contrats associés NoExpiredServices=Pas de services actifs expirés -ListOfServicesToExpireWithDuration=Liste des services actifs pour expirer à %s days -ListOfServicesToExpire=Liste des services actifs pour expirer -Service=Service +ListOfServicesToExpireWithDuration=Liste des services actifs expirant dans %s jours +ListOfServicesToExpireWithDurationNeg=Liste des services actifs expiré depuis plus de %s jours +ListOfServicesToExpire=Liste des services actifs en expiration +NoteListOfYourExpiredServices=Cette list ne contient que les contrats de services des tiers pour lesquels vous êtes liés comme représentant commercial. ##### Types de contacts ##### TypeContact_contrat_internal_SALESREPSIGN=Commercial signataire du contrat diff --git a/scripts/company/export-contacts-xls-example.php b/scripts/company/export-contacts-xls-example.php old mode 100644 new mode 100755 diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php old mode 100644 new mode 100755 diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index 611d614393a..83f71d7e65d 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -36,16 +36,18 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm'))) +if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm')) || ! in_array($argv[2],array('thirdparties','contacts'))) { - print "Usage: $script_file [test|confirm] [delay]\n"; + print "Usage: $script_file (test|confirm) (thirdparties|contacts) [delay] [after]\n"; print "\n"; - print "Send an email to customers to remind all all contracts services to expire.\n"; + print "Send an email to customers to remind all contracts services to expire or expired.\n"; print "If you choose 'test' mode, no emails are sent.\n"; - print "If you add a delay (nb of days), only services with expired date < today + delay are included.\n"; + print "If you add param delay (nb of days), only services with expired date < today + delay are included.\n"; + print "If you add param after (nb of days), only services with expired date >= today + delay are included.\n"; exit(-1); } $mode=$argv[1]; +$targettype=$argv[2]; require($path."../../htdocs/master.inc.php"); @@ -69,33 +71,42 @@ print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',',$argv)); $now=dol_now('tzserver'); -$duration_value=isset($argv[2])?$argv[2]:'none'; +$duration_value=isset($argv[3])?$argv[3]:'none'; +$duration_value2=isset($argv[4])?$argv[4]:'none'; -print $script_file." launched with mode ".$mode.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n"; +$error = 0; +print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value)?" delay=".$duration_value:"").(is_numeric($duration_value2)?" after=".$duration_value2:"")."\n"; if ($mode != 'confirm') $conf->global->MAIN_DISABLE_ALL_MAILS=1; -$sql = "SELECT DISTINCT s.nom as name, c.ref, cd.date_fin_validite, cd.total_ttc, p.label label, s.email, s.default_lang"; +$sql = "SELECT c.ref, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel,"; +$sql.= " s.rowid as sid, s.nom as name, s.email, s.default_lang"; +if ($targettype == 'contacts') $sql.= ", sp.rowid as cid, sp.firstname as cfirstname, sp.lastname as clastname, sp.email as cemail"; $sql .= " FROM ".MAIN_DB_PREFIX."societe AS s"; +if ($targettype == 'contacts') $sql.= ", ".MAIN_DB_PREFIX."socpeople as sp"; $sql .= ", ".MAIN_DB_PREFIX."contrat AS c"; $sql .= ", ".MAIN_DB_PREFIX."contratdet AS cd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product"; -$sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5"; +$sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut < 5"; +if (is_numeric($duration_value2)) $sql.= " AND cd.date_fin_validite >= '".$db->idate(dol_time_plus_duree($now, $duration_value2, "d"))."'"; +if (is_numeric($duration_value)) $sql.= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'"; +if ($targettype == 'contacts') $sql.= " AND s.rowid = sp.fk_soc"; +$sql.= " ORDER BY"; +if ($targettype == 'contacts') $sql.= " sp.email, sp.rowid,"; +$sql.= " s.email ASC, s.rowid ASC, cd.date_fin_validite ASC"; // Order by email to allow one message per email -if (is_numeric($duration_value)) $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'"; - -$sql .= " ORDER BY cd.date_fin_validite ASC, s.rowid ASC"; - -print $sql; +//print $sql; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - $oldemail = 'none'; $oldlang=''; + $oldemail = 'none'; $oldsid = 0; $oldcid = 0; $oldlang=''; $total = 0; $foundtoprocess = 0; - print "We found ".$num." couples (services to expire - customer) qualified\n"; - dol_syslog("We found ".$num." couples (services to expire - customer) qualified"); + $trackthirdpartiessent = array(); + + print "We found ".$num." couples (services to expire-".$targettype.") qualified\n"; + dol_syslog("We found ".$num." couples (services to expire-".$targettype.") qualified"); $message=''; if ($num) @@ -104,25 +115,40 @@ if ($resql) { $obj = $db->fetch_object($resql); - if (($obj->email <> $oldemail) || $oldemail == 'none') + $newemail=empty($obj->cemail)?$obj->email:$obj->cemail; + + // Check if this record is a break after previous one + $startbreak=false; + if ($newemail <> $oldemail || $oldemail == 'none') $startbreak=true; + if ($obj->sid && $obj->sid <> $oldsid) $startbreak=true; + if ($obj->cid && $obj->cid <> $oldcid) $startbreak=true; + + if ($startbreak) { - // Break onto sales representative (new email or uid) - if (dol_strlen($oldemail) && $oldemail != 'none') + // Break onto sales representative (new email or cid) + if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { - envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldcustomer,$duration_value); + envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldtarget,$duration_value); + $trackthirdpartiessent[$oldsid.'|'.$oldemail]='contact id '.$oldcid; } else { - if ($oldemail != 'none') print "- No email sent for ".$oldcustomer.", total: ".$total."\n"; + if ($oldemail != 'none') + { + if (empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) print "- No email sent for '".$oldtarget."', total: ".$total."\n"; + else print "- No email sent for '".$oldtarget."', total: ".$total." (already sent to ".$trackthirdpartiessent[$oldsid.'|'.$oldemail].")\n"; + } } - $oldemail = $obj->email; + $oldemail = $newemail; + $oldsid = $obj->sid; + $oldcid = $obj->cid; $oldlang = $obj->lang; - $oldcustomer=$obj->name; + $oldtarget=(empty($obj->cfirstname) && empty($obj->clastname))?$obj->name:($obj->clastname." ".$obj->cfirstname); $message = ''; - $total = 0; + $total = 0; $foundtoprocess = 0; - $customer=$obj->name; - if (empty($obj->email)) print "Warning: Customer ".$customer." has no email. Notice disabled.\n"; + $target=(empty($obj->cfirstname) && empty($obj->clastname))?$obj->name:($obj->clastname." ".$obj->cfirstname); + //if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n"; } // Define line content @@ -131,18 +157,21 @@ if ($resql) $outputlangs->load("bills"); $outputlangs->load("main"); $outputlangs->load("contracts"); + $outputlangs->load("products"); - if (dol_strlen($oldemail)) + if (dol_strlen($newemail)) { - $message .= $langs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".$obj->label." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency)."), ".$langs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n"; - dol_syslog("email_expire_services_to_customers.php: ".$obj->email); + $message .= $outputlangs->trans("Contract")." ".$obj->ref.": ".$outputlangs->trans("Service")." ".dol_concatdesc($obj->plabel,$obj->description)." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency)."), ".$outputlangs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n"; + dol_syslog("email_expire_services_to_customers.php: ".$newemail." ".$message); $foundtoprocess++; } - print "Service to expire ".$obj->ref.", label ".$obj->label.", due date ".dol_print_date($db->jdate($obj->date_fin_validite),'day')." (linked to company ".$obj->nom.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email."): "; - if (dol_strlen($obj->email)) print "qualified."; + print "Service to expire ".$obj->ref.", label ".dol_concatdesc($obj->plabel,$obj->description).", due date ".dol_print_date($db->jdate($obj->date_fin_validite),'day').", customer id ".$obj->sid." ".$obj->name.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", ":"")."email ".$newemail.", lang ".$outputlangs->defaultlang.": "; + if (dol_strlen($newemail)) print "qualified."; else print "disqualified (no email)."; print "\n"; + unset($outputlangs); + $total += $obj->total_ttc; $i++; @@ -151,13 +180,18 @@ if ($resql) // Si il reste des envois en buffer if ($foundtoprocess) { - if (dol_strlen($oldemail) && $oldemail != 'none') // Break onto email (new email) + if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) // Break onto email (new email) { - envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldcustomer,$duration_value); + envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldtarget,$duration_value); + $trackthirdpartiessent[$oldsid.'|'.$oldemail]='contact id '.$oldcid; } else { - if ($oldemail != 'none') print "- No email sent for ".$oldcustomer.", total: ".$total."\n"; + if ($oldemail != 'none') + { + if (empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) print "- No email sent for '".$oldtarget."', total: ".$total."\n"; + else print "- No email sent for '".$oldtarget."', total: ".$total." (already sent to ".$trackthirdpartiessent[$oldsid.'|'.$oldemail].")\n"; + } } } } @@ -181,15 +215,15 @@ else * Send email * * @param string $mode Mode (test | confirm) - * @param string $oldemail Old email + * @param string $oldemail Target email * @param string $message Message to send * @param string $total Total amount of unpayed invoices * @param string $userlang Code lang to use for email output. - * @param string $oldcustomer Old customer + * @param string $oldtarget Target name * @param int $duration_value duration value * @return int <0 if KO, >0 if OK */ -function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$duration_value) +function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldtarget,$duration_value) { global $conf,$langs; @@ -201,17 +235,20 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura $newlangs->load("contracts"); if ($duration_value) - $title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value); + { + if ($duration_value > 0) $title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value); + else $title=$newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg",$duration_value); + } else $title= $newlangs->transnoentities("ListOfServicesToExpire"); - $subject = "[".(empty($conf->global->MAIN_APPLICATION_TITLE)?'Dolibarr':$conf->global->MAIN_APPLICATION_TITLE)."] ".$title; + $subject = (empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT)?$title:$conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT); $sendto = $oldemail; $from = $conf->global->MAIN_MAIL_EMAIL_FROM; $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $msgishtml = -1; - print "- Send email for ".$oldcustomer."(".$oldemail."), total: ".$total."\n"; + print "- Send email to '".$oldtarget."' (".$oldemail."), total: ".$total."\n"; dol_syslog("email_expire_services_to_customers.php: send mail to ".$oldemail); $usehtml=0; @@ -227,10 +264,9 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura { $allmessage.= "Dear customer".($usehtml?"
\n":"\n").($usehtml?"
\n":"\n"); $allmessage.= "Please, find a summary of the services contracted by you that are about to expire.".($usehtml?"
\n":"\n").($usehtml?"
\n":"\n"); - $allmessage.= "Note: This list contains only services to expire.".($usehtml?"
\n":"\n").($usehtml?"
\n":"\n"); } $allmessage.= $message.($usehtml?"
\n":"\n"); - $allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"
\n":"\n"); + //$allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"
\n":"\n"); if (! empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER)) { $allmessage.=$conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER; @@ -271,6 +307,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura $result=1; } + unset($newlangs); if ($result) { return 1; diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index 7fded53a9f7..76489bebcf2 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -38,7 +38,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') { if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm'))) { - print "Usage: $script_file [test|confirm] [delay]\n"; + print "Usage: $script_file (test|confirm) [delay]\n"; print "\n"; print "Send an email to remind all contracts services to expire, to users that are sale representative for.\n"; print "If you choose 'test' mode, no emails are sent.\n"; @@ -71,20 +71,18 @@ dol_syslog($script_file." launched with arg ".join(',',$argv)); $now=dol_now('tzserver'); $duration_value=isset($argv[2])?$argv[2]:'none'; -print $script_file." launched with mode ".$mode.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n"; +print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n"; if ($mode != 'confirm') $conf->global->MAIN_DISABLE_ALL_MAILS=1; -$sql = "SELECT DISTINCT s.nom, c.ref, cd.date_fin_validite, cd.total_ttc, p.label label, c.fk_soc,u.rowid AS uid, u.lastname, u.firstname, u.email, u.lang"; -$sql .= " FROM ".MAIN_DB_PREFIX."societe AS s, ".MAIN_DB_PREFIX."contrat AS c, ".MAIN_DB_PREFIX."contratdet AS cd"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product, ".MAIN_DB_PREFIX."societe_commerciaux AS sc, ".MAIN_DB_PREFIX."user AS u"; - -$sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5"; - +$sql = "SELECT DISTINCT c.ref, c.fk_soc, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel, s.nom as name, s.email, s.default_lang,"; +$sql.= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe AS s, ".MAIN_DB_PREFIX."contrat AS c, ".MAIN_DB_PREFIX."contratdet AS cd"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product, ".MAIN_DB_PREFIX."societe_commerciaux AS sc, ".MAIN_DB_PREFIX."user AS u"; +$sql.= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5"; if (is_numeric($duration_value)) $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'"; - -$sql .= " AND sc.fk_soc = s.rowid AND sc.fk_user = u.rowid"; -$sql .= " ORDER BY cd.date_fin_validite ASC, s.rowid ASC"; +$sql.= " AND sc.fk_soc = s.rowid AND sc.fk_user = u.rowid"; +$sql .= " ORDER BY u.email ASC, s.rowid ASC, c.ref ASC"; // Order by email to allow one message per email //print $sql; $resql=$db->query($sql); @@ -131,19 +129,23 @@ if ($resql) $outputlangs->setDefaultLang(empty($obj->lang)?$langs->defaultlang:$obj->lang); // By default language of sale representative $outputlangs->load("bills"); $outputlangs->load("main"); + $outputlangs->load("contracts"); + $outputlangs->load("products"); if (dol_strlen($obj->email)) { - $message .= $langs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".$obj->label." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency).") ".$obj->nom.", ".$langs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n"; + $message .= $outputlangs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".dol_concatdesc($obj->plabel,$obj->description)." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency).") ".$obj->name.", ".$outputlangs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n"; dol_syslog("email_expire_services_to_representatives.php: ".$obj->email); $foundtoprocess++; } - print "Service to expire ".$obj->ref.", label ".$obj->label.", due date ".dol_print_date($db->jdate($obj->date_fin_validite),'day')." (linked to company ".$obj->nom.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email."): "; + print "Service to expire ".$obj->ref.", label ".dol_concatdesc($obj->plabel,$obj->description).", due date ".dol_print_date($db->jdate($obj->date_fin_validite),'day')." (linked to company ".$obj->name.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email."): "; if (dol_strlen($obj->email)) print "qualified."; else print "disqualified (no email)."; print "\n"; - $total += $obj->total_ttc; + unset($outputlangs); + + $total += $obj->total_ttc; $i++; } @@ -200,11 +202,14 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta $newlangs->load("contracts"); if ($duration_value) - $title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value); + { + if ($duration_value > 0) $title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value); + else $title=$newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg",$duration_value); + } else $title= $newlangs->transnoentities("ListOfServicesToExpire"); - $subject = "[".(empty($conf->global->MAIN_APPLICATION_TITLE)?'Dolibarr':$conf->global->MAIN_APPLICATION_TITLE)."] ".$title; + $subject = (empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT)?$title:$conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT); $sendto = $oldemail; $from = $conf->global->MAIN_MAIL_EMAIL_FROM; $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; @@ -225,7 +230,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta else { $allmessage.= $title.($usehtml?"
\n":"\n").($usehtml?"
\n":"\n"); - $allmessage.= "Note: This list contains only services of contracts for third parties you are linked to as a sale representative.".($usehtml?"
\n":"\n").($usehtml?"
\n":"\n"); + $allmessage.= $newlangs->transnoentities("NoteListOfYourExpiredServices").($usehtml?"
\n":"\n").($usehtml?"
\n":"\n"); } $allmessage.= $message.($usehtml?"
\n":"\n"); $allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"
\n":"\n"); diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index fbd7bf7b466..52bc8bd1442 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -160,7 +160,7 @@ if ($resql) dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message); $foundtoprocess++; } - print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." customer id ".$obj->sid." ".$obj->name.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.",":"")." email ".$newemail." lang ".$outputlangs->defaultlang.": "; + print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day').", customer id ".$obj->sid." ".$obj->name.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", ":"")."email ".$newemail.", lang ".$outputlangs->defaultlang.": "; if (dol_strlen($newemail)) print "qualified."; else print "disqualified (no email)."; print "\n"; diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index e3b23a932d5..e83dbe5b795 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -38,7 +38,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') { if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm'))) { - print "Usage: $script_file [test|confirm] [delay]\n"; + print "Usage: $script_file (test|confirm) [delay]\n"; print "\n"; print "Send an email to users to remind all unpaid customer invoices user is sale representative for.\n"; print "If you choose 'test' mode, no emails are sent.\n"; @@ -125,7 +125,7 @@ if ($resql) $total = 0; $foundtoprocess = 0; $salerepresentative=dolGetFirstLastname($obj->firstname, $obj->lastname); - if (empty($obj->email)) print "Warning: Sal representative ".$salerepresentative." has no email. Notice disabled.\n"; + if (empty($obj->email)) print "Warning: Sale representative ".$salerepresentative." has no email. Notice disabled.\n"; } // Define line content @@ -140,7 +140,7 @@ if ($resql) dol_syslog("email_unpaid_invoices_to_representatives.php: ".$obj->email); $foundtoprocess++; } - print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." (linked to company ".$obj->name.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email." lang ".$outputlangs->defaultlang."): "; + print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." (linked to company ".$obj->name.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email.", lang ".$outputlangs->defaultlang."): "; if (dol_strlen($obj->email)) print "qualified."; else print "disqualified (no email)."; print "\n"; diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php old mode 100644 new mode 100755 diff --git a/test/phpunit/ScriptsTest.php b/test/phpunit/ScriptsTest.php index 82d6a6c7240..19a10dc526b 100755 --- a/test/phpunit/ScriptsTest.php +++ b/test/phpunit/ScriptsTest.php @@ -151,9 +151,75 @@ class ScriptsTest extends PHPUnit_Framework_TestCase return $result; } + /** + * testCompany + * + * @depends testBank + * @return string + */ + public function testCompany() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /* + $script=dirname(__FILE__).'/../../scripts/company/sync_contacts_dolibarr_2ldap now'; + $result=exec($script, $output, $returnvar); + + print __METHOD__." result=".$result."\n"; + print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." returnvar=".$returnvar."\n"; + $this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.'); + $this->assertEquals($returnvar,255); + */ + return $result; + } + + /** + * testContracts + * + * @depends testCompany + * @return string + */ + public function testContracts() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties'; + $result=exec($script, $output, $returnvar); + print __METHOD__." result=".$result."\n"; + print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." returnvar=".$returnvar."\n"; + $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php thirdparties'); + + $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30'; + $result=exec($script, $output, $returnvar); + print __METHOD__." result=".$result."\n"; + print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." returnvar=".$returnvar."\n"; + $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php contacts'); + + $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30'; + $result=exec($script, $output, $returnvar); + print __METHOD__." result=".$result."\n"; + print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." returnvar=".$returnvar."\n"; + $this->assertEquals($returnvar,0,'email_expire_services_to_representatives.php'); + + return $result; + } + /** * testInvoices * + * @depends testContracts * @return string */ public function testInvoices() @@ -166,11 +232,24 @@ class ScriptsTest extends PHPUnit_Framework_TestCase $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties'; $result=exec($script, $output, $returnvar); - print __METHOD__." result=".$result."\n"; print __METHOD__." output=".join("\n",$output)."\n"; print __METHOD__." returnvar=".$returnvar."\n"; - $this->assertEquals($returnvar,0); + $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); + + $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30'; + $result=exec($script, $output, $returnvar); + print __METHOD__." result=".$result."\n"; + print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." returnvar=".$returnvar."\n"; + $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php contacts'); + + $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties'; + $result=exec($script, $output, $returnvar); + print __METHOD__." result=".$result."\n"; + print __METHOD__." output=".join("\n",$output)."\n"; + print __METHOD__." returnvar=".$returnvar."\n"; + $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); return $result; } From 37e28d844871e10012c7c2770b924c4a798abe7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Jul 2013 13:22:45 +0200 Subject: [PATCH 14/16] Removed key not used --- htdocs/langs/en_US/admin.lang | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b3c8d1c8808..c1386cf33c3 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -984,7 +984,6 @@ ConditionIsCurrently=Condition is currently %s TestNotPossibleWithCurrentBrowsers=Automatic detection not possible YouUseBestDriver=You use driver %s that is best driver available currently. YouDoNotUseBestDriver=You use drive %s but driver %s is recommanded. -SearchProduct=Optimisation recherche produits NbOfProductIsLowerThanNoPb=You have only %s products/services into database. This does not required any particular optimization. SearchOptim=Search optimization YouHaveXProductUseSearchOptim=You have %s product into database. You should add the constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 into Home-Setup-Other, you limit the search to the beginning of strings making possible for database to use index and you should get an immediate response. From 6351c64a627da3b3d05dd18248197a43fc579d24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Jul 2013 13:49:24 +0200 Subject: [PATCH 15/16] Test tx --- htdocs/langs/fr_FR/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 00ff1a85195..cd23d31166f 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -11,7 +11,7 @@ VersionUnknown=Inconnue VersionRecommanded=Recommandé SessionId=ID Session SessionSaveHandler=Modalité de sauvegarde des sessions -SessionSavePath=Emplacement sauvegarde sessions +SessionSavePath=Emplacement de sauvegarde sessions PurgeSessions=Purge des sessions # ConfirmPurgeSessions=Do you really want to purge all sessions ? This will disconnect every user (except yourself). NoSessionListWithThisHandler=Le gestionnaire de session configuré pour votre PHP ne permet pas de lister les sessions en cours From 68e13b09e950454bf75e2e868a6d863ef5422987 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 Jul 2013 14:11:58 +0200 Subject: [PATCH 16/16] Enhance tx tool. --- dev/translation/txpush.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dev/translation/txpush.sh b/dev/translation/txpush.sh index 3c4aa8fd2a6..a591082d11b 100755 --- a/dev/translation/txpush.sh +++ b/dev/translation/txpush.sh @@ -4,13 +4,16 @@ # # Laurent Destailleur - eldy@users.sourceforge.net #------------------------------------------------------ -# Usage: txpush.sh [all|xx_XX] +# Usage: txpush.sh (source|all|xx_XX) [-r dolibarr.file] [-f] #------------------------------------------------------ # Syntax if [ "x$1" = "x" ] then - echo "Usage: txpush.sh (source|all|xx_XX) [-r dolibarr.file]" + echo "This push local files to transifex." + echo "Note: If you push a langauge file (not source), file will be skipped if transifex file is newer." + echo " Using -f will overwrite translation but not memory." + echo "Usage: txpush.sh (source|all|xx_XX) [-r dolibarr.file] [-f]" exit fi @@ -28,7 +31,7 @@ then echo "tx push -s $2 $3" tx push -s $2 $3 else - echo "tx push -t -l $1 $2 $3" - tx push -t -l $1 $2 $3 + echo "tx push -t -l $1 $2 $3 $4" + tx push -t -l $1 $2 $3 $4 fi fi