diff --git a/ChangeLog b/ChangeLog index cd52ecc34be5fb559c0200ba8ee89862aceffa6c..1fee8521e36c99e2c11dea72241482ea20a42f5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,7 +16,9 @@ For users: - New: [ task #901 ] Add Extrafeild on Fiche Inter. - New: Show process id in all command line scripts. - New: Module mailman can subscribe/unsubscribe to ML according to categories or type of member. -- New: New: Add object_hour as substitution tag for opendocument generation. +- New: Add object_hour as substitution tag for opendocument generation. +- New: Add option MEMBER_PAYONLINE_SENDEMAIL to send email when paypal or paybox payment is done. +- New: Implement same rule for return value of all command line scripts (0 when success, <>0 if error). For translators: - Normalized sort order of all languages files with english ref file. diff --git a/dev/skeletons/skeleton_script.php b/dev/skeletons/skeleton_script.php index 9eb17bbbaaffc48eb6369a55cdcfb37baf60a7d6..4f8eb20cb6bb4ecbb3fd02971b3985a40e2aa56e 100644 --- a/dev/skeletons/skeleton_script.php +++ b/dev/skeletons/skeleton_script.php @@ -31,7 +31,7 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } // Global variables @@ -60,7 +60,7 @@ $user->getrights(); print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; if (! isset($argv[1])) { // Check parameters print "Usage: ".$script_file." param1 param2 ...\n"; - exit; + exit(-1); } print '--- start'."\n"; print 'Argument 1='.$argv[1]."\n"; @@ -163,5 +163,5 @@ else $db->close(); // Close $db database opened handler -return $error; -?> +exit($error); +?> \ No newline at end of file diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0ed4a1ad80aa47fe463e6aedf5e4c6ba122dbf9a..d02d0d56789d7394f7511cd3aeda23f032878955 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1307,31 +1307,25 @@ class Form } if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype; // Add criteria on ref/label - if ($filterkey && $filterkey != '') + if ($filterkey != '') { - $sql.=" AND ("; - if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) // Can use index + $sql.=' AND ('; + $prefix=empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)?'%':''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on + // For natural search + $scrit = explode(' ', $filterkey); + $i=0; + if (count($scrit) > 1) $sql.="("; + foreach ($scrit as $crit) { - $sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'"; - if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$filterkey."%'"; + if ($i > 0) $sql.=" AND "; + $sql.="(p.ref LIKE '".$prefix.$crit."%' OR p.label LIKE '".$prefix.$crit."%'"; + if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '".$prefix.$crit."%'"; $sql.=")"; + $i++; } - else - { - // For natural search - $scrit = explode(' ', $filterkey); - foreach ($scrit as $crit) { - $sql.=" AND (p.ref LIKE '%".$crit."%' OR p.label LIKE '%".$crit."%'"; - if (! empty($conf->global->MAIN_MULTILANGS)) $sql.=" OR pl.label LIKE '%".$crit."%'"; - $sql.=")"; - } - } - - if (! empty($conf->barcode->enabled)) - { - $sql .= " OR p.barcode LIKE '".$filterkey."'"; - } - $sql.=")"; + if (count($scrit) > 1) $sql.=")"; + if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$prefix.$filterkey."%'"; + $sql.=')'; } $sql.= $db->order("p.ref"); $sql.= $db->plimit($limit); @@ -1658,21 +1652,23 @@ class Form if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype; if (! empty($filtre)) $sql.=" ".$filtre; // Add criteria on ref/label - if ($filterkey && $filterkey != '') + if ($filterkey != '') { - if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) - { - $sql.=" AND (pfp.ref_fourn LIKE '".$filterkey."%' OR p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%')"; - } - else - { - $sql.=" AND (pfp.ref_fourn LIKE '%".$filterkey."%' OR p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%')"; - } - - if (! empty($conf->barcode->enabled)) - { - $sql .= " OR p.barcode LIKE '".$filterkey."'"; - } + $sql.=' AND ('; + $prefix=empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)?'%':''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on + // For natural search + $scrit = explode(' ', $filterkey); + $i=0; + if (count($scrit) > 1) $sql.="("; + foreach ($scrit as $crit) + { + if ($i > 0) $sql.=" AND "; + $sql.="(pfp.ref_fourn LIKE '".$prefix.$crit."%' OR p.ref LIKE '".$prefix.$crit."%' OR p.label LIKE '".$prefix.$crit."%')"; + $i++; + } + if (count($scrit) > 1) $sql.=")"; + if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$prefix.$filterkey."%'"; + $sql.=')'; } $sql.= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index 88e4057428090d133494f0879e6c4b219f95a092..6ec3ecae8bf8bfc25d95943ebca102b76f184eb7 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> - * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com> @@ -24,10 +24,11 @@ /** * \file htdocs/mailmanspip/class/mailmanspip.class.php * \ingroup member - * \brief File of class to manage members of a foundation + * \brief File of class to manage mailman and spip actions */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 3fed5d5152ca7afed4b413087f38c94d2a00afc1..61ef111bddfad6af77bb590d9a447c9963b05b22 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -157,11 +157,11 @@ else $form = new Form($db); if (empty($mode) || $mode == 1) { - $arrayresult=$form->select_produits_do("",$htmlname,$type,"",$price_level,$searchkey,$status,2,$outjson); + $arrayresult=$form->select_produits_list("",$htmlname,$type,"",$price_level,$searchkey,$status,2,$outjson); } elseif ($mode == 2) { - $arrayresult=$form->select_produits_fournisseurs_do($socid,"",$htmlname,$type,"",$searchkey,$status,$outjson); + $arrayresult=$form->select_produits_fournisseurs_list($socid,"",$htmlname,$type,"",$searchkey,$status,$outjson); } $db->close(); diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php index c4457ff4d930ec288a639c946463beeac7300dd9..de05e2a4ac16f51a1169dd655d0444a27eb8cb9e 100644 --- a/htdocs/public/paybox/paymentko.php +++ b/htdocs/public/paybox/paymentko.php @@ -64,7 +64,7 @@ dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); // Send an email -if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fulltag)) +if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=/',$fulltag)) { $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; $from=$conf->global->MAILING_EMAIL_FROM; @@ -79,11 +79,11 @@ if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fu $result=$mailfile->sendfile(); if ($result) { - dol_syslog("EMail sent to ".$sendto); + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox'); } else { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR); + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox'); } } diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php index b8940fa1a323750d4529f893188b6e6874ff7658..6af144c353ce052f205c951c6be7ec582bf9b221 100644 --- a/htdocs/public/paybox/paymentok.php +++ b/htdocs/public/paybox/paymentok.php @@ -94,7 +94,7 @@ dol_syslog("Call newpaymentok with token=".$token." paymentType=".$paymentType." */ // Send an email -if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fulltag)) +if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=/',$fulltag)) { $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; $from=$conf->global->MAILING_EMAIL_FROM; @@ -109,11 +109,11 @@ if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fu $result=$mailfile->sendfile(); if ($result) { - dol_syslog("EMail sent to ".$sendto); + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paybox'); } else { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR); + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paybox'); } } diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php index 21d93f3eaa15033c5d0261bed91b93840f5b0e69..69fa80eb9cbdd6c7fdbadca33748bdbf0d8eabdb 100755 --- a/htdocs/public/paypal/paymentko.php +++ b/htdocs/public/paypal/paymentko.php @@ -72,7 +72,7 @@ dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal'); // Send an email -if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fulltag)) +if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=/',$fulltag)) { $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; $from=$conf->global->MAILING_EMAIL_FROM; @@ -87,11 +87,11 @@ if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fu $result=$mailfile->sendfile(); if ($result) { - dol_syslog("EMail sent to ".$sendto); + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal'); } else { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR); + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal'); } } diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index e4ea8a92095c9d2c139d0a59802903ebe537c4e2..5e822fd75d15e649473607f1064eabf7fbd8bfe1 100755 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -127,11 +127,11 @@ if ($PAYPALTOKEN) // From env $ipaddress = $_SESSION['ipaddress']; - dol_syslog("Call newpaymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag); + dol_syslog("Call newpaymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_paypal'); // Send an email - if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=',$fulltag)) + if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=/',$fulltag)) { $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; $from=$conf->global->MAILING_EMAIL_FROM; @@ -146,11 +146,11 @@ if ($PAYPALTOKEN) $result=$mailfile->sendfile(); if ($result) { - dol_syslog("EMail sent to ".$sendto); + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal'); } else { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR); + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal'); } } @@ -158,11 +158,11 @@ if ($PAYPALTOKEN) // Validate record if (! empty($paymentType)) { - dol_syslog("We call GetExpressCheckoutDetails"); + dol_syslog("We call GetExpressCheckoutDetails", LOG_DEBUG, 0, '_paypal'); $resArray=getDetails($token); //var_dump($resarray); - dol_syslog("We call DoExpressCheckoutPayment token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag); + dol_syslog("We call DoExpressCheckoutPayment token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_paypal'); $resArray=confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag); $ack = strtoupper($resArray["ACK"]); diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index 8ba7f665f604155c601a41877a86a61d0ee06c4f..18aa26b824691d6bfa89d1ceef6ae9700800b174 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -30,7 +30,7 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } require_once($path."../../htdocs/master.inc.php"); @@ -62,8 +62,8 @@ $error=0; print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; if (! isset($argv[3]) || ! $argv[3]) { - print "Usage: $script_file bank_ref bank_receipt_number (csv|tsv|excel|excel2007) [lang=xx_XX]\n"; - exit; + print "Usage: ".$script_file." bank_ref bank_receipt_number (csv|tsv|excel|excel2007) [lang=xx_XX]\n"; + exit(-1); } $bankref=$argv[1]; $num=$argv[2]; @@ -120,7 +120,7 @@ $result=$acct->fetch('',$bankref); if ($result <= 0) { print "Failed to find bank account with ref ".$bankref.".\n"; - exit; + exit(-1); } else { @@ -135,7 +135,7 @@ $classname = "Export".$model; if (! dol_is_file($dir.$file)) { print "No driver to export with format ".$model."\n"; - exit; + exit(-1); } require_once $dir.$file; $objmodel = new $classname($db); @@ -247,7 +247,7 @@ if ($resql) else { dol_print_error($db); - exit; + exit(-1); } $total = $balancebefore[$objp->num_releve]; @@ -439,5 +439,5 @@ else $db->close(); -return $ret; +exit($ret); ?> \ No newline at end of file diff --git a/scripts/company/export-contacts-xls-example.php b/scripts/company/export-contacts-xls-example.php index e3b4830f1800a743f8ab431d12542562ff0e56c5..5e7b6404994aa70b0eeaa0e7247fbac9a023b851 100644 --- a/scripts/company/export-contacts-xls-example.php +++ b/scripts/company/export-contacts-xls-example.php @@ -31,12 +31,12 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[1]) || ! $argv[1]) { print "Usage: $script_file now\n"; - exit; + exit(-1); } $now=$argv[1]; @@ -120,4 +120,5 @@ $objWriter->save($fname); print 'File '.$fname.' was generated.'."\n"; +exit(0); ?> diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index 26228df1ad8a9225062520d17392798b3f96696b..edede8d3ba214320d412bb04fe262e2aff8d0e21 100644 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -31,12 +31,12 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[1]) || ! $argv[1]) { print "Usage: $script_file now\n"; - exit; + exit(-1); } $now=$argv[1]; @@ -87,7 +87,7 @@ $input = trim(fgets(STDIN)); if (! $conf->global->LDAP_CONTACT_ACTIVE) { print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); - exit 1; + exit(-1); } */ @@ -147,5 +147,5 @@ else dol_print_error($db); } -return $error; +exit($error); ?> diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index d60d5a86a5a0f66077e423b4e93fac9842215203..b503c0eaca281a549f2660ed174eb05d65a364a9 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -33,7 +33,7 @@ $path=dirname(__FILE__).'/'; $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm'))) @@ -43,7 +43,7 @@ if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm print "Send an email to customers to remind all all contracts services to expire.\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"; - exit; + exit(-1); } $mode=$argv[1]; @@ -157,11 +157,15 @@ if ($resql) { print "No unpaid invoices found\n"; } + + exit(0); } else { dol_print_error($db); dol_syslog("email_expire_services_to_customers.php: Error"); + + exit(-1); } @@ -269,5 +273,4 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura } } - -?> +?> \ No newline at end of file diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index e570145815295e11b316042d0dd75ec1d5171b25..1a352f138aa8cade250494ee0722b740c6a9366b 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -33,7 +33,7 @@ $path=dirname(__FILE__).'/'; $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm'))) @@ -43,7 +43,7 @@ if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm 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"; print "If you add a delay (nb of days), only services with expired date < today + delay are included.\n"; - exit; + exit(-1); } $mode=$argv[1]; @@ -154,14 +154,18 @@ if ($resql) } } else - { + { print "No services to expire (for companies linked to a particular commercial dolibarr user) found\n"; } + + exit(0); } else { dol_print_error($db); dol_syslog("email_expire_services_to_representatives.php: Error"); + + exit(-1); } @@ -268,5 +272,4 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta } } - -?> +?> \ No newline at end of file diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 63836a979f46196c8ea960ae267f2dca3055e314..3cdf74936635f2cab1ae12fcc20bf6c93f3eedb3 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -1,7 +1,8 @@ #!/usr/bin/php <?php -/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr - * Copyright (C) 2013 Florian Henry <forian.henry@open-cocnept.pro +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro + * Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,18 +39,18 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[1]) || ! $argv[1]) { print "Usage: ".$script_file." securitykey userlogin cronjobid(optional)\n"; - exit; + exit(-1); } $key=$argv[1]; if (! isset($argv[2]) || ! $argv[2]) { print "Usage: ".$script_file." securitykey userlogin cronjobid(optional)\n"; - exit; + exit(-1); } else { $userlogin=$argv[2]; } @@ -75,7 +76,7 @@ print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; if ($key != $conf->global->CRON_KEY) { print "Error: securitykey is wrong\n"; - exit; + exit(-1); } // Check user login @@ -85,7 +86,7 @@ if ($result < 0) { echo "User Error: ".$user->error; dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); - exit; + exit(-1); } else { @@ -93,7 +94,7 @@ else { echo " User user login: ".$userlogin." do not exists"; dol_syslog(" User user login:".$userlogin." do not exists", LOG_ERR); - exit; + exit(-1); } } @@ -116,7 +117,7 @@ if ($result<0) { echo "Error: ".$object->error; dol_syslog("cron_run_jobs.php:: fetch Error ".$object->error, LOG_ERR); - exit; + exit(-1); } // current date @@ -135,14 +136,14 @@ if(is_array($object->lines) && (count($object->lines)>0)) if ($result<0) { echo "Error:".$cronjob->error; dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); - exit; + exit(-1); } // execute methode $result=$cronjob->run_jobs($userlogin); if ($result<0) { echo "Error:".$cronjob->error; dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR); - exit; + exit(-1); } // we re-program the next execution and stores the last execution time for this job @@ -150,7 +151,7 @@ if(is_array($object->lines) && (count($object->lines)>0)) if ($result<0) { echo "Error:".$cronjob->error; dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR); - exit; + exit(-1); } } @@ -158,4 +159,6 @@ if(is_array($object->lines) && (count($object->lines)>0)) } $db->close(); + +exit(0); ?> \ No newline at end of file diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 33b1160ef7ee88e662d437d43dedad8264ba2ebd..31cb141835cd8ab552a1564567495d7379510639 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -32,12 +32,12 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[1]) || ! $argv[1]) { print "Usage: ".$script_file." (ID_MAILING|all)\n"; - exit; + exit(-1); } $id=$argv[1]; diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index cfe253a86216c78206f042958b4cc8f024edcad5..0178d95d0b6b8707c96dff64231f2a02eb40bc9b 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -33,7 +33,7 @@ $path=dirname(__FILE__).'/'; $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[2]) || ! $argv[2] || ! in_array($argv[1],array('test','confirm')) || ! in_array($argv[2],array('thirdparties','contacts'))) @@ -43,7 +43,7 @@ if (! isset($argv[2]) || ! $argv[2] || ! in_array($argv[1],array('test','confirm print "Send an email to customers to remind all unpaid customer invoices.\n"; print "If you choose 'test' mode, no emails are sent.\n"; print "If you add a delay (nb of days), only invoice with due date < today + delay are included.\n"; - exit; + exit(-1); } $mode=$argv[1]; $targettype=$argv[2]; @@ -187,14 +187,18 @@ if ($resql) } } else - { + { print "No unpaid invoices found\n"; } + + exit(0); } else { dol_print_error($db); dol_syslog("email_unpaid_invoices_to_customers.php: Error"); + + exit(-1); } @@ -297,5 +301,4 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldtarget) } } - ?> diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index f190725a458198bff8fc607aef651e2706bbdeae..ef5935b7946dd5c20c6de7b7e188a8fa287adaba 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -33,7 +33,7 @@ $path=dirname(__FILE__).'/'; $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm'))) @@ -43,7 +43,7 @@ if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm 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"; print "If you add a delay (nb of days), only invoice with due date < today + delay are included.\n"; - exit; + exit(-1); } $mode=$argv[1]; @@ -164,14 +164,18 @@ if ($resql) } } else - { + { print "No unpaid invoices (for companies linked to a particular commercial dolibarr user) found\n"; } + + exit(0); } else { dol_print_error($db); dol_syslog("email_unpaid_invoices_to_representatives.php: Error"); + + exit(-1); } @@ -272,5 +276,4 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta } } - ?> diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index a53e8940361174c52fe81a08e3abe6df681dfa9b..eeb5407b37be044b89a6f9b9dde66911d5d2e75a 100755 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -30,7 +30,7 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } // Include Dolibarr environment @@ -62,7 +62,7 @@ print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; if (! isset($argv[1])) { usage(); - exit; + exit(-1); } $diroutputpdf=$conf->facture->dir_output . '/temp'; @@ -125,7 +125,7 @@ foreach ($argv as $key => $value) if (empty($paymentdateafter) || empty($paymentdatebefore)) { print 'Error: Bad date format'."\n"; - exit; + exit(-1); } print 'Rebuild PDF for invoices with at least one payment between '.dol_print_date($paymentdateafter,'day')." and ".dol_print_date($paymentdatebefore,'day').".\n"; } @@ -151,7 +151,7 @@ foreach ($argv as $key => $value) if ($result <= 0) { print 'Error: Bank account with ref "'.$paymentonbankref.'" not found'."\n"; - exit; + exit(-1); } $paymentonbankid=$bankaccount->id; print 'Rebuild PDF for invoices with at least one payment on financial account '.$bankaccount->ref."\n"; @@ -185,7 +185,7 @@ foreach ($argv as $key => $value) if (! $found && preg_match('/filter=/i',$value)) { usage(); - exit; + exit(-1); } } @@ -193,18 +193,18 @@ foreach ($argv as $key => $value) if (empty($option) && count($filter) <= 0) { usage(); - exit; + exit(-1); } // Check if there is no uncompatible choice if (in_array('payments',$filter) && in_array('nopayment',$filter)) { usage(); - exit; + exit(-1); } if (in_array('bank',$filter) && in_array('nopayment',$filter)) { usage(); - exit; + exit(-1); } @@ -229,7 +229,7 @@ else $db->close(); -return $error; +exit($error); diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index 476837aa309c23150a74b1e00a13247855a6cfca..31df696aedf4723cc018c9b1be539b2daa804cd5 100755 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -31,7 +31,7 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } require_once($path."../../htdocs/master.inc.php"); @@ -55,7 +55,7 @@ print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; if (! isset($argv[1]) || ! $argv[1]) { print "Usage: $script_file now\n"; - exit; + exit(-1); } $now=$argv[1]; @@ -88,7 +88,7 @@ $input = trim(fgets(STDIN)); if (! $conf->global->LDAP_MEMBER_ACTIVE) { print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); - exit 1; + exit(-1); } */ @@ -115,13 +115,13 @@ if ($resql) if ($result < 0) { dol_print_error($db,$member->error); - exit; + exit(-1); } $result=$member->fetch_subscriptions(); if ($result < 0) { dol_print_error($db,$member->error); - exit; + exit(-1); } print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->getFullName($langs); @@ -158,5 +158,5 @@ else dol_print_error($db); } -return $error; +exit($error); ?> diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index 1b4fc64457ce9724a60158d558dcb420df9552cf..52735e2a30e405eb1da55a3f6309120aeb60fdff 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -31,7 +31,7 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } require_once($path."../../htdocs/master.inc.php"); @@ -98,7 +98,7 @@ print "***** $script_file ($version) *****\n"; if (! isset($argv[2]) || ! is_numeric($argv[2])) { print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [ldapserverhost]\n"; - exit; + exit(-1); } $typeid=$argv[2]; if ($argv[1] == 'commitiferror') $forcecommit=1; @@ -128,12 +128,12 @@ print "\n"; if (empty($conf->global->LDAP_MEMBER_DN)) { print $langs->trans("Error").': '.$langs->trans("LDAP setup for members not defined inside Dolibarr")."\n"; - exit(1); + exit(-1); } if ($typeid <= 0) { print $langs->trans("Error").': Parameter id_member_type is not a valid ref of an existing member type'."\n"; - exit(2); + exit(-2); } @@ -173,7 +173,7 @@ if ($resql) else { dol_print_error($db); - exit; + exit(-1); } @@ -326,7 +326,7 @@ else } -return $error; +exit($error); /** @@ -340,4 +340,4 @@ function dolValidElement($element) return (trim($element) != ''); } -?> +?> \ No newline at end of file diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index 55a40209a9e3ea2e8da22b07447147f002139b10..5ecb9ee209745e94b8e45f9d3b91c6d87182287b 100755 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -31,12 +31,12 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[1]) || ! $argv[1]) { - print "Usage: $script_file now\n"; - exit; + print "Usage: ".$script_file." now\n"; + exit(-1); } $now=$argv[1]; @@ -60,7 +60,7 @@ print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; if (! $conf->global->LDAP_SYNCHRO_ACTIVE) { print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); - exit 1; + exit(-1); } */ @@ -120,5 +120,5 @@ else dol_print_error($db); } -return $error; +exit($error); ?> diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index 0a0107917934fc4090d3e2b2ca2588b6777e20ed..ae8690e39965fbd4fdab34438152c23ae0c73f8f 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -32,7 +32,7 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } require_once($path."../../htdocs/master.inc.php"); @@ -77,7 +77,7 @@ print "***** $script_file ($version) *****\n"; if (! isset($argv[1])) { //print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n"; print "Usage: $script_file (nocommitiferror|commitiferror) [ldapserverhost]\n"; - exit; + exit(-1); } $groupid=$argv[3]; if ($argv[1] == 'commitiferror') $forcecommit=1; @@ -112,7 +112,7 @@ $input = trim(fgets(STDIN)); if (empty($conf->global->LDAP_GROUP_DN)) { print $langs->trans("Error").': '.$langs->trans("LDAP setup for groups not defined inside Dolibarr"); - exit(1); + exit(-1); } @@ -242,7 +242,7 @@ else } -return $error; +exit($error); /** @@ -256,4 +256,4 @@ function dolValidElement($element) return (trim($element) != ''); } -?> +?> \ No newline at end of file diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index c02a676305e3ee6ddbf4e868551297d9eff4956b..9f2dfe5d53b3997b6dde179f776ebf4c1432f76a 100755 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -31,12 +31,12 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } if (! isset($argv[1]) || ! $argv[1]) { print "Usage: $script_file now\n"; - exit; + exit(-1); } $now=$argv[1]; @@ -60,7 +60,7 @@ print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n"; if (! $conf->global->LDAP_SYNCHRO_ACTIVE) { print $langs->trans("LDAPSynchronizationNotSetupInDolibarr"); - exit 1; + exit(-1); } */ @@ -119,5 +119,5 @@ else dol_print_error($db); } -return $error; -?> +exit($error); +?> \ No newline at end of file diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 89bc46134875b09c3f51d80d655c849be37808e3..44ead523fd61c536113fe1966152e4e39ab85714 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -31,7 +31,7 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } require_once($path."../../htdocs/master.inc.php"); @@ -89,7 +89,7 @@ print "***** $script_file ($version) *****\n"; if (! isset($argv[1])) { //print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n"; print "Usage: $script_file (nocommitiferror|commitiferror) [ldapserverhost]\n"; - exit; + exit(-1); } $groupid=$argv[3]; if ($argv[1] == 'commitiferror') $forcecommit=1; @@ -124,7 +124,7 @@ $input = trim(fgets(STDIN)); if (empty($conf->global->LDAP_USER_DN)) { print $langs->trans("Error").': '.$langs->trans("LDAP setup for users not defined inside Dolibarr"); - exit(1); + exit(-1); } @@ -158,7 +158,7 @@ if ($resql) else { dol_print_error($db); - exit; + exit(-1); } @@ -296,7 +296,7 @@ else } -return $error; +exit($error); /** @@ -310,4 +310,4 @@ function dolValidElement($element) return (trim($element) != ''); } -?> +?> \ No newline at end of file diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php index 93e9239ecb7da887625362e0fca23390f42f24b6..2db617e840559205f08e85778f0d28f20cbee845 100644 --- a/scripts/withdrawals/build_withdrawal_file.php +++ b/scripts/withdrawals/build_withdrawal_file.php @@ -31,7 +31,7 @@ $path=dirname(__FILE__).'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; - exit; + exit(-1); } require_once($path."../../htdocs/master.inc.php"); @@ -66,7 +66,7 @@ if (! isset($argv[1])) { // Check parameters print "This script check invoices with a withdrawal request and\n"; print "then create payment and build a withdraw file.\n"; print "Usage: ".$script_file." simu|real\n"; - exit; + exit(-1); } @@ -75,4 +75,6 @@ $result=$withdrawreceipt->create($conf->global->PRELEVEMENT_CODE_BANQUE,$conf->g $db->close(); + +exit(0); ?> diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index b22dd5b1ea294b41bfbb55707578d544046f8341..f5eec24cff8d1c8bc739ffd7d33d15f53d673348 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -159,6 +159,9 @@ class AllTests require_once dirname(__FILE__).'/ImportTest.php'; $suite->addTestSuite('ImportTest'); + require_once dirname(__FILE__).'/ScriptsTest.php'; + $suite->addTestSuite('ScriptsTest'); + require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer $suite->addTestSuite('ModulesTest'); diff --git a/test/phpunit/ScriptsTest.php b/test/phpunit/ScriptsTest.php new file mode 100755 index 0000000000000000000000000000000000000000..d5bda95e2b3cd0ff59c8ccf6ac3884e26d057ec5 --- /dev/null +++ b/test/phpunit/ScriptsTest.php @@ -0,0 +1,178 @@ +<?php +/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * or see http://www.gnu.org/ + */ + +/** + * \file test/phpunit/ScriptsTest.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; + +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) + +if (empty($user->id)) +{ + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class ScriptsTest extends PHPUnit_Framework_TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return SecurityTest + */ + function __construct() + { + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; + } + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + * Init phpunit tests + * + * @return void + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + } + + /** + * End phpunit tests + * + * @return void + */ + protected function tearDown() + { + print __METHOD__."\n"; + } + + /** + * testBank + * + * @return string + */ + public function testBank() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $script=dirname(__FILE__).'/../../scripts/bank/export-bank-receipts.php BANKDUMMY RECEIPTDUMMY excel2007 lang=fr_FR'; + $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; + } + + /** + * testInvoices + * + * @return string + */ + public function testInvoices() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $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); + + return $result; + } +} +?> \ No newline at end of file