diff --git a/ChangeLog b/ChangeLog index 2e60a9f4f76..60e7c871cf3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,37 +144,6 @@ For users: - Fix: [ bug #972 ] Auto completion contact field do not take account the min caract number before search - Fix : [ bug #971 ] html.form.class.php select_contact with autocomplete do not exclude id from exclude array -For translators: -- Update language files. - -For developers: -- System of menu managers has been rewritten to reduce code to do same things. -- An external module can force its theme. -- Add function dol_set_focus('#xxx'). -- A mymodule can bring its own core/modules/mymodule/modules_mymodule.php file. -- Removed some not used libraries. -- More web services. -- Renamed some database fields, code variables and parameters from french to english. -- First change to manage margins on contracts. -- Add hook getFormMail. -- Function plimit of databases drivers accept -1 as value (it means default value set - into conf->liste_limit). -- New: Add option dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, - dol_no_mouse_hover and dol_use_jmobile onto login page (to support different terminal). -- New: dol_syslog method accept a suffix to use different log files for log. -- New: Type of fields are received by export format handlers. -- New: when adding an action, we can define a free code to tag it for a specific need. -- New: Enhance Dolibarr migration process to include migration script of external - modules. -- New: [ task #811 ] Uniformanize note field. - - -WARNING: If you used external modules, some of them may need to be upgraded due to: -- Fields of classes were renamed to be normalized (nom, prenom, cp, ville, adresse, tel - were renamed into lastname, firstname, zip, town, address, phone). - This may also be true for some fields into web services. -- If module use hook pdf_writelinedesc, module may have to add return 1 at end of - function to keep same behaviour. ***** ChangeLog for 3.3.4 compared to 3.3.3 ***** 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 diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index fd11266b74f..d0d21e43e64 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'); @@ -536,4 +536,4 @@ print ''; llxFooter(); $db->close(); -?> \ No newline at end of file +?> diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 3cc5824ddc5..30aced500d7 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); @@ -1092,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,"; @@ -1121,7 +1123,7 @@ else $total = 0; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -1236,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); } @@ -1312,6 +1306,7 @@ else } print "
'.$langs->trans("Service").''.$langs->trans("ServiceNb",$cursorline).''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").'
'; @@ -1293,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"; /* @@ -1521,13 +1516,14 @@ else print ''; } - print '
 
 
'; + //print ''; // Form to add new line if ($user->rights->contrat->creer && ($object->statut >= 0)) diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index 2042b5c45f7..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 c.rowid = '".$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"; 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 diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index 8f37976f3b1..245632d55f2 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -538,7 +538,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); diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 5f4e7c601bf..ce64f9e660d 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -321,17 +321,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 '; @@ -355,7 +375,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) { @@ -390,7 +410,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) { 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.= ''; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 6ba325f8e8e..97fb4a8cc9a 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/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. 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/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 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/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); 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); 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; }