From d0f83141fbaa5bb61a43bf803fa5a432eb2e7098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:38:01 +0200 Subject: [PATCH 001/152] FIX: Bad variable usage --- htdocs/accountancy/admin/account.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index c42a8d7079b..340cb3e18d5 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -65,8 +65,7 @@ if ($action == 'delete') { $accounting = new AccountingAccount($db); if ($action == 'disable') { - $accounting = $accounting->fetch($id); - if (! empty($accounting->id)) { + if ($accounting->fetch($id)) { $result = $accounting->account_desactivate($id); } @@ -75,10 +74,7 @@ if ($action == 'disable') { setEventMessage($accounting->error, 'errors'); } } else if ($action == 'enable') { - - $accounting = $accounting->fetch($id); - - if (! empty($accounting->id)) { + if ($accounting->fetch($id)) { $result = $accounting->account_activate($id); } $action = 'update'; @@ -206,4 +202,4 @@ if ($result) { } llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); From bab1dd13e248a08bd01cd9336a7291f2bcfce7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:42:07 +0200 Subject: [PATCH 002/152] FIX: missing extends --- htdocs/accountancy/class/accountingaccount.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 82c3ec3ca10..f91f21343f8 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -26,7 +26,7 @@ /** * Classe permettant la gestion des comptes generaux de compta */ -class AccountingAccount +class AccountingAccount extends CommonObject { var $db; var $id; @@ -426,4 +426,4 @@ class AccountingAccount return - 1; } } -} \ No newline at end of file +} From 7b300b0a9dfdc2d9c852febb6e2c0fb02bd20e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:42:21 +0200 Subject: [PATCH 003/152] FIX: Missing variable declaration --- htdocs/accountancy/class/accountingaccount.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index f91f21343f8..4ecd0b3c8e1 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -107,6 +107,7 @@ class AccountingAccount extends CommonObject { global $conf, $langs; $error = 0; + $now = dol_now(); // Clean parameters if (isset($this->fk_pcg_version)) From b1ad7af527f039c0c4888408c7ae9034f4cbe26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:42:33 +0200 Subject: [PATCH 004/152] FIX: Missing extends --- htdocs/accountancy/class/bookkeeping.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 2788526de05..e9bbc7d5958 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -27,7 +27,7 @@ /** * Class to manage accountancy book keeping */ -class BookKeeping +class BookKeeping extends CommonObject { var $db; var $id; @@ -709,4 +709,4 @@ class BookKeepingLine var $fk_user_author; var $code_journal; var $piece_num; -} \ No newline at end of file +} From 64da1b1dc03326dfcc9785314948a36bd3bc1daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:43:49 +0200 Subject: [PATCH 005/152] FIX: Removed HTML file preventing PHP service --- htdocs/accountancy/customer/index.html | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 htdocs/accountancy/customer/index.html diff --git a/htdocs/accountancy/customer/index.html b/htdocs/accountancy/customer/index.html deleted file mode 100644 index e69de29bb2d..00000000000 From 9a141215bb279e46b7c2fda8c30e13cd489156d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:46:53 +0200 Subject: [PATCH 006/152] FIX: Moved code to where the variable is defined --- htdocs/accountancy/journal/bankjournal.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 82c3a09e20a..ef39e5668a0 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -137,17 +137,18 @@ if ($result) { $tabpay = array (); $tabbq = array (); $tabtp = array (); - $tabcompany[$obj->rowid] = array ( - 'id' => $obj->socid, - 'name' => $obj->name, - 'code_client' => $obj->code_compta - ); $tabtype = array (); $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); + $tabcompany[$obj->rowid] = array ( + 'id' => $obj->socid, + 'name' => $obj->name, + 'code_client' => $obj->code_compta + ); + // Controls $compta_bank = $obj->account_number; if ($obj->label == '(SupplierInvoicePayment)') @@ -580,4 +581,4 @@ if ($action == 'export_csv') { // End of page llxFooter(); } -$db->close(); \ No newline at end of file +$db->close(); From cc68966d7282f17176ce9baf52d188a2d69d72dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:49:07 +0200 Subject: [PATCH 007/152] FIX: Missing declaration --- htdocs/accountancy/journal/purchasesjournal.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index e0c2ceb8e36..09d93d5cd50 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -246,7 +246,9 @@ if ($action == 'export_csv') { header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename=journal_achats.csv'); - + + $companystatic = new Fournisseur($db); + if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert { foreach ( $tabfac as $key => $val ) { @@ -468,4 +470,4 @@ if ($action == 'export_csv') { // End of page llxFooter(); } -$db->close(); \ No newline at end of file +$db->close(); From 332caa2b7124ca6e314d5b119d2ee8676c903504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:51:21 +0200 Subject: [PATCH 008/152] FIX: missing global declaration --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1059d1af07d..50b9a35f4fe 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2768,7 +2768,7 @@ abstract class CommonObject */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf,$langs,$user,$object,$hookmanager; + global $conf, $hookmanager, $inputalsopricewithtax, $langs, $user; print ''; From 852758c81c0bba13e3769804695206884e91e8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:52:22 +0200 Subject: [PATCH 009/152] FIX: Removed concatenation on undeclared variable --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5cf872eb3d8..937f904c512 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1297,7 +1297,7 @@ class Form // Method with no ajax //$out.='
'; - $out.=$this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); + $out=$this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); $out.=''; $assignedtouser=array(); if (!empty($_SESSION['assignedtouser'])) $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true); From 4c7ae3d14b66e836b13b2fd6d11d56bb924127eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:54:04 +0200 Subject: [PATCH 010/152] FIX: Missing parameter declaration --- htdocs/core/lib/accounting.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index e7313c73aee..7b18de022f6 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -25,10 +25,11 @@ /** * Prepare array with list of admin tabs + * @param Object $object Accounting account * * @return array Array of tabs to show */ -function admin_accounting_prepare_head() +function admin_accounting_prepare_head($object) { global $langs, $conf; @@ -189,4 +190,4 @@ function length_exportsage($txt, $len, $end) } } return $res; -} \ No newline at end of file +} From 7c7276b5aaaf3c3dc515f4299e6e2e4b8ee8e892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 11:57:15 +0200 Subject: [PATCH 011/152] FIX: Removed undeclared variable --- htdocs/societe/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 0aa9f0e5979..10d0f69dd8e 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -67,7 +67,7 @@ if (GETPOST("button_removefilter")) } // Customer or supplier selected in drop box $thirdTypeSelect = GETPOST("third_select_id"); -$type_element = GETPOST('type_element')?GETPOST('type_element'):$type_element; +$type_element = GETPOST('type_element')?GETPOST('type_element'):''; $langs->load("companies"); From c7c809a6095ceae7697bfe9b24f6bb7a7fb5fd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 12:02:17 +0200 Subject: [PATCH 012/152] FIX: Wrong type hinting --- .../class/fournisseur.commande.class.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4e8c3a650b0..07964e69d58 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1062,25 +1062,25 @@ class CommandeFournisseur extends CommonOrder * Add order line * * @param string $desc Description - * @param double $pu_ht Unit price - * @param double $qty Quantity - * @param double $txtva Taux tva - * @param double $txlocaltax1 Localtax1 tax - * @param double $txlocaltax2 Localtax2 tax + * @param float $pu_ht Unit price + * @param float $qty Quantity + * @param float $txtva Taux tva + * @param float $txlocaltax1 Localtax1 tax + * @param float $txlocaltax2 Localtax2 tax * @param int $fk_product Id produit * @param int $fk_prod_fourn_price Id supplier price * @param string $fourn_ref Supplier reference - * @param double $remise_percent Remise + * @param float $remise_percent Remise * @param string $price_base_type HT or TTC - * @param double $pu_ttc Unit price TTC + * @param float $pu_ttc Unit price TTC * @param int $type Type of line (0=product, 1=service) * @param int $info_bits More information - * @param int $notrigger Disable triggers - * @param timestamp $date_start Date start of service - * @param timestamp $date_end Date end of service + * @param bool $notrigger Disable triggers + * @param int $date_start Date start of service + * @param int $date_end Date end of service * @return int <=0 if KO, >0 if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $type=0, $info_bits=0, $notrigger=false, $date_start='', $date_end='') + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null) { global $langs,$mysoc; From 3a0d4cd47f139e57d8a9c81db00d4c6ab8b27c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 14:22:22 +0200 Subject: [PATCH 013/152] =?UTF-8?q?FIX:=C2=A0Missing=20visibility=20of=20s?= =?UTF-8?q?tatic=20property?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d5d16efc2e9..c4bb2afcd44 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -54,7 +54,7 @@ class ExtraFields var $error; var $errno; - static $type2label=array( + public static $type2label=array( 'varchar'=>'String', 'text'=>'TextLong', 'int'=>'Int', From 37c0b9606b7c7db25fb714b3ae3b37ae9bb8b573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 14:32:50 +0200 Subject: [PATCH 014/152] FIX: Removed unused variable --- scripts/accountancy/export-thirdpartyaccount.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index 2556457f38e..f1ff769059c 100644 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -164,7 +164,6 @@ if ($resql) { header('Content-Disposition: attachment;filename=export_csv.csv'); $obj = $db->fetch_object($resql); - $var = ! $var; print '"' . $obj->compta . '",'; print '"' . $obj->address . '",'; @@ -237,4 +236,4 @@ if ($resql) { } llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); From 131997eeb8684df3c6012a134ef6cabe064011a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 14:39:17 +0200 Subject: [PATCH 015/152] FIX: Removed undeclared variables --- htdocs/core/modules/action/rapport.pdf.php | 2 +- htdocs/core/modules/cheque/pdf/pdf_blochet.class.php | 2 +- htdocs/core/modules/rapport/pdf_paiement.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index 1f03ea19d62..3bf7eddecce 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -127,7 +127,7 @@ class CommActionRapport $hookmanager=new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters=array('file'=>$file, 'outputlangs'=>$outputlangs); global $action; $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php index 1112150a0e9..c2ac3aaa628 100644 --- a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php @@ -120,7 +120,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $hookmanager=new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters=array('outputlangs'=>$outputlangs); global $action; $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 683034156da..a4b73f22e90 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -126,7 +126,7 @@ class pdf_paiement $hookmanager=new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters=array('file'=>$file,'outputlangs'=>$outputlangs); global $action; $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks From afcebea440e2752945f67b95a43fa9d6a47ec90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 14:40:43 +0200 Subject: [PATCH 016/152] FIX: Missing global declaration --- htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php | 2 +- htdocs/core/modules/project/pdf/pdf_baleine.modules.php | 2 +- htdocs/core/modules/rapport/pdf_paiement.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index fa2e3c85c06..80cf628838d 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -106,7 +106,7 @@ class pdf_soleil extends ModelePDFFicheinter */ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc; + global $conf, $hookmanager, $langs, $user; if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php index 58dd367757e..0165a01a9bc 100644 --- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php @@ -92,7 +92,7 @@ class pdf_baleine extends ModelePDFProjects */ function write_file($object,$outputlangs) { - global $user,$langs,$conf; + global $conf, $hookmanager, $langs, $user; if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index a4b73f22e90..6f48cc1baca 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -91,7 +91,7 @@ class pdf_paiement { include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - global $user,$langs,$conf; + global $conf, $hookmanager, $langs, $user; $socid=0; if ($user->societe_id) $socid=$user->societe_id; From f68cb3bfcbbf9e659066e53d532bd27ab345256b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 14:52:59 +0200 Subject: [PATCH 017/152] FIX: Variable declared boolean --- htdocs/core/modules/modSyslog.class.php | 2 +- htdocs/core/modules/modUser.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php index 563b2e31fa0..f2b5f80ff32 100644 --- a/htdocs/core/modules/modSyslog.class.php +++ b/htdocs/core/modules/modSyslog.class.php @@ -50,7 +50,7 @@ class modSyslog extends DolibarrModules // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "Activate debug logs (syslog)"; // Can be enabled / disabled only in the main company - $this->core_enabled = 1; + $this->core_enabled = true; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index a59031b4a44..55e96f02262 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -49,7 +49,7 @@ class modUser extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des utilisateurs (requis)"; - $this->always_enabled = 1; // Can't be disabled + $this->always_enabled = true; // Can't be disabled // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; From eea9a76589c6138dea1e06c8774d7c6a1522cfd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 15:09:03 +0200 Subject: [PATCH 018/152] FIX: Variable might not be traversable --- htdocs/accountancy/journal/bankjournal.php | 144 +++++++++++---------- htdocs/accountancy/journal/cashjournal.php | 107 +++++++-------- htdocs/comm/action/peruser.php | 77 ++++++----- htdocs/compta/bank/class/account.class.php | 8 +- htdocs/core/class/html.form.class.php | 19 +-- htdocs/core/lib/json.lib.php | 2 +- htdocs/user/class/usergroup.class.php | 2 +- 7 files changed, 192 insertions(+), 167 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index ef39e5668a0..ca862098bd3 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -170,83 +170,87 @@ if ($result) { } $links = $object->get_url($obj->rowid); - foreach ( $links as $key => $val ) { + // get_url may return -1 which is not traversable + if (is_array($links)) { - $tabtype[$obj->rowid] = $links[$key]['type']; + foreach ( $links as $key => $val ) { - if ($links[$key]['type'] == 'payment') - { - $paymentstatic->id = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); - } - else if ($links[$key]['type'] == 'payment_supplier') - { - $paymentsupplierstatic->id = $links[$key]['url_id']; - $paymentsupplierstatic->ref = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); - } - else if ($links[$key]['type'] == 'company') - { - $societestatic->id = $links[$key]['url_id']; - $societestatic->nom = $links[$key]['label']; - $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); - $tabtp[$obj->rowid][$compta_soc] += $obj->amount; - } - else if ($links[$key]['type'] == 'sc') - { - $chargestatic->id = $links[$key]['url_id']; - $chargestatic->ref = $links[$key]['url_id']; + $tabtype[$obj->rowid] = $links[$key]['type']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); - if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { - if ($reg[1] == 'socialcontribution') - $reg[1] = 'SocialContribution'; - $chargestatic->lib = $langs->trans($reg[1]); - } - else + if ($links[$key]['type'] == 'payment') { - $chargestatic->lib = $links[$key]['label']; - } - $chargestatic->ref = $chargestatic->lib; - $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); - - $sqlmid = 'SELECT cchgsoc.accountancy_code'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; - $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; - - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) + $paymentstatic->id = $links[$key]['url_id']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); + } + else if ($links[$key]['type'] == 'payment_supplier') { - $objmid = $db->fetch_object($resultmid); - $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; + $paymentsupplierstatic->id = $links[$key]['url_id']; + $paymentsupplierstatic->ref = $links[$key]['url_id']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); } + else if ($links[$key]['type'] == 'company') + { + $societestatic->id = $links[$key]['url_id']; + $societestatic->nom = $links[$key]['label']; + $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); + $tabtp[$obj->rowid][$compta_soc] += $obj->amount; + } + else if ($links[$key]['type'] == 'sc') + { + $chargestatic->id = $links[$key]['url_id']; + $chargestatic->ref = $links[$key]['url_id']; + + $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); + if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { + if ($reg[1] == 'socialcontribution') + $reg[1] = 'SocialContribution'; + $chargestatic->lib = $langs->trans($reg[1]); + } + else + { + $chargestatic->lib = $links[$key]['label']; + } + $chargestatic->ref = $chargestatic->lib; + $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); + + $sqlmid = 'SELECT cchgsoc.accountancy_code'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; + $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; + + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) + { + $objmid = $db->fetch_object($resultmid); + $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; + } + } + else if ($links[$key]['type'] == 'payment_vat') + { + $paymentvatstatic->id = $links[$key]['url_id']; + $paymentvatstatic->ref = $links[$key]['url_id']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); + $tabtp[$obj->rowid][$cpttva] += $obj->amount; + } + else if ($links[$key]['type'] == 'payment_salary') + { + $paymentsalstatic->id = $links[$key]['url_id']; + $paymentsalstatic->ref = $links[$key]['url_id']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); + $tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount; + } + else if ($links[$key]['type'] == 'banktransfert') + { + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); + $tabtp[$obj->rowid][$cpttva] += $obj->amount; + } + /*else { + $tabtp [$obj->rowid] [$accountancy_account_salary] += $obj->amount; + }*/ } - else if ($links[$key]['type'] == 'payment_vat') - { - $paymentvatstatic->id = $links[$key]['url_id']; - $paymentvatstatic->ref = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); - $tabtp[$obj->rowid][$cpttva] += $obj->amount; - } - else if ($links[$key]['type'] == 'payment_salary') - { - $paymentsalstatic->id = $links[$key]['url_id']; - $paymentsalstatic->ref = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); - $tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount; - } - else if ($links[$key]['type'] == 'banktransfert') - { - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); - $tabtp[$obj->rowid][$cpttva] += $obj->amount; - } - /*else { - $tabtp [$obj->rowid] [$accountancy_account_salary] += $obj->amount; - }*/ } $tabbq[$obj->rowid][$compta_bank] += $obj->amount; diff --git a/htdocs/accountancy/journal/cashjournal.php b/htdocs/accountancy/journal/cashjournal.php index 33b1e4359c1..e2994ce57e6 100644 --- a/htdocs/accountancy/journal/cashjournal.php +++ b/htdocs/accountancy/journal/cashjournal.php @@ -157,64 +157,67 @@ if ($result) { } $links = $object->get_url($obj->rowid); - foreach ( $links as $key => $val ) { + // get_url may return -1 which is not traversable + if (is_array($links)) { + foreach ($links as $key => $val) { - $tabtype[$obj->rowid] = $links[$key]['type']; + $tabtype[$obj->rowid] = $links[$key]['type']; - if ($links[$key]['type'] == 'payment') { - $paymentstatic->id = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); - } else if ($links[$key]['type'] == 'payment_supplier') { - $paymentsupplierstatic->id = $links[$key]['url_id']; - $paymentsupplierstatic->ref = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); - } else if ($links[$key]['type'] == 'company') { + if ($links[$key]['type'] == 'payment') { + $paymentstatic->id = $links[$key]['url_id']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); + } else if ($links[$key]['type'] == 'payment_supplier') { + $paymentsupplierstatic->id = $links[$key]['url_id']; + $paymentsupplierstatic->ref = $links[$key]['url_id']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); + } else if ($links[$key]['type'] == 'company') { - $societestatic->id = $links[$key]['url_id']; - $societestatic->nom = $links[$key]['label']; - $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); - $tabtp[$obj->rowid][$compta_soc] += $obj->amount; - } else if ($links[$key]['type'] == 'sc') { + $societestatic->id = $links[$key]['url_id']; + $societestatic->nom = $links[$key]['label']; + $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); + $tabtp[$obj->rowid][$compta_soc] += $obj->amount; + } else if ($links[$key]['type'] == 'sc') { - $chargestatic->id = $links[$key]['url_id']; - $chargestatic->ref = $links[$key]['url_id']; + $chargestatic->id = $links[$key]['url_id']; + $chargestatic->ref = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); - if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { - if ($reg[1] == 'socialcontribution') - $reg[1] = 'SocialContribution'; - $chargestatic->lib = $langs->trans($reg[1]); - } else { - $chargestatic->lib = $links[$key]['label']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); + if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { + if ($reg[1] == 'socialcontribution') + $reg[1] = 'SocialContribution'; + $chargestatic->lib = $langs->trans($reg[1]); + } else { + $chargestatic->lib = $links[$key]['label']; + } + $chargestatic->ref = $chargestatic->lib; + $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); + + $sqlmid = 'SELECT cchgsoc.accountancy_code'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; + $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; + dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; + } + } else if ($links[$key]['type'] == 'payment_vat') { + + $paymentvatstatic->id = $links[$key]['url_id']; + $paymentvatstatic->ref = $links[$key]['url_id']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); + $tabtp[$obj->rowid][$cpttva] += $obj->amount; + } else if ($links[$key]['type'] == 'banktransfert') { + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); + $tabtp[$obj->rowid][$cpttva] += $obj->amount; } - $chargestatic->ref = $chargestatic->lib; - $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); - - $sqlmid = 'SELECT cchgsoc.accountancy_code'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; - $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; - dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; - } - } else if ($links[$key]['type'] == 'payment_vat') { - - $paymentvatstatic->id = $links[$key]['url_id']; - $paymentvatstatic->ref = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); - $tabtp[$obj->rowid][$cpttva] += $obj->amount; - } else if ($links[$key]['type'] == 'banktransfert') { - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); - $tabtp[$obj->rowid][$cpttva] += $obj->amount; + /*else { + $tabtp [$obj->rowid] [$cptsociale] += $obj->amount; + }*/ } - /*else { - $tabtp [$obj->rowid] [$cptsociale] += $obj->amount; - }*/ } $tabbq[$obj->rowid][$compta_bank] += $obj->amount; @@ -530,4 +533,4 @@ if ($action == 'export_csv') { // End of page llxFooter(); } -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 8bcd1c7289b..ccb544ac4bb 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -600,41 +600,56 @@ else // Loop on each user to show calendar $sav = $tmpday; $showheader = true; -foreach ($usernames as $username) -{ - echo ""; - echo '' . $username->getNomUrl(1). ''; - $tmpday = $sav; - $i = 0; - for ($iter_day = 0; $iter_day < 7; $iter_day++) - { - if (($i + 1) < $begin_d || ($i + 1) > $end_d) - { +// listUsersForGroup may return -1 which is not traversable +if (is_array($usernames)) { + foreach ($usernames as $username) { + echo ""; + echo '' . $username->getNomUrl(1) . ''; + $tmpday = $sav; + + $i = 0; + for ($iter_day = 0; $iter_day < 7; $iter_day++) { + if (($i + 1) < $begin_d || ($i + 1) > $end_d) { + $i++; + continue; + } + + // Show days of the current week + $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); + $tmparray = dol_getdate($curtime, 'fast'); + $tmpday = $tmparray['mday']; + $tmpmonth = $tmparray['mon']; + $tmpyear = $tmparray['year']; + + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_other_month'; + $today = 0; + $todayarray = dol_getdate($now, 'fast'); + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; + if ($today) $style = 'cal_today_peruser'; + + show_day_events2( + $username, + $tmpday, + $month, + $year, + $monthshown, + $style, + $eventarray, + 0, + $maxnbofchar, + $newparam, + 1, + 300, + $showheader + ); + $i++; - continue; } - - // Show days of the current week - $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); - $tmparray = dol_getdate($curtime,'fast'); - $tmpday = $tmparray['mday']; - $tmpmonth = $tmparray['mon']; - $tmpyear = $tmparray['year']; - - $style='cal_current_month'; - if ($iter_day == 6) $style.=' cal_other_month'; - $today=0; - $todayarray=dol_getdate($now,'fast'); - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1; - if ($today) $style='cal_today_peruser'; - - show_day_events2($username, $tmpday, $month, $year, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader); - - $i++; + echo "\n"; + $showheader = false; } - echo "\n"; - $showheader = false; } echo "\n"; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4ca6175d785..cd428f927b2 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -164,10 +164,10 @@ class Account extends CommonObject * TODO Move this into AccountLine * Return array with links from llx_bank_url * - * @param int $fk_bank To search using bank transaction id - * @param int $url_id To search using link to - * @param string $type To search using type - * @return array Array of links + * @param int $fk_bank To search using bank transaction id + * @param int $url_id To search using link to + * @param string $type To search using type + * @return array|-1 Array of links or -1 on error */ function get_url($fk_bank='', $url_id='', $type='') { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 937f904c512..6b0e9b4d895 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1302,14 +1302,17 @@ class Form $assignedtouser=array(); if (!empty($_SESSION['assignedtouser'])) $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true); if (count($assignedtouser)) $out.='
'; - foreach($assignedtouser as $key => $value) - { - $userstatic->fetch($key); - $out.=$userstatic->getNomUrl(1); - //$out.=' '.($value['mandatory']?$langs->trans("Mandatory"):$langs->trans("Optional")); - //$out.=' '.($value['transparency']?$langs->trans("Busy"):$langs->trans("NotBusy")); - $out.='
'; - } + // dol_json_decode may return false on error which is not traversable + if (is_array($assignedtouser)) { + foreach($assignedtouser as $key => $value) + { + $userstatic->fetch($key); + $out.=$userstatic->getNomUrl(1); + //$out.=' '.($value['mandatory']?$langs->trans("Mandatory"):$langs->trans("Optional")); + //$out.=' '.($value['transparency']?$langs->trans("Busy"):$langs->trans("NotBusy")); + $out.='
'; + } + } //$out.=''; return $out; diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 69dbb4eba1a..00d5970d77e 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -218,7 +218,7 @@ if (! function_exists('json_decode')) * * @param string $json Json encoded to PHP Object or Array * @param bool $assoc False return an object, true return an array. Try to always use it with true ! - * @return mixed Object or Array + * @return mixed Object or Array or false on error */ function dol_json_decode($json, $assoc=false) { diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index b801c2660aa..9bd0d64fe4c 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -178,7 +178,7 @@ class UserGroup extends CommonObject * * @param string $excludefilter Filter to exclude * @param int $mode 0=Return array of user instance, 1=Return array of users id only - * @return array Array of users + * @return array|-1 Array of users or -1 on error */ function listUsersForGroup($excludefilter='', $mode=0) { From a7964c4a9ad4af94b6796b727b304e3ebb9f43c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 15:20:48 +0200 Subject: [PATCH 019/152] FIX: Replaced deprecated call --- htdocs/accountancy/customer/list.php | 4 ++-- htdocs/accountancy/supplier/list.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 02602262e2c..03e31d44a96 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -63,7 +63,7 @@ if ($action == 'ventil') { $cpt = 0; foreach ( $mesCasesCochees as $maLigneCochee ) { // print '
id selectionnee : '.$monChoix."
"; - $maLigneCourante = split("_", $maLigneCochee); + $maLigneCourante = explode("_", $maLigneCochee); $monId = $maLigneCourante[0]; $monNumLigne = $maLigneCourante[1]; $monCompte = $mesCodesVentilChoisis[$monNumLigne]; @@ -234,4 +234,4 @@ if ($result) { } $db->close(); -llxFooter(); \ No newline at end of file +llxFooter(); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 84f548344b8..817b07c178e 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -65,7 +65,7 @@ if ($action == 'ventil') { foreach ( $mesCasesCochees as $maLigneCochee ) { // print '
id selectionnee : '.$monChoix."
"; - $maLigneCourante = split("_", $maLigneCochee); + $maLigneCourante = explode("_", $maLigneCochee); $monId = $maLigneCourante[0]; $monNumLigne = $maLigneCourante[1]; $monCompte = $mesCodesVentilChoisis[$monNumLigne]; From e87b1d68b6fce80fd66e255c6a654b5981232d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 15:22:05 +0200 Subject: [PATCH 020/152] FIX: Replaced deprecated property --- htdocs/accountancy/journal/bankjournal.php | 2 +- htdocs/accountancy/journal/cashjournal.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index ca862098bd3..218c4dd46df 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -191,7 +191,7 @@ if ($result) { else if ($links[$key]['type'] == 'company') { $societestatic->id = $links[$key]['url_id']; - $societestatic->nom = $links[$key]['label']; + $societestatic->name = $links[$key]['label']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); $tabtp[$obj->rowid][$compta_soc] += $obj->amount; } diff --git a/htdocs/accountancy/journal/cashjournal.php b/htdocs/accountancy/journal/cashjournal.php index e2994ce57e6..ac7cbeb2f77 100644 --- a/htdocs/accountancy/journal/cashjournal.php +++ b/htdocs/accountancy/journal/cashjournal.php @@ -173,7 +173,7 @@ if ($result) { } else if ($links[$key]['type'] == 'company') { $societestatic->id = $links[$key]['url_id']; - $societestatic->nom = $links[$key]['label']; + $societestatic->name = $links[$key]['label']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); $tabtp[$obj->rowid][$compta_soc] += $obj->amount; } else if ($links[$key]['type'] == 'sc') { From c20f5b186e6e8997feb7fb0f989c69afdbec2612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 15:25:18 +0200 Subject: [PATCH 021/152] Qual: Updated code documentation --- htdocs/core/modules/DolibarrModules.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index e4d1f834b4a..69dabf04219 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -192,10 +192,10 @@ abstract class DolibarrModules * Enables a module. * Inserts all informations into database * - * @param string[] $array_sql SQL requests to be executed when enabling module - * @param string $options String with options when disabling module ('newboxdefonly|noboxes') + * @param string[]|array $array_sql SQL requests to be executed when enabling module + * @param string $options String with options when disabling module ('newboxdefonly|noboxes') * - * @return int 1 if OK, 0 if KO + * @return int 1 if OK, 0 if KO */ function _init($array_sql, $options='') { From e9175d5d663430c9b4e21988e4d87b3b9cff52b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 15:26:42 +0200 Subject: [PATCH 022/152] Qual: date type doesn't exist --- htdocs/core/lib/report.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index 9c701441765..d41594c3193 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -31,7 +31,7 @@ * @param string $period Period of report * @param string $periodlink Link to switch period * @param string $description Description -* @param date $builddate Date generation +* @param int $builddate Date generation * @param string $exportlink Link for export or '' * @param array $moreparam Array with list of params to add into form * @param string $calcmode Calculation mode From b21d85a1da139aafe593ba4300b3d58d3f3b102b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 15:28:56 +0200 Subject: [PATCH 023/152] FIX: Function was expecting a boolean not a string --- htdocs/comm/action/index.php | 2 +- htdocs/comm/action/peruser.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 2318c45f132..7cec34cb6db 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -986,7 +986,7 @@ elseif ($action == 'show_week') // View by week { // Show days of the current week $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); - $tmparray = dol_getdate($curtime,'fast'); + $tmparray = dol_getdate($curtime, true); $tmpday = $tmparray['mday']; $tmpmonth = $tmparray['mon']; $tmpyear = $tmparray['year']; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index ccb544ac4bb..ec6243c7ae7 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -617,7 +617,7 @@ if (is_array($usernames)) { // Show days of the current week $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); - $tmparray = dol_getdate($curtime, 'fast'); + $tmparray = dol_getdate($curtime, true); $tmpday = $tmparray['mday']; $tmpmonth = $tmparray['mon']; $tmpyear = $tmparray['year']; @@ -625,7 +625,7 @@ if (is_array($usernames)) { $style = 'cal_current_month'; if ($iter_day == 6) $style .= ' cal_other_month'; $today = 0; - $todayarray = dol_getdate($now, 'fast'); + $todayarray = dol_getdate($now, true); if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; if ($today) $style = 'cal_today_peruser'; From bd03cb439d91954e18274024a7ec29dc3fa61811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 15:36:37 +0200 Subject: [PATCH 024/152] FIX: Function expects an int, not a boolean --- htdocs/comm/action/peruser.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index ec6243c7ae7..5afda948a77 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -800,9 +800,9 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $color = ''; //init if (empty($event->fulldayevent)) { - $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,false); - $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,false); - $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,false); + $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,0); + $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,0); + $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0); $dateendtouse=$event->date_end_in_calendar; if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; From 0f71b7e0b0f5f5f4628355028dd33eeedee87175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 18 Sep 2014 15:38:07 +0200 Subject: [PATCH 025/152] FIX: Typo --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 20b030a9226..2acf4071052 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -822,7 +822,7 @@ function dol_strftime($fmt, $ts=false, $is_gmt=false) * @param string $tzoutput true or 'gmt' => string is for Greenwich location * false or 'tzserver' => output string is for local PHP server TZ usage * 'tzuser' => output string is for local browser TZ usage - * @param Tranlsate $outputlangs Object lang that contains language for text translation. + * @param Translate $outputlangs Object lang that contains language for text translation. * @param boolean $encodetooutput false=no convert into output pagecode * @return string Formated date or '' if time is null * From 4296766ea96dfbb13de71d282ca1bcc9bd86476b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Fri, 19 Sep 2014 03:03:24 +0200 Subject: [PATCH 026/152] Qual: Coding style --- htdocs/core/lib/accounting.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 7b18de022f6..69e47569b07 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -25,6 +25,7 @@ /** * Prepare array with list of admin tabs + * * @param Object $object Accounting account * * @return array Array of tabs to show From 619bcb44df5bd39bc0af4aeab58b7a51d9465336 Mon Sep 17 00:00:00 2001 From: jean Date: Tue, 21 Oct 2014 19:02:48 +0200 Subject: [PATCH 027/152] object must be reloaded before creating pdf on confirmation and ordering --- htdocs/fourn/commande/fiche.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 00884d368f6..3c1d15ddc47 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -523,7 +523,8 @@ else if ($action == 'confirm_approve' && $confirm == 'yes' && $user->rights->fou if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $ret=$object->fetch($object->id); // Reload to get new records + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; @@ -555,7 +556,8 @@ else if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fo if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $ret=$object->fetch($object->id); // Reload to get new records + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; From e9f754395d280e614bd8f59f9a16e9055124c137 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 10 Nov 2014 13:09:58 +0100 Subject: [PATCH 028/152] Start bank extrafields --- htdocs/compta/bank/class/account.class.php | 61 ++++++++++++++++++- htdocs/core/lib/bank.lib.php | 33 ++++++++++ .../llx_bank_account_extrafields.key.sql | 20 ++++++ .../tables/llx_bank_account_extrafields.sql | 26 ++++++++ 4 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_bank_account_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_bank_account_extrafields.sql diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index e2a039cf2d8..a50a7f448a9 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -343,7 +343,7 @@ class Account extends CommonObject */ function create($user='') { - global $langs,$conf; + global $langs,$conf, $hookmanager; // Clean parameters if (! $this->min_allowed) $this->min_allowed=0; @@ -441,6 +441,23 @@ class Account extends CommonObject $this->error=$this->db->lasterror(); return -3; } + + // Actions on extra fields (by external module or standard code) + $hookmanager->initHooks(array('bankdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + return -4; + } + } + } + else if ($reshook < 0) return -5; } return $this->id; } @@ -466,7 +483,7 @@ class Account extends CommonObject */ function update($user='') { - global $langs,$conf; + global $langs,$conf, $hookmanager; // Clean parameters if (! $this->min_allowed) $this->min_allowed=0; @@ -517,6 +534,25 @@ class Account extends CommonObject $result = $this->db->query($sql); if ($result) { + + // Actions on extra fields (by external module or standard code) + $hookmanager->initHooks(array('bankdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + return -1; + } + } + } + else if ($reshook < 0) return -1; + + return 1; } else @@ -663,6 +699,15 @@ class Account extends CommonObject $this->min_allowed = $obj->min_allowed; $this->min_desired = $obj->min_desired; $this->comment = $obj->comment; + + // Retreive all extrafield for thirdparty + // fetch optionals attributes and labels + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + + return 1; } else @@ -694,6 +739,18 @@ class Account extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { + + // Remove extrafields + if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + return -1; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } + return 1; } else { diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 488a4c3a530..e3fb787657b 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -89,6 +89,39 @@ function bank_prepare_head($object) return $head; } +/** + * Prepare array with list of tabs + * + * @param Object $object Object related to tabs + * @return array Array of tabs to shoc + */ +function bank_admin_prepare_head($object) +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT . '/admin/bank.php'; + $head[$h][1] = $langs->trans("Miscellaneous"); + $head[$h][2] = 'general'; + $h++; + + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin'); + + $head[$h][0] = DOL_URL_ROOT.'/admin/bank_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin', 'remove'); + + return $head; + } /** * Check account number informations for a bank account diff --git a/htdocs/install/mysql/tables/llx_bank_account_extrafields.key.sql b/htdocs/install/mysql/tables/llx_bank_account_extrafields.key.sql new file mode 100644 index 00000000000..0f6e8052115 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_bank_account_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2014 Florian Henry +-- +-- 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 . +-- +-- =================================================================== + + +ALTER TABLE llx_bank_account_extrafields ADD INDEX idx_bank_account_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_bank_account_extrafields.sql b/htdocs/install/mysql/tables/llx_bank_account_extrafields.sql new file mode 100644 index 00000000000..97b1508237c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_bank_account_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2014 Florian Henry +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +create table llx_bank_account_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + From 9c795d2c4b5f95bdd8f647e8ba7aa9b30fd106e3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 10 Nov 2014 13:18:27 +0100 Subject: [PATCH 029/152] Finnish bank extrafeilds --- htdocs/admin/bank.php | 4 + htdocs/admin/bank_extrafields.php | 154 ++++++++++++++++++++++++++++++ htdocs/compta/bank/card.php | 37 +++++++ 3 files changed, 195 insertions(+) create mode 100644 htdocs/admin/bank_extrafields.php diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index de1f7662373..9b5cb77e072 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -26,6 +26,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $langs->load("admin"); @@ -89,6 +90,9 @@ print_fiche_titre($langs->trans("BankSetupModule"),$linkback,'setup'); print '
'; +$head = bank_admin_prepare_head(null); +dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), 0, 'account'); + print ''; print ''; print ''; diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php new file mode 100644 index 00000000000..b28c8b417c3 --- /dev/null +++ b/htdocs/admin/bank_extrafields.php @@ -0,0 +1,154 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/bank_extrafields.php + * \ingroup bank + * \brief Page to setup extra fields of bank + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("banks"); +$langs->load("admin"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='bank_account'; //Must be the $element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +llxHeader('',$langs->trans("BankSetupModule"),$help_url); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("BankSetupModule"),$linkback,'setup'); + + +$head = bank_admin_prepare_head(null); + +dol_fiche_head($head, 'attributes', $langs->trans("Bank"), 0, 'account'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print "
'.$langs->trans("Parameters").'
"; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; + // $i++; +} + +print "
'.$langs->trans("Position").''.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_pos[$key]."".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel + /* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 81596540489..9b4efe79eb1 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $langs->load("banks"); $langs->load("categories"); @@ -48,6 +49,10 @@ $fieldid = isset($_GET["ref"])?'ref':'rowid'; if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'banque',$id,'bank_account&bank_account','','',$fieldid); +$account = new Account($db); +$extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($account->table_element); /* * Actions @@ -100,6 +105,9 @@ if ($_POST["action"] == 'add') $error++; } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$account); + if (! $error) { $id = $account->create($user); @@ -172,6 +180,9 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) $error++; } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$account); + if (! $error) { $result = $account->update($user); @@ -306,6 +317,15 @@ if ($action == 'create') $doleditor=new DolEditor('account_comment',$account->comment,'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,70); $doleditor->Create(); print ''; + + // Other attributes + $parameters=array('colspan' => 3); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$account,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $account->showOptionals($extrafields,'edit',$parameters); + } + print ''; @@ -461,6 +481,14 @@ else print ''.$langs->trans("Comment").''; print ''.$account->comment.''; + // Other attributes + $parameters=array('colspan' => 3); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$account,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $account->showOptionals($extrafields); + } + print ''; print '
'; @@ -615,6 +643,15 @@ else $doleditor->Create(); print ''; + // Other attributes + $parameters=array('colspan' => 3); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$account,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $account->showOptionals($extrafields,'edit'); + } + + print ''; print '
'; From 5cce8c45e3895336a0051b72f439d98e6e2c1302 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Fri, 5 Dec 2014 18:23:54 +0100 Subject: [PATCH 030/152] WIP PrintIPP --- htdocs/comm/propal.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/facture.php | 2 +- htdocs/core/actions_printing.inc.php | 58 +++++++ htdocs/core/actions_printipp.inc.php | 45 ----- htdocs/core/class/dolprintipp.class.php | 2 +- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/modules/modPrintIPP.class.php | 19 ++- htdocs/core/modules/modPrinting.class.php | 155 ++++++++++++++++++ ...nterface_60_modPrinting_Printing.class.php | 71 ++++++++ htdocs/printing/admin/index.html | 0 htdocs/printing/admin/printing.php | 127 ++++++++++++++ htdocs/printing/index.php | 38 +++++ 13 files changed, 464 insertions(+), 59 deletions(-) create mode 100644 htdocs/core/actions_printing.inc.php delete mode 100644 htdocs/core/actions_printipp.inc.php create mode 100644 htdocs/core/modules/modPrinting.class.php create mode 100644 htdocs/core/triggers/interface_60_modPrinting_Printing.class.php create mode 100644 htdocs/printing/admin/index.html create mode 100644 htdocs/printing/admin/printing.php create mode 100644 htdocs/printing/index.php diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index aa75945f0ea..908a8d4c8ad 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -553,7 +553,7 @@ else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST( } } -include DOL_DOCUMENT_ROOT.'/core/actions_printipp.inc.php'; +include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; /* diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 309b0c35e1a..a9a8800ede1 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1142,7 +1142,7 @@ else if ($action == 'update_extras') { $action = 'edit_extras'; } -include DOL_DOCUMENT_ROOT.'/core/actions_printipp.inc.php'; +include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; /* diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index be6ad58764a..4e79e710321 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1615,7 +1615,7 @@ else if ($action == 'remove_file') { } } -include DOL_DOCUMENT_ROOT.'/core/actions_printipp.inc.php'; +include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) { diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php new file mode 100644 index 00000000000..f864524fce1 --- /dev/null +++ b/htdocs/core/actions_printing.inc.php @@ -0,0 +1,58 @@ + + * Copyright (C) 2014 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/actions_printing.inc.php + * \brief Code for actions print_file to print file with calling trigger + */ + + +// $action must be defined +// $db, $user, $conf, $langs must be defined +// Filename to print must be provided into 'file' parameter + +// Print file +if ($action == 'print_file' and $user->rights->printing->read) +{ + $langs->load("printing"); + //require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; + //$printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); + //$result = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); + // Call trigger to Print Doc + //$actiontypecode='AC_PRINT'; + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $trigger_name='PRINT_DOCPDF'; + $printing->file = GETPOST('file', 'alpha'); + $printing->printer = GETPOST('printer', 'alpha'); + //print print_r($printing, true); + + $result=$interface->run_triggers($trigger_name,$printing,$user,$langs,$conf); + if ($result < 0) { + setEventMessage($interface->errors, 'errors'); + } + if ($result == 0) { + setEventMessage($langs->trans("NoModuleFound")); + } + + if ($result>0) { + setEventMessage($langs->trans("FileWasSentToPrinter", basename(GETPOST('file')))); + } + $action = ''; +} diff --git a/htdocs/core/actions_printipp.inc.php b/htdocs/core/actions_printipp.inc.php deleted file mode 100644 index 3c18faa813b..00000000000 --- a/htdocs/core/actions_printipp.inc.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * 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 . - * or see http://www.gnu.org/ - */ - -/** - * \file htdocs/core/actions_printipp.inc.php - * \brief Code for actions print_file to print file using ipp - */ - - -// $action must be defined -// $db, $user, $conf, $langs must be defined -// Filename to print must be provided into 'file' parameter - -// Print file -if ($action == 'print_file' and $user->rights->printipp->read) -{ - $langs->load("printipp"); - require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; - $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); - $result = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); - if ($result) - { - setEventMessage($result,'warnings'); - } - else - { - setEventMessage($langs->trans("FileWasSentToPrinter", basename(GETPOST('file')))); - } - $action = ''; -} diff --git a/htdocs/core/class/dolprintipp.class.php b/htdocs/core/class/dolprintipp.class.php index 71ee2a1be37..272d46ec745 100644 --- a/htdocs/core/class/dolprintipp.class.php +++ b/htdocs/core/class/dolprintipp.class.php @@ -28,7 +28,7 @@ class dolprintIPP { var $host; var $port; - var $userid; /* user login */ + var $userid; /* user login */ var $user; var $password; var $error; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 9a419e53d89..d2183c582cd 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -274,7 +274,7 @@ class FormFile $printer=0; if (in_array($modulepart,array('facture','propal','proposal','order','commande'))) // This feature is implemented only for such elements { - $printer = (!empty($user->rights->printipp->read) && !empty($conf->printipp->enabled))?true:false; + $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; } $hookmanager->initHooks(array('formfile')); diff --git a/htdocs/core/modules/modPrintIPP.class.php b/htdocs/core/modules/modPrintIPP.class.php index 3cdcd6cdfa6..1f3d0a71a7a 100644 --- a/htdocs/core/modules/modPrintIPP.class.php +++ b/htdocs/core/modules/modPrintIPP.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,9 +23,9 @@ /** * \file htdocs/core/modules/modPrintIPP.class.php * \ingroup printipp - * \brief Fichier de description et activation du module OSCommerce2 + * \brief Fichier de description et activation du module PrintIPP */ -include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php"); +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; @@ -37,9 +38,9 @@ class modPrintIPP extends DolibarrModules /** - * Constructor + * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ function __construct($db) { @@ -68,10 +69,10 @@ class modPrintIPP extends DolibarrModules // Dependances $this->hidden = (! empty($_SERVER["WINDIR"])); - $this->depends = array(); + $this->depends = array('printing'); $this->requiredby = array(); - $this->phpmin = array(5,1); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module + $this->phpmin = array(5,1); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module $this->conflictwith = array(); $this->langfiles = array("printipp"); @@ -142,8 +143,8 @@ class modPrintIPP extends DolibarrModules * Remove from database constants, boxes and permissions from Dolibarr database. * Data directories are not deleted * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ function remove($options='') { diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php new file mode 100644 index 00000000000..144b023bdc8 --- /dev/null +++ b/htdocs/core/modules/modPrinting.class.php @@ -0,0 +1,155 @@ + + * Copyright (C) 2014 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \defgroup printing Module printing + * \brief Module for activation of printing icon + */ + +/** + * \file htdocs/core/modules/modPrinting.class.php + * \ingroup printing + * \brief Fichier de description et activation du module Printing + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + + +/** + * \class modPrinting + * \brief Classe de description et activation du module Printing + */ +class modPrinting extends DolibarrModules +{ + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db ; + $this->numero = 112000; + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "other"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i','',get_class($this)); + $this->description = "Enable Printing System."; + $this->version = 'experimental'; // 'development' or 'experimental' or 'dolibarr' or version + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) + $this->special = 1; + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto = 'technic'; + + // Data directories to create when module is enabled. + $this->dirs = array(); + + // Config pages + $this->config_page_url = array("printing.php@printing"); + + // Dependances + $this->hidden = (! empty($_SERVER["WINDIR"])); + $this->depends = array(); + $this->requiredby = array(); + $this->phpmin = array(5,1); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module + $this->conflictwith = array(); + $this->langfiles = array("printing"); + + // Constantes + $this->const = array(); + + // Boxes + $this->boxes = array(); + + // Permissions + $this->rights = array(); + $this->rights_class = 'printing'; + + $r=0; + // $this->rights[$r][0] Id permission (unique tous modules confondus) + // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) + // $this->rights[$r][2] Non utilise + // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut + // $this->rights[$r][4] Niveau 1 pour nommer permission dans code + // $this->rights[$r][5] Niveau 2 pour nommer permission dans code + + $r++; + $this->rights[$r][0] = 112001; + $this->rights[$r][1] = 'Printing'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'read'; + + // Main menu entries + $this->menus = array(); // List of menus to add + $r=0; + + // This is to declare the Top Menu entry: + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Put 0 if this is a top menu + 'type'=>'left', // This is a Top menu entry + 'titre'=>'Printing', + 'mainmenu'=>'printing', + 'url'=>'/printing/index.php', + 'langs'=>'printing', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>300, + 'enabled'=>'$conf->printing->enabled && $leftmenu==\'modulesadmintools\'', + 'perms'=>'$user->rights->printing->read', // Use 'perms'=>'1' if you want your menu with no permission rules + 'target'=>'', + 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both + + $r++; + + + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function init($options='') + { + $sql = array(); + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function remove($options='') + { + $sql = array(); + + return $this->_remove($sql, $options); + } + +} diff --git a/htdocs/core/triggers/interface_60_modPrinting_Printing.class.php b/htdocs/core/triggers/interface_60_modPrinting_Printing.class.php new file mode 100644 index 00000000000..b02b16f4796 --- /dev/null +++ b/htdocs/core/triggers/interface_60_modPrinting_Printing.class.php @@ -0,0 +1,71 @@ + + * Copyright (C) 2005-2014 Regis Houssin + * Copyright (C) 2014 Marcos García + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/triggers/interface_60_modPrinting_Printing.class.php + * \ingroup printing + * \brief Trigger call by printing to print with PrintIPP + * \remarks + */ +require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; + + +/** + * Class of triggers for printing + */ +class InterfacePrinting extends DolibarrTriggers +{ + + public $family = 'printing'; + public $picto = 'technic'; + public $description = "Triggers of this module is used for printing via PrintIPP."; + public $version = self::VERSION_DOLIBARR; + + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) + { + global $db; + // Put here code you want to execute when a Dolibarr business events occurs. + // Data and type of action are stored into $object and $action + + // Actions + + if ($action=='PRINT_DOCPDF') { + require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; + $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); + $result = $printer->print_file($object->file, $object->printer); + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + //$this->errors[]='test'; + //return -1; + return 1; + } + return 0; + } + +} diff --git a/htdocs/printing/admin/index.html b/htdocs/printing/admin/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php new file mode 100644 index 00000000000..29bd8787fa0 --- /dev/null +++ b/htdocs/printing/admin/printing.php @@ -0,0 +1,127 @@ + + * Copyright (C) 2014 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/printing/admin/printing.php + * \ingroup printing + * \brief Page to setup printing module + */ + +require '../../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +//require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php'; +//require_once DOL_DOCUMENT_ROOT.'/printing/lib/printing.lib.php'; + +$langs->load("admin"); +$langs->load("printing"); + +if (! $user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); +$mode = GETPOST('mode','alpha'); +$value = GETPOST('value','alpha'); + +if (!$mode) $mode='config'; + +/* + * Action + */ + + + +/* + * View + */ + +$form = new Form($db); + +llxHeader('',$langs->trans("PrintingSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("PrintIPPSetup"),$linkback,'setup'); + +//$head=printippadmin_prepare_head(); + + +if ($mode == 'config' && $user->admin) +{ + print '
'; + print ''; + print ''; + + dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic'); + + print $langs->trans("PrintingDesc")."

\n"; + + print ''; + + $var=true; + print ''; + print ''; + print ''; + print "\n"; + + + $var=!$var; + print ''; + + $var=!$var; + print ''; + + $var=!$var; + print ''; + + $var=!$var; + print ''; + + print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; + print $langs->trans("PRINTIPP_HOST").''; + print ''; + print '   '.$langs->trans("Example").': localhost'; + print '
'; + print $langs->trans("PRINTIPP_PORT").''; + print ''; + print '   '.$langs->trans("Example").': 631'; + print '
'; + print $langs->trans("PRINTIPP_USER").''; + print ''; + print '
'; + print $langs->trans("PRINTIPP_PASSWORD").''; + print ''; + print '
'; + + dol_fiche_end(); + + //print '
'; + + + print ''; + + + //if (count($list) == 0) print $langs->trans("NoPrinterFound"); + + dol_fiche_end(); +} + + + +llxFooter(); + +$db->close(); diff --git a/htdocs/printing/index.php b/htdocs/printing/index.php new file mode 100644 index 00000000000..e8669f44585 --- /dev/null +++ b/htdocs/printing/index.php @@ -0,0 +1,38 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/printing/index.php + * \ingroup printing + * \brief Printing + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php'; + +llxHeader("",$langs->trans("Printing")); + +print_fiche_titre($langs->trans("Printing")); + +// List Jobs from printing modules +//$printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD); +//$printer->list_jobs('commande'); + +llxFooter(); + +$db->close(); From 99f817b69a88fc1985d9f95a75fa1cf1f22c1df8 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 5 Dec 2014 21:40:55 +0100 Subject: [PATCH 031/152] - New: Add Option to not change date on cloning project --- ChangeLog | 2 ++ htdocs/langs/en_US/projects.lang | 1 + htdocs/langs/fr_FR/projects.lang | 1 + htdocs/projet/card.php | 4 +++- htdocs/projet/class/project.class.php | 16 +++++++++------- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5d67d88d7f..7178312ca7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ -------------------------------------------------------------- English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 3.8 compared to 3.7.* ***** +- New: Add Option to not change date on cloning project ***** ChangeLog for 3.7 compared to 3.6.* ***** diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 8d5d7c26a53..c038429043e 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -103,6 +103,7 @@ CloneContacts=Clone contacts CloneNotes=Clone notes CloneProjectFiles=Clone project joined files CloneTaskFiles=Clone task(s) joined files (if task(s) cloned) +CloneMoveDate=Update project/tasks dates from now ? ConfirmCloneProject=Are you sure to clone this project ? ProjectReportDate=Change task date according project start date ErrorShiftTaskDate=Impossible to shift task date according to new project start date diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 7148ae0c1c0..639049b0c3e 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -101,6 +101,7 @@ CloneContacts=Cloner les contacts CloneNotes=Cloner les notes CloneProjectFiles=Cloner les pièces jointes du projet CloneTaskFiles=Cloner les pièces jointes des tâche(s) (si tâche(s) cloner) +CloneMoveDate=Deplacer les date projets/taches sur maintenant ConfirmCloneProject=Êtes-vous sûr de vouloir cloner ce projet ? ProjectReportDate=Reporter les dates des tâches en fonction de la date de départ. ErrorShiftTaskDate=Une erreur s'est produite dans le report des dates des tâches. diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 1f6f430fccb..9b5f70e4dce 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -353,7 +353,8 @@ if (empty($reshook)) $clone_project_files = GETPOST('clone_project_files') ? 1 : 0; $clone_task_files = GETPOST('clone_task_files') ? 1 : 0; $clone_notes=GETPOST('clone_notes')?1:0; - $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_project_files,$clone_task_files,$clone_notes); + $move_date=GETPOST('move_date')?1:0; + $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_project_files,$clone_task_files,$clone_notes,$move_date); if ($result <= 0) { setEventMessage($object->error, 'errors'); @@ -538,6 +539,7 @@ else 'text' => $langs->trans("ConfirmClone"), array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), + array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true), array('type' => 'checkbox', 'name' => 'clone_project_files','label' => $langs->trans("CloneProjectFiles"), 'value' => false), array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 738eec46ec0..b70c2c59764 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -984,7 +984,7 @@ class Project extends CommonObject * @param bool $notrigger no trigger flag * @return int New id of clone */ - function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_project_file=false,$clone_task_file=false,$clone_note=true,$notrigger=0) + function createFromClone($fromid,$clone_contact=false,$clone_task=true,$clone_project_file=false,$clone_task_file=false,$clone_note=true,$move_date=true,$notrigger=0) { global $user,$langs,$conf; @@ -1006,11 +1006,13 @@ class Project extends CommonObject $orign_project_ref=$clone_project->ref; $clone_project->id=0; - $clone_project->date_start = $now; - if (!(empty($clone_project->date_end))) - { - $clone_project->date_end = $clone_project->date_end + ($now - $orign_dt_start); - } + if ($move_date) { + $clone_project->date_start = $now; + if (!(empty($clone_project->date_end))) + { + $clone_project->date_end = $clone_project->date_end + ($now - $orign_dt_start); + } + } $clone_project->datec = $now; @@ -1164,7 +1166,7 @@ class Project extends CommonObject foreach ($tasksarray as $tasktoclone) { - $result_clone = $taskstatic->createFromClone($tasktoclone->id,$clone_project_id,$tasktoclone->fk_parent,true,true,false,$clone_task_file,true,false); + $result_clone = $taskstatic->createFromClone($tasktoclone->id,$clone_project_id,$tasktoclone->fk_parent,$move_date,true,false,$clone_task_file,true,false); if ($result_clone <= 0) { $this->error.=$result_clone->error; From be60c13de6392290a480ef48509934cebfdc9fd3 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 8 Dec 2014 20:33:26 +0100 Subject: [PATCH 032/152] WIP Printing System --- .tx/config | 12 + htdocs/core/actions_printing.inc.php | 48 +-- htdocs/core/class/html.formfile.class.php | 10 +- htdocs/core/modules/modPrintIPP.class.php | 156 --------- htdocs/core/modules/modPrinting.class.php | 5 +- .../modules/printing}/index.html | 0 .../modules/printing/modules_printing.php | 86 +++++ .../modules/printing/printgcp.modules.php | 331 ++++++++++++++++++ .../modules/printing/printipp.modules.php | 282 +++++++++++++++ ...nterface_60_modPrinting_Printing.class.php | 71 ---- htdocs/expedition/card.php | 2 + .../install/mysql/migration/3.7.0-3.8.0.sql | 15 + .../{llx_printer_ipp.sql => llx_printing.sql} | 13 +- htdocs/langs/en_US/printgcp.lang | 18 + htdocs/langs/en_US/printing.lang | 10 + htdocs/langs/en_US/printipp.lang | 5 +- htdocs/printing/admin/printing.php | 190 +++++++--- htdocs/{printipp => printing}/lib/index.html | 0 .../lib/printing.lib.php} | 29 +- htdocs/printipp/admin/printipp.php | 246 ------------- htdocs/printipp/index.php | 36 -- 21 files changed, 965 insertions(+), 600 deletions(-) delete mode 100644 htdocs/core/modules/modPrintIPP.class.php rename htdocs/{printipp/admin => core/modules/printing}/index.html (100%) create mode 100644 htdocs/core/modules/printing/modules_printing.php create mode 100644 htdocs/core/modules/printing/printgcp.modules.php create mode 100644 htdocs/core/modules/printing/printipp.modules.php delete mode 100644 htdocs/core/triggers/interface_60_modPrinting_Printing.class.php rename htdocs/install/mysql/tables/{llx_printer_ipp.sql => llx_printing.sql} (83%) create mode 100644 htdocs/langs/en_US/printgcp.lang create mode 100644 htdocs/langs/en_US/printing.lang rename htdocs/{printipp => printing}/lib/index.html (100%) rename htdocs/{printipp/lib/printipp.lib.php => printing/lib/printing.lib.php} (59%) delete mode 100644 htdocs/printipp/admin/printipp.php delete mode 100644 htdocs/printipp/index.php diff --git a/.tx/config b/.tx/config index e4d1fc65732..74875508f29 100644 --- a/.tx/config +++ b/.tx/config @@ -236,6 +236,18 @@ source_file = htdocs/langs/en_US/paypal.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.printgcp] +file_filter = htdocs/langs//printgcp.lang +source_file = htdocs/langs/en_US/printgcp.lang +source_lang = en_US +type = MOZILLAPROPERTIES + +[dolibarr.printing] +file_filter = htdocs/langs//printing.lang +source_file = htdocs/langs/en_US/printing.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.printipp] file_filter = htdocs/langs//printipp.lang source_file = htdocs/langs/en_US/printipp.lang diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index f864524fce1..431ac89a94e 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -31,28 +31,34 @@ if ($action == 'print_file' and $user->rights->printing->read) { $langs->load("printing"); - //require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; - //$printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); - //$result = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); - // Call trigger to Print Doc - //$actiontypecode='AC_PRINT'; - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $trigger_name='PRINT_DOCPDF'; - $printing->file = GETPOST('file', 'alpha'); - $printing->printer = GETPOST('printer', 'alpha'); - //print print_r($printing, true); + require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php'; + $objectprint = new PrintingDriver($db); + $list = $objectprint->listDrivers($db, 10); + if (! empty($list)) { + $errorprint=0; + $printed=0; + foreach ($list as $driver) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; + $langs->load($driver); + $classname = 'printing_'.$driver; + $printer = new $classname($db); + //print '
'.print_r($printer, true).'
'; - $result=$interface->run_triggers($trigger_name,$printing,$user,$langs,$conf); - if ($result < 0) { - setEventMessage($interface->errors, 'errors'); - } - if ($result == 0) { - setEventMessage($langs->trans("NoModuleFound")); - } - - if ($result>0) { - setEventMessage($langs->trans("FileWasSentToPrinter", basename(GETPOST('file')))); + if (! empty($conf->global->{$printer->active})) { + $subdir=(GETPOST('printer', 'alpha')=='expedition'?'sending':''); + $errorprint = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'), $subdir); + //if ($errorprint < 0) { + // setEventMessage($interface->errors, 'errors'); + //} + if ($errorprint=='') { + setEventMessage($langs->trans("FileWasSentToPrinter", basename(GETPOST('file'))).' '.$langs->trans("ViaModule").' '.$printer->name); + $printed++; + } + } + } + if ($printed==0) setEventMessage($langs->trans("NoActivePrintingModuleFound")); + } else { + setEventMessage($langs->trans("NoModuleFound"), 'warning'); } $action = ''; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index d2183c582cd..9160213667b 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -272,7 +272,7 @@ class FormFile } $printer=0; - if (in_array($modulepart,array('facture','propal','proposal','order','commande'))) // This feature is implemented only for such elements + if (in_array($modulepart,array('facture','propal','proposal','order','commande','expedition'))) // This feature is implemented only for such elements { $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; } @@ -603,8 +603,8 @@ class FormFile $out.= ''; if ($delallowed) { - $out.= 'trans("Delete"), 'delete.png').''; @@ -613,8 +613,8 @@ class FormFile if ($printer) { //$out.= ''; - $out.= ' trans("Print"),'printer.png').''; } if ($morepicto) diff --git a/htdocs/core/modules/modPrintIPP.class.php b/htdocs/core/modules/modPrintIPP.class.php deleted file mode 100644 index 1f3d0a71a7a..00000000000 --- a/htdocs/core/modules/modPrintIPP.class.php +++ /dev/null @@ -1,156 +0,0 @@ - - * Copyright (C) 2014 Frederic France - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** \defgroup printipp Module printipp - * \brief Module pour imprimer via CUPS - */ - -/** - * \file htdocs/core/modules/modPrintIPP.class.php - * \ingroup printipp - * \brief Fichier de description et activation du module PrintIPP - */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; - - - -/** - * \class modPrintIPP - * \brief Classe de description et activation du module PrintIPP - */ -class modPrintIPP extends DolibarrModules -{ - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db ; - $this->numero = 54000; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "other"; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "Print via Cups IPP Printer."; - $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'technic'; - - // Data directories to create when module is enabled. - $this->dirs = array(); - - // Config pages - $this->config_page_url = array("printipp.php@printipp"); - - // Dependances - $this->hidden = (! empty($_SERVER["WINDIR"])); - $this->depends = array('printing'); - $this->requiredby = array(); - $this->phpmin = array(5,1); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3,7,-2); // Minimum version of Dolibarr required by module - $this->conflictwith = array(); - $this->langfiles = array("printipp"); - - // Constantes - $this->const = array(); - - // Boxes - $this->boxes = array(); - - // Permissions - $this->rights = array(); - $this->rights_class = 'printipp'; - - $r=0; - // $this->rights[$r][0] Id permission (unique tous modules confondus) - // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) - // $this->rights[$r][2] Non utilise - // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut - // $this->rights[$r][4] Niveau 1 pour nommer permission dans code - // $this->rights[$r][5] Niveau 2 pour nommer permission dans code - - $r++; - $this->rights[$r][0] = 54001; - $this->rights[$r][1] = 'Printer'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 1; - $this->rights[$r][4] = 'read'; - - // Main menu entries - $this->menus = array(); // List of menus to add - $r=0; - - // This is to declare the Top Menu entry: - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Put 0 if this is a top menu - 'type'=>'left', // This is a Top menu entry - 'titre'=>'Printer', - 'mainmenu'=>'printer', - 'url'=>'/printipp/index.php', - 'langs'=>'printipp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>300, - 'enabled'=>'$conf->printipp->enabled && $leftmenu==\'modulesadmintools\'', - 'perms'=>'$user->rights->printipp->read', // Use 'perms'=>'1' if you want your menu with no permission rules - 'target'=>'', - 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both - - $r++; - - - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function init($options='') - { - $sql = array(); - - return $this->_init($sql, $options); - } - - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function remove($options='') - { - $sql = array(); - - return $this->_remove($sql, $options); - } - -} diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index 144b023bdc8..00c59eaf285 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -67,7 +67,6 @@ class modPrinting extends DolibarrModules $this->config_page_url = array("printing.php@printing"); // Dependances - $this->hidden = (! empty($_SERVER["WINDIR"])); $this->depends = array(); $this->requiredby = array(); $this->phpmin = array(5,1); // Minimum version of PHP required by module @@ -132,6 +131,7 @@ class modPrinting extends DolibarrModules */ function init($options='') { + // insertion modele dans llx_document_model $sql = array(); return $this->_init($sql, $options); @@ -142,11 +142,12 @@ class modPrinting extends DolibarrModules * Remove from database constants, boxes and permissions from Dolibarr database. * Data directories are not deleted * - * @param string $options Options when enabling module ('', 'noboxes') + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ function remove($options='') { + // suppression des modeles "printing" $sql = array(); return $this->_remove($sql, $options); diff --git a/htdocs/printipp/admin/index.html b/htdocs/core/modules/printing/index.html similarity index 100% rename from htdocs/printipp/admin/index.html rename to htdocs/core/modules/printing/index.html diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php new file mode 100644 index 00000000000..3b53711f58c --- /dev/null +++ b/htdocs/core/modules/printing/modules_printing.php @@ -0,0 +1,86 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/mailings/modules_printing.php + * \ingroup printing + * \brief File with parent class of printing modules + */ +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + +/** + * Parent class of emailing target selectors modules + */ +class PrintingDriver +{ + var $db; + var $error; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + + /** + * Return list of printing driver + * + * @param DoliDB $db Database handler + * @param string $maxfilenamelength Max length of value to show + * @return array List of drivers + */ + static function listDrivers($db,$maxfilenamelength=0) + { + global $conf; + + $type='printing'; + $liste=array(); + + $moduledir=DOL_DOCUMENT_ROOT."/core/modules/printing/"; + $tmpfiles=dol_dir_list($moduledir,'all',0,'\modules.php','','name',SORT_ASC,0); + foreach($tmpfiles as $record) { + $list[$record['fullname']]=str_replace('.modules.php', '',$record['name']); + } + + return $list; + } + + /** + * Return description of Printing Module + * + * @return string Return translation of key PrintingModuleDescXXX where XXX is module name, or $this->desc if not exists + */ + function getDesc() + { + global $langs; + $langs->load("printing"); + $transstring="PrintingModuleDesc".$this->name; + if ($langs->trans($transstring) != $transstring) return $langs->trans($transstring); + else return $this->desc; + } + +} + diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php new file mode 100644 index 00000000000..7041e112811 --- /dev/null +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -0,0 +1,331 @@ +. + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/printing/printgcp.modules.php + * \ingroup printing + * \brief File to provide printing with Google Cloud Print + */ + +include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; + +/** + * \class mailing_example + * \brief Class to provide printing with Google Cloud Print + */ +class printing_printgcp extends PrintingDriver +{ + var $name = 'printgcp'; + var $desc = 'PrintGCPDesc'; + var $picto = 'printer'; + var $active = 'PRINTING_PRINTGCP'; + var $conf = array(); + var $login = ''; + var $password = ''; + var $authtoken = ''; + var $db; + + const LOGIN_URL = 'https://www.google.com/accounts/ClientLogin'; + const PRINTERS_SEARCH_URL = 'https://www.google.com/cloudprint/interface/search'; + const PRINT_URL = 'https://www.google.com/cloudprint/interface/submit'; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf; + + $this->db = $db; + $this->login = $conf->global->PRINTGCP_LOGIN; + $this->password = $conf->global->PRINTGCP_PASSWORD; + $this->authtoken = $conf->global->PRINTGCP_AUTHTOKEN; + $this->conf[] = array('varname'=>'PRINTGCP_LOGIN', 'required'=>1, 'example'=>'user@gmail.com', 'type'=>'text'); + $this->conf[] = array('varname'=>'PRINTGCP_PASSWORD', 'required'=>1, 'example'=>'', 'type'=>'password'); + } + + /** + * Return list of available printers + * + * @return string html list of printers + */ + function listAvailablePrinters() + { + global $bc, $conf, $langs; + $langs->load('printgcp'); + $var=true; + $html = ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''."\n"; + $list = $this->getlist_available_printers(); + //$html.= ''; + $var = true; + foreach ($list['available'] as $printer_det) + { + $var=!$var; + $html.= ""; + $html.= ''; + $html.= ''; + $html.= ''; // id to identify printer to use + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + // Defaut + $html.= ''; + $html.= ''."\n"; + } + + return $html; + } + + /** + * Return list of available printers + * + * @return array list of printers + */ + function getlist_available_printers() + { + global $conf,$db; + if ($this->authtoken=='') { + $this->GoogleLogin(); + } + $ret['available'] = $this->get_printer_detail(); + return $ret; + } + + /** + * List of printers + * + * @return array list of printers + */ + public function get_printer_detail() + { + // Check if we have auth token + if(empty($this->authtoken)) { + // We don't have auth token so throw exception + throw new Exception("Please first login to Google by calling loginToGoogle function"); + } + // Prepare auth headers with auth token + $authheaders = array("Authorization: GoogleLogin auth=".$this->authtoken, + "GData-Version: 3.0", + ); + // Make Http call to get printers added by user to Google Cloud Print + $responsedata = $this->makeCurl(self::PRINTERS_SEARCH_URL,array(),$authheaders); + $printers = json_decode($responsedata); + // Check if we have printers? + if(is_null($printers)) { + // We dont have printers so return blank array + return array(); + } else { + // We have printers so returns printers as array + return $this->parsePrinters($printers); + } + } + + /** + * Print selected file + * + * @param string $file file + * @param string $module module + * + * @return string '' if OK, Error message if KO + */ + public function print_file($file, $module, $subdir='') + { + global $conf; + if ($this->authtoken=='') { + $this->GoogleLogin(); + } + // si $module=commande_fournisseur alors $conf->fournisseur->commande->dir_output + $fileprint=$conf->{$module}->dir_output; + if ($subdir!='') $fileprint.='/'.$subdir; + $fileprint.='/'.$file; + + $this->sendPrintToPrinter($conf->global->PRINTING_GCP_DEFAULT, $file, $fileprint, 'application/pdf'); + } + + /** + * Sends document to the printer + * + * @param string $printerid Printer id returned by Google Cloud Print + * @param string $printjobtitle Job Title + * @param string $filepath File Path to be send to Google Cloud Print + * @param string $contenttype File content type by example application/pdf, image/png + * @return array status array + */ + public function sendPrintToPrinter($printerid,$printjobtitle,$filepath,$contenttype) + { + $errors=0; + // Check auth token + if(empty($this->authtoken)) { + $errors++; + setEventMessage('Please first login to Google', 'warning'); + } + // Check if printer id + if(empty($printerid)) { + $errors++; + setEventMessage('No provided printer ID', 'warning'); + } + // Open the file which needs to be print + $handle = fopen($filepath, "rb"); + if(!$handle) { + $errors++; + setEventMessage('Could not read the file.'); + } + // Read file content + $contents = fread($handle, filesize($filepath)); + fclose($handle); + // Prepare post fields for sending print + $post_fields = array('printerid' => $printerid, + 'title' => $printjobtitle, + 'contentTransferEncoding' => 'base64', + 'content' => base64_encode($contents), // encode file content as base64 + 'contentType' => $contenttype + ); + // Prepare authorization headers + $authheaders = array("Authorization: GoogleLogin auth=" . $this->authtoken); + // Make http call for sending print Job + $response = json_decode($this->makeCurl(self::PRINT_URL,$post_fields,$authheaders)); + // Has document been successfully sent? + if($response->success=="1") { + return array('status' =>true,'errorcode' =>'','errormessage'=>""); + } else { + return array('status' =>false,'errorcode' =>$response->errorCode,'errormessage'=>$response->message); + } + } + + + /** + * Login into Google Account + * + * @return string true or false + */ + function GoogleLogin() + { + global $db, $conf; + // Prepare post fields required for the login + $loginpostfields = array("accountType" => "HOSTED_OR_GOOGLE", + "Email" => $this->login, + "Passwd" => $this->password, + "service" => "cloudprint", + "source" => "GCP" + ); + // Get the Auth token + $loginresponse = $this->makeCurl(self::LOGIN_URL,$loginpostfields); + $token = $this->getAuthToken($loginresponse); + if(! empty($token)&&!is_null($token)) { + $this->authtoken = $token; + $result=dolibarr_set_const($db, 'PRINTGCP_AUTHTOKEN', $token, 'chaine', 0, '', $conf->entity); + return true; + } else { + return false; + } + + } + + /** + * + * Parse json response and return printers array + * @param string $jsonobj Json response object + * @return array return array of printers + */ + private function parsePrinters($jsonobj) + { + $printers = array(); + if (isset($jsonobj->printers)) { + foreach ($jsonobj->printers as $gcpprinter) { + $printers[] = array('id' =>$gcpprinter->id, + 'name' =>$gcpprinter->name, + 'defaultDisplayName' =>$gcpprinter->defaultDisplayName, + 'displayName' =>$gcpprinter->displayName, + 'ownerId' =>$gcpprinter->ownerId, + 'ownerName' =>$gcpprinter->ownerName, + 'connectionStatus' =>$gcpprinter->connectionStatus, + 'status' =>$gcpprinter->status, + 'type' =>$gcpprinter->type + ); + } + } + return $printers; + } + + /** + * Parse data to get auth token + * + * @param string $response response from curl + * @return string token + */ + private function getAuthToken($response) + { + // Search Auth tag + preg_match("/Auth=([a-z0-9_-]+)/i", $response, $matches); + $authtoken = @$matches[1]; + return $authtoken; + } + + /** + * Curl request + * + * @param string $url url to hit + * @param array $postfields array of post fields + * @param array $headers array of http headers + * @return + */ + private function makeCurl($url,$postfields=array(),$headers=array()) + { + // Curl Init + $curl = curl_init($url); + // Curl post request + if(! empty($postfields)) { + // As is HTTP post curl request so set post fields + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); + } + // Curl request headers + if(! empty($headers)) { + // As curl requires header so set headers here + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + } + curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + // Execute the curl and return response + $response = curl_exec($curl); + curl_close($curl); + return $response; + } + + +} diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php new file mode 100644 index 00000000000..5252341c2d3 --- /dev/null +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -0,0 +1,282 @@ +. + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/printing/printipp.modules.php + * \ingroup mailing + * \brief File to provide printing with PrintIPP + */ + +include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; + +/** + * \class mailing_example + * \brief Class to provide printing with PrintIPP + */ +class printing_printipp extends PrintingDriver +{ + var $name='printipp'; + var $desc='PrintIPPDesc'; + var $picto='printer'; + var $active='PRINTING_PRINTIPP'; + var $conf=array(); + var $host; + var $port; + var $userid; /* user login */ + var $user; + var $password; + var $error; + var $db; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf; + + $this->db=$db; + $this->host=$conf->global->PRINTIPP_HOST; + $this->port=$conf->global->PRINTIPP_PORT; + $this->user=$conf->global->PRINTIPP_USER; + $this->password=$conf->global->PRINTIPP_PASSWORD; + $this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text'); + $this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text'); + $this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text'); + $this->conf[] = array('varname'=>'PRINTIPP_PASSWORD', 'required'=>0, 'example'=>'', 'type'=>'password'); + } + + /** + * Print selected file + * + * @param string $file file + * @param string $module module + * @param string $subdir subdirectory of document like for expedition subdir is sendings + * + * @return string '' if OK, Error message if KO + */ + function print_file($file, $module, $subdir='') + { + global $conf,$db; + + include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; + + $ipp = new CupsPrintIPP(); + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose + $ipp->setHost($this->host); + $ipp->setPort($this->port); + $ipp->setJobName($file,true); + $ipp->setUserName($this->userid); + if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); + + // select printer uri for module order, propal,... + $sql = 'SELECT rowid,printer_id,copy FROM '.MAIN_DB_PREFIX.'printing WHERE module="'.$module.'" AND driver="printipp"'; + $result = $db->query($sql); + if ($result) + { + $obj = $this->db->fetch_object($result); + if ($obj) + { + $ipp->setPrinterURI($obj->printer_id); + } + else + { + if (! empty($conf->global->PRINTIPP_URI_DEFAULT)) + { + $ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT); + } + else + { + return 'NoDefaultPrinterDefined'; + } + } + } + + // Set number of copy + $ipp->setCopies($obj->copy); + $fileprint=$conf->{$module}->dir_output; + if ($subdir!='') $fileprint.='/'.$subdir; + $fileprint.='/'.$file; + $ipp->setData($fileprint); + $ipp->printJob(); + + return ''; + } + + /** + * Return list of available printers + * + * @return string html list of printers + */ + function listAvailablePrinters() + { + global $bc, $conf, $langs; + $var=true; + $html = '
NamedisplayNameIdOwnerNameStateconnectionStatusType'.$langs->trans("Select").'
'.print_r($list,true).'
'.$printer_det['name'].''.$printer_det['displayName'].''.$printer_det['id'].''.$printer_det['ownerName'].''.$printer_det['status'].''.$langs->trans('STATE_'.$printer_det['connectionStatus']).''.$langs->trans('TYPE_'.$printer_det['type']).''; + if ($conf->global->PRINTING_GCP_DEFAULT == $printer_det['id']) + { + $html.= img_picto($langs->trans("Default"),'on'); + } + else + $html.= ''.img_picto($langs->trans("Disabled"),'off').''; + $html.= '
'; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + //$html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= "\n"; + $list = $this->getlist_available_printers(); + $var = true; + foreach ($list as $value) + { + $var=!$var; + $printer_det = $this->get_printer_detail($value); + $html.= ""; + $html.= ''; + //$html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + //$html.= ''; + $html.= ''; + $html.= ''; + // Defaut + $html.= ''; + $html.= ''."\n"; + } + + return $html; + } + + /** + * Return list of available printers + * + * @return array list of printers + */ + function getlist_available_printers() + { + global $conf,$db; + include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; + $ipp = new CupsPrintIPP(); + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose + $ipp->setHost($this->host); + $ipp->setPort($this->port); + $ipp->setUserName($this->userid); + if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); + $ipp->getPrinters(); + return $ipp->available_printers; + } + + /** + * Get printer detail + * + * @param string $uri URI + * @return array List of attributes + */ + function get_printer_detail($uri) + { + global $conf,$db; + + include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; + $ipp = new CupsPrintIPP(); + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose + $ipp->setHost($this->host); + $ipp->setPort($this->port); + $ipp->setUserName($this->userid); + if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); + $ipp->setPrinterURI($uri); + $ipp->getPrinterAttributes(); + return $ipp->printer_attributes; + } + + /** + * List jobs print + * + * @param string $module module + * + * @return void + */ + function list_jobs($module) + { + global $conf, $db, $bc; + include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; + $ipp = new CupsPrintIPP(); + $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose + $ipp->setHost($this->host); + $ipp->setPort($this->port); + $ipp->setUserName($this->userid); + if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); + // select printer uri for module order, propal,... + $sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"'; + $result = $this->db->query($sql); + if ($result) + { + $obj = $this->db->fetch_object($result); + if ($obj) + { + $ipp->setPrinterURI($obj->printer_uri); + } + else + { + // All printers + $ipp->setPrinterURI("ipp://localhost:631/printers/"); + } + } + // Getting Jobs + $ipp->getJobs(false,0,'completed',false); + print '
UriNameStateState_reasonState_reason1BWColorDeviceMediaSupported'.$langs->trans("Select").'
'.$value.'
'.print_r($printer_det,true).'
'.$printer_det->printer_name->_value0.''.$printer_det->printer_state->_value0.''.$printer_det->printer_state_reasons->_value0.''.$printer_det->printer_state_reasons->_value1.''.$printer_det->printer_type->_value2.''.$printer_det->printer_type->_value3.''.$printer_det->device_uri->_value0.''.$printer_det->media_default->_value0.''.$printer_det->media_type_supported->_value1.''; + if ($conf->global->PRINTIPP_URI_DEFAULT == $value) + { + $html.= img_picto($langs->trans("Default"),'on'); + } + else + $html.= ''.img_picto($langs->trans("Disabled"),'off').''; + $html.= '
'; + print ''; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $jobs = $ipp->jobs_attributes; + $var = True; + //print '
'.print_r($jobs,true).'
'; + foreach ($jobs as $value ) + { + $var=!$var; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + print "
IdOwnerPrinterFileStatusCancel
'.$value->job_id->_value0.''.$value->job_originating_user_name->_value0.''.$value->printer_uri->_value0.''.$value->job_name->_value0.''.$value->job_state->_value0.''.$value->job_uri->_value0.'
"; + } + +} diff --git a/htdocs/core/triggers/interface_60_modPrinting_Printing.class.php b/htdocs/core/triggers/interface_60_modPrinting_Printing.class.php deleted file mode 100644 index b02b16f4796..00000000000 --- a/htdocs/core/triggers/interface_60_modPrinting_Printing.class.php +++ /dev/null @@ -1,71 +0,0 @@ - - * Copyright (C) 2005-2014 Regis Houssin - * Copyright (C) 2014 Marcos García - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/triggers/interface_60_modPrinting_Printing.class.php - * \ingroup printing - * \brief Trigger call by printing to print with PrintIPP - * \remarks - */ -require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; - - -/** - * Class of triggers for printing - */ -class InterfacePrinting extends DolibarrTriggers -{ - - public $family = 'printing'; - public $picto = 'technic'; - public $description = "Triggers of this module is used for printing via PrintIPP."; - public $version = self::VERSION_DOLIBARR; - - /** - * Function called when a Dolibarrr business event is done. - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) - * - * @param string $action Event action code - * @param Object $object Object - * @param User $user Object user - * @param Translate $langs Object langs - * @param conf $conf Object conf - * @return int <0 if KO, 0 if no triggered ran, >0 if OK - */ - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) - { - global $db; - // Put here code you want to execute when a Dolibarr business events occurs. - // Data and type of action are stored into $object and $action - - // Actions - - if ($action=='PRINT_DOCPDF') { - require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; - $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); - $result = $printer->print_file($object->file, $object->printer); - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - //$this->errors[]='test'; - //return -1; - return 1; - } - return 0; - } - -} diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index b4ca3504347..1f01d4ad981 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -414,6 +414,8 @@ if (GETPOST('removedfile','alpha')) $action ='presend'; } +include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + /* * Send mail */ diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index a190f102023..ee73492d9f0 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -26,4 +26,19 @@ create table llx_c_price_expression expression varchar(80) NOT NULL )ENGINE=innodb; +--create table for user conf of printing driver +CREATE TABLE llx_printing +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + datec datetime, + printer_name text NOT NULL, + printer_location text NOT NULL, + printer_id varchar(255) NOT NULL, + copy integer NOT NULL DEFAULT '1', + module varchar(16) NOT NULL, + driver varchar(16) NOT NULL, + userid integer +)ENGINE=innodb; + ALTER TABLE llx_product_fournisseur_price ADD fk_price_expression integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_printer_ipp.sql b/htdocs/install/mysql/tables/llx_printing.sql similarity index 83% rename from htdocs/install/mysql/tables/llx_printer_ipp.sql rename to htdocs/install/mysql/tables/llx_printing.sql index a19e05587d6..3da96b1e6b8 100644 --- a/htdocs/install/mysql/tables/llx_printer_ipp.sql +++ b/htdocs/install/mysql/tables/llx_printing.sql @@ -1,5 +1,5 @@ -- ============================================================================ --- Copyright (C) 2013 Florian HENRY +-- Copyright (C) 2014 Frederic France -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -16,15 +16,16 @@ -- -- ============================================================================ -CREATE TABLE llx_printer_ipp +CREATE TABLE llx_printing ( rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, - datec datetime, + tms timestamp, + datec datetime, printer_name text NOT NULL, printer_location text NOT NULL, - printer_uri varchar(255) NOT NULL, + printer_id varchar(255) NOT NULL, copy integer NOT NULL DEFAULT '1', module varchar(16) NOT NULL, - login varchar(32) NOT NULL + driver varchar(16) NOT NULL, + userid integer )ENGINE=innodb; diff --git a/htdocs/langs/en_US/printgcp.lang b/htdocs/langs/en_US/printgcp.lang new file mode 100644 index 00000000000..9751649a738 --- /dev/null +++ b/htdocs/langs/en_US/printgcp.lang @@ -0,0 +1,18 @@ +# Dolibarr language file - Source file is en_US - printgccp +PRINTGCP=Google Cloud Print +PrintGCPDesc=This driver allow to send documents directly to a printer with Google Cloud Print. +PrintingDriverDescprintgcp=Configuration variables for printing driver Google Cloud Print. +PrintTestDescprintgcp=List of Printers for Google Cloud Print. +PRINTGCP_LOGIN=Google Account Login +PRINTGCP_PASSWORD=Google Account Password +STATE_ONLINE=Online +STATE_UNKNOWN=Unknown +STATE_OFFLINE=Offline +STATE_DORMANT=Offline for quite a while +TYPE_GOOGLE=Google +TYPE_HP=HP Printer +TYPE_DOCS=DOCS +TYPE_DRIVE=Google Drive +TYPE_FEDEX=Fedex +TYPE_ANDROID_CHROME_SNAPSHOT=Android +TYPE_IOS_CHROME_SNAPSHOT=IOS diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang new file mode 100644 index 00000000000..77c63884636 --- /dev/null +++ b/htdocs/langs/en_US/printing.lang @@ -0,0 +1,10 @@ +# Dolibarr language file - Source file is en_US - printing +PrintingSetup=Setup of Printing System +PrintingDesc=This module adds a Print button to send documents directly to a printer with various module. +ModuleDriverSetup=Setup Module Driver +PrintingDriverDesc=Configuration variables for printing driver. +ListDrivers=List of drivers +PrintTestDesc=List of Printers. +FileWasSentToPrinter=File %s was sent to printer +NoActivePrintingModuleFound=No active module to print document +PleaseSelectaDriverfromList=Please select a driver from list. diff --git a/htdocs/langs/en_US/printipp.lang b/htdocs/langs/en_US/printipp.lang index 835e6827f12..2a10ddfe710 100644 --- a/htdocs/langs/en_US/printipp.lang +++ b/htdocs/langs/en_US/printipp.lang @@ -1,6 +1,9 @@ # Dolibarr language file - Source file is en_US - printipp +PRINTIPP=PrintIPP Driver PrintIPPSetup=Setup of Direct Print module -PrintIPPDesc=This module adds a Print button to send documents directly to a printer. It requires a Linux system with CUPS installed. +PrintIPPDesc=This driver allow to send documents directly to a printer. It requires a Linux system with CUPS installed. +PrintingDriverDescprintipp=Configuration variables for printing driver PrintIPP. +PrintTestDescprintipp=List of Printers for driver PrintIPP. PRINTIPP_ENABLED=Show "Direct print" icon in document lists PRINTIPP_HOST=Print server PRINTIPP_PORT=Port diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 29bd8787fa0..f12c235dc2c 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -26,8 +26,8 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -//require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php'; -//require_once DOL_DOCUMENT_ROOT.'/printing/lib/printing.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; +require_once DOL_DOCUMENT_ROOT.'/printing/lib/printing.lib.php'; $langs->load("admin"); $langs->load("printing"); @@ -37,14 +37,58 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $mode = GETPOST('mode','alpha'); $value = GETPOST('value','alpha'); +$varname = GETPOST('varname', 'alpha'); +$driver = GETPOST('driver', 'alpha'); + +if (! empty($driver)) $langs->load($driver); if (!$mode) $mode='config'; /* * Action */ +if ($action == 'setconst' && $user->admin) +{ + $error=0; + $db->begin(); + foreach ($_POST['setupdriver'] as $setupconst) { + //print '
'.print_r($setupconst, true).'
'; + $result=dolibarr_set_const($db, $setupconst['varname'],$setupconst['value'],'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + } + if (! $error) + { + $db->commit(); + setEventMessage($langs->trans("SetupSaved")); + } + else + { + $db->rollback(); + dol_print_error($db); + } + $action=''; +} +if ($action == 'setvalue' && $user->admin) +{ + $db->begin(); + + $result=dolibarr_set_const($db, $varname, $value,'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + + if (! $error) + { + $db->commit(); + setEventMessage($langs->trans("SetupSaved")); + } + else + { + $db->rollback(); + dol_print_error($db); + } + $action = ''; +} /* * View @@ -55,73 +99,131 @@ $form = new Form($db); llxHeader('',$langs->trans("PrintingSetup")); $linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre($langs->trans("PrintIPPSetup"),$linkback,'setup'); +print_fiche_titre($langs->trans("PrintingSetup"),$linkback,'setup'); -//$head=printippadmin_prepare_head(); +$head=printingadmin_prepare_head(); +if ($mode == 'setup' && $user->admin) +{ + print '
'; + print ''; + print ''; + dol_fiche_head($head, $mode, $langs->trans("ModuleDriverSetup"), 0, 'technic'); + + print $langs->trans("PrintingDriverDesc".$driver)."

\n"; + + print ''."\n"; + $var=true; + print ''; + print ''; + print ''; + print "\n"; + + if (! empty($driver)) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; + $classname = 'printing_'.$driver; + $printer = new $classname($db); + //print '
'.print_r($printer, true).'
'; + $i=0; + foreach ($printer->conf as $key) { + $var=!$var; + print ''; + print ''.$langs->trans($key['varname']).''; + $i++; + } + } else { + print $langs->trans('PleaseSelectaDriverfromList'); + } + + print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; + print ''; + print ''; + print ' '.($key['example']!=''?$langs->trans("Example").' : '.$key['example']:''); + print '
'; + if (! empty($driver)) { + print '
'; + } + print ''; + dol_fiche_end(); + +} if ($mode == 'config' && $user->admin) { - print '
'; - print ''; - print ''; - dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic'); print $langs->trans("PrintingDesc")."

\n"; - print ''; + print '
'."\n"; $var=true; print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; - - $var=!$var; - print ''; - - $var=!$var; - print ''; - - $var=!$var; - print ''; - - $var=!$var; - print ''; + $object = new PrintingDriver($db); + $result = $object->listDrivers($db, 10); + foreach ($result as $driver) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; + $classname = 'printing_'.$driver; + $langs->load($driver); + $printer = new $classname($db); + //print '
'.print_r($printer, true).'
'; + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; + } print '
'.$langs->trans("Parameters").''.$langs->trans("Value").''.$langs->trans("Description").''.$langs->trans("Active").''.$langs->trans("Setup").''.$langs->trans("Test").'
'; - print $langs->trans("PRINTIPP_HOST").''; - print ''; - print '   '.$langs->trans("Example").': localhost'; - print '
'; - print $langs->trans("PRINTIPP_PORT").''; - print ''; - print '   '.$langs->trans("Example").': 631'; - print '
'; - print $langs->trans("PRINTIPP_USER").''; - print ''; - print '
'; - print $langs->trans("PRINTIPP_PASSWORD").''; - print ''; - print '
'.img_picto('', $printer->picto).$langs->trans($printer->desc).''; + if (! empty($conf->use_javascript_ajax)) + { + print ajax_constantonoff($printer->active); + } + else + { + if (empty($conf->global->{$printer->conf})) + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + else + { + print ''.img_picto($langs->trans("Enabled"),'on').''; + } + } + print ''.img_picto('', 'setup').''.img_picto('', 'setup').'
'; dol_fiche_end(); +} + +if ($mode == 'test' && $user->admin) +{ + dol_fiche_head($head, $mode, $langs->trans("PrintingTest"), 0, 'technic'); + + print $langs->trans('PrintTestDesc'.$driver)."

\n"; - //print '
'; - + print ''; + if (! empty($driver)) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; + $classname = 'printing_'.$driver; + $printer = new $classname($db); + //print '
'.print_r($printer, true).'
'; + print $printer->listAvailablePrinters(); - print ''; - - - //if (count($list) == 0) print $langs->trans("NoPrinterFound"); + } else { + print $langs->trans('PleaseSelectaDriverfromList'); + } + print '
'; dol_fiche_end(); } - llxFooter(); $db->close(); diff --git a/htdocs/printipp/lib/index.html b/htdocs/printing/lib/index.html similarity index 100% rename from htdocs/printipp/lib/index.html rename to htdocs/printing/lib/index.html diff --git a/htdocs/printipp/lib/printipp.lib.php b/htdocs/printing/lib/printing.lib.php similarity index 59% rename from htdocs/printipp/lib/printipp.lib.php rename to htdocs/printing/lib/printing.lib.php index 64c14609df5..fd02c240b15 100644 --- a/htdocs/printipp/lib/printipp.lib.php +++ b/htdocs/printing/lib/printing.lib.php @@ -16,44 +16,49 @@ */ /** - * \file htdocs/printipp/lib/printipp.lib.php - * \ingroup printipp - * \brief Library for printipp functions + * \file htdocs/printing/lib/printing.lib.php + * \ingroup printing + * \brief Library for printing functions */ /** - * Define head array for tabs of printipp tools setup pages + * Define head array for tabs of printing tools setup pages * * @return Array of head */ -function printippadmin_prepare_head() +function printingadmin_prepare_head() { global $langs, $conf; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT."/printipp/admin/printipp.php?mode=config"; - $head[$h][1] = $langs->trans("CupsServer"); + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=config"; + $head[$h][1] = $langs->trans("ListDrivers"); $head[$h][2] = 'config'; $h++; - $head[$h][0] = DOL_URL_ROOT."/printipp/admin/printipp.php?mode=test"; - $head[$h][1] = $langs->trans("Printer"); + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup"; + $head[$h][1] = $langs->trans("SetupDriver"); + $head[$h][2] = 'setup'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test"; + $head[$h][1] = $langs->trans("TestDriver"); $head[$h][2] = 'test'; $h++; - $object=new stdClass(); + //$object=new stdClass(); // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf,$langs,$object,$head,$h,'printippadmin'); + //complete_head_from_modules($conf,$langs,$object,$head,$h,'printingadmin'); - complete_head_from_modules($conf,$langs,$object,$head,$h,'printipp','remove'); + //complete_head_from_modules($conf,$langs,$object,$head,$h,'printing','remove'); return $head; } diff --git a/htdocs/printipp/admin/printipp.php b/htdocs/printipp/admin/printipp.php deleted file mode 100644 index 28ad55453eb..00000000000 --- a/htdocs/printipp/admin/printipp.php +++ /dev/null @@ -1,246 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/printipp/admin/printipp.php - * \ingroup printipp - * \brief Page to setup printipp module - */ - -require '../../main.inc.php'; - -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php'; -require_once DOL_DOCUMENT_ROOT.'/printipp/lib/printipp.lib.php'; - -$langs->load("admin"); -$langs->load("printipp"); - -if (! $user->admin) accessforbidden(); - -$action = GETPOST('action','alpha'); -$mode = GETPOST('mode','alpha'); -$value = GETPOST('value','alpha'); - -if (!$mode) $mode='config'; - -/* - * Action - */ - -if ($action == 'setvalue' && $user->admin) -{ - $db->begin(); - - if (! $result > 0) $error++; - $result=dolibarr_set_const($db, "PRINTIPP_HOST",GETPOST('PRINTIPP_HOST','alpha'),'chaine',0,'',$conf->entity); - if (! $result > 0) $error++; - $result=dolibarr_set_const($db, "PRINTIPP_PORT",GETPOST('PRINTIPP_PORT','alpha'),'chaine',0,'',$conf->entity); - if (! $result > 0) $error++; - $result=dolibarr_set_const($db, "PRINTIPP_USER",GETPOST('PRINTIPP_USER','alpha'),'chaine',0,'',$conf->entity); - if (! $result > 0) $error++; - $result=dolibarr_set_const($db, "PRINTIPP_PASSWORD",GETPOST('PRINTIPP_PASSWORD','alpha'),'chaine',0,'',$conf->entity); - if (! $result > 0) $error++; - - if (! $error) - { - $db->commit(); - setEventMessage($langs->trans("SetupSaved")); - } - else - { - $db->rollback(); - dol_print_error($db); - } -} - -// Set default model -else if ($action == 'setprinteruri') -{ - if (dolibarr_set_const($db, "PRINTIPP_URI_DEFAULT",$value,'chaine',0,'',$conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->PRINTIPP_URI_DEFAULT = $value; - } -} - - -/* - * View - */ - -$form = new Form($db); - -llxHeader('',$langs->trans("PrintIPPSetup")); - -$linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre($langs->trans("PrintIPPSetup"),$linkback,'setup'); - -$head=printippadmin_prepare_head(); - - -if ($mode == 'config' && $user->admin) -{ - print '
'; - print ''; - print ''; - - dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic'); - - print $langs->trans("PrintIPPDesc")."

\n"; - - print ''; - - $var=true; - print ''; - print ''; - print ''; - print "\n"; - - /* - $var=!$var; - print ''; - */ - - $var=!$var; - print ''; - - $var=!$var; - print ''; - - $var=!$var; - print ''; - - $var=!$var; - print ''; - - //$var=true; - //print ''; - //print ''; - //print ''; - //print "\n"; - - print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; - print $langs->trans("PRINTIPP_ENABLED").''; - - if (! empty($conf->use_javascript_ajax)) - { - print ajax_constantonoff('PRINTIPP_ENABLED'); - } - else - { - if (empty($conf->global->PRINTIPP_ENABLED)) - { - print ''.img_picto($langs->trans("Disabled"),'off').''; - } - else - { - print ''.img_picto($langs->trans("Enabled"),'on').''; - } - } - print '
'; - print $langs->trans("PRINTIPP_HOST").''; - print ''; - print '   '.$langs->trans("Example").': localhost'; - print '
'; - print $langs->trans("PRINTIPP_PORT").''; - print ''; - print '   '.$langs->trans("Example").': 631'; - print '
'; - print $langs->trans("PRINTIPP_USER").''; - print ''; - print '
'; - print $langs->trans("PRINTIPP_PASSWORD").''; - print ''; - print '
'.$langs->trans("OtherParameter").''.$langs->trans("Value").'
'; - - dol_fiche_end(); - - print '
'; - - print ''; -} - -if ($mode == 'test' && $user->admin) -{ - dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic'); - - print $langs->trans("PrintIPPDesc")."

\n"; - - print ''; - $printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD); - $var=true; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print ''; - print ''; - print ''; - print "\n"; - - $list = $printer->getlist_available_printers(); - $var = true; - foreach ($list as $value) - { - $var=!$var; - $printer_det = $printer->get_printer_detail($value); - print ""; - print ''; - //print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print ''; - print ''; - // Defaut - print "'; - print "\n"; - } - print '
UriNameStateState_reasonState_reason1BWColorDeviceMediaSupported'.$langs->trans("Select").'
'.$value.'
'.print_r($printer_det,true).'
'.$printer_det->printer_name->_value0.''.$printer_det->printer_state->_value0.''.$printer_det->printer_state_reasons->_value0.''.$printer_det->printer_state_reasons->_value1.''.$printer_det->printer_type->_value2.''.$printer_det->printer_type->_value3.''.$printer_det->device_uri->_value0.''.$printer_det->media_default->_value0.''.$printer_det->media_type_supported->_value1.'"; - if ($conf->global->PRINTIPP_URI_DEFAULT == "$value") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print ''.img_picto($langs->trans("Disabled"),'off').''; - } - print '
'; - - if (count($list) == 0) print $langs->trans("NoPrinterFound"); - - dol_fiche_end(); -} - - - -llxFooter(); - -$db->close(); diff --git a/htdocs/printipp/index.php b/htdocs/printipp/index.php deleted file mode 100644 index a130805f16e..00000000000 --- a/htdocs/printipp/index.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -/** - * \file htdocs/printipp/index.php - * \ingroup printipp - * \brief Printipp - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php'; - -llxHeader("",$langs->trans("Printer")); - -print_fiche_titre($langs->trans("Printer")); - -$printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD); -$printer->list_jobs('commande'); - -llxFooter(); - -$db->close(); From 9bb1999dc2f1191c438d94c5866c450a9edc4f7c Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 8 Dec 2014 21:07:24 +0100 Subject: [PATCH 033/152] Some correct --- .../core/modules/printing/printgcp.modules.php | 16 ++++++++-------- htdocs/install/mysql/tables/llx_printing.sql | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 7041e112811..b9cc1aa0b37 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -130,7 +130,7 @@ class printing_printgcp extends PrintingDriver * * @return array list of printers */ - public function get_printer_detail() + function get_printer_detail() { // Check if we have auth token if(empty($this->authtoken)) { @@ -159,10 +159,10 @@ class printing_printgcp extends PrintingDriver * * @param string $file file * @param string $module module - * + * @param string $subdir subdir for file * @return string '' if OK, Error message if KO */ - public function print_file($file, $module, $subdir='') + function print_file($file, $module, $subdir='') { global $conf; if ($this->authtoken=='') { @@ -256,8 +256,8 @@ class printing_printgcp extends PrintingDriver } /** - * * Parse json response and return printers array + * * @param string $jsonobj Json response object * @return array return array of printers */ @@ -298,10 +298,10 @@ class printing_printgcp extends PrintingDriver /** * Curl request * - * @param string $url url to hit - * @param array $postfields array of post fields - * @param array $headers array of http headers - * @return + * @param string $url url to hit + * @param array $postfields array of post fields + * @param array $headers array of http headers + * @return array response from curl */ private function makeCurl($url,$postfields=array(),$headers=array()) { diff --git a/htdocs/install/mysql/tables/llx_printing.sql b/htdocs/install/mysql/tables/llx_printing.sql index 3da96b1e6b8..451564ff74b 100644 --- a/htdocs/install/mysql/tables/llx_printing.sql +++ b/htdocs/install/mysql/tables/llx_printing.sql @@ -1,5 +1,6 @@ -- ============================================================================ --- Copyright (C) 2014 Frederic France +-- Copyright (C) 2013 Florian HENRY +-- Copyright (C) 2014 Frederic France -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by From 715d0f18db80f617b455c593318de3ef8905b433 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 8 Dec 2014 21:52:53 +0100 Subject: [PATCH 034/152] Lang correction --- htdocs/core/modules/modPrinting.class.php | 2 -- .../modules/printing/printgcp.modules.php | 14 ++++---- .../modules/printing/printipp.modules.php | 32 +++++++++---------- htdocs/langs/en_US/printgcp.lang | 7 ++++ htdocs/langs/en_US/printipp.lang | 20 ++++++++++++ 5 files changed, 50 insertions(+), 25 deletions(-) diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index 00c59eaf285..12d73e33875 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -131,7 +131,6 @@ class modPrinting extends DolibarrModules */ function init($options='') { - // insertion modele dans llx_document_model $sql = array(); return $this->_init($sql, $options); @@ -147,7 +146,6 @@ class modPrinting extends DolibarrModules */ function remove($options='') { - // suppression des modeles "printing" $sql = array(); return $this->_remove($sql, $options); diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index b9cc1aa0b37..de414b9d18b 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -72,13 +72,13 @@ class printing_printgcp extends PrintingDriver $var=true; $html = ''; $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; $html.= ''; $html.= ''."\n"; $list = $this->getlist_available_printers(); diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index 5252341c2d3..7f789b859eb 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -131,16 +131,16 @@ class printing_printipp extends PrintingDriver $var=true; $html = '
NamedisplayNameIdOwnerNameStateconnectionStatusType'.$langs->trans('GCP_Name').''.$langs->trans('GCP_displayName').''.$langs->trans('GCP_Id').''.$langs->trans('GCP_OwnerName').''.$langs->trans('GCP_State').''.$langs->trans('GCP_connectionStatus').''.$langs->trans('GCP_Type').''.$langs->trans("Select").'
'; $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - //$html.= ''; - $html.= ''; - $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + //$html.= ''; + $html.= ''; + $html.= ''; $html.= ''; $html.= "\n"; $list = $this->getlist_available_printers(); @@ -153,14 +153,14 @@ class printing_printipp extends PrintingDriver $html.= ''; //$html.= ''; $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; - $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; //$html.= ''; $html.= ''; - $html.= ''; + $html.= ''; // Defaut $html.= ''; print ''; print ''; + print ''; print "\n"; - $sql = 'SELECT p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid'; + $sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid'; $resql = $db->query($sql); while ($row=$db->fetch_array($resql)) { $var=!$var; @@ -254,6 +263,7 @@ if ($mode == 'userconf' && $user->admin) print ''; print ''; print ''; + print ''; print "\n"; } print '
UriNameStateState_reasonState_reason1BWColorDeviceMediaSupported'.$langs->trans('IPP_Uri').''.$langs->trans('IPP_Name').''.$langs->trans('IPP_State').''.$langs->trans('IPP_State_reason').''.$langs->trans('IPP_State_reason1').''.$langs->trans('IPP_BW').''.$langs->trans('IPP_Color').''.$langs->trans('IPP_Device').''.$langs->trans('IPP_Media').''.$langs->trans('IPP_Supported').''.$langs->trans("Select").'
'.$value.'
'.print_r($printer_det,true).'
'.$printer_det->printer_name->_value0.''.$printer_det->printer_state->_value0.''.$printer_det->printer_state_reasons->_value0.''.$printer_det->printer_state_reasons->_value1.''.$printer_det->printer_type->_value2.''.$printer_det->printer_type->_value3.''.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).''.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).''.(! empty($printer_det->printer_state_reasons->_value1)?$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1):'').''.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).''.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).''.$printer_det->device_uri->_value0.''.$printer_det->media_default->_value0.''.$printer_det->media_type_supported->_value1.''.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).''; if ($conf->global->PRINTIPP_URI_DEFAULT == $value) diff --git a/htdocs/langs/en_US/printgcp.lang b/htdocs/langs/en_US/printgcp.lang index 9751649a738..ded5fb63d6e 100644 --- a/htdocs/langs/en_US/printgcp.lang +++ b/htdocs/langs/en_US/printgcp.lang @@ -16,3 +16,10 @@ TYPE_DRIVE=Google Drive TYPE_FEDEX=Fedex TYPE_ANDROID_CHROME_SNAPSHOT=Android TYPE_IOS_CHROME_SNAPSHOT=IOS +GCP_Name=Name +GCP_displayName=Display Name +GCP_Id=Printer Id +GCP_OwnerName=Owner Name +GCP_State=Printer State +GCP_connectionStatus=Online State +GCP_Type=Printer Type diff --git a/htdocs/langs/en_US/printipp.lang b/htdocs/langs/en_US/printipp.lang index 2a10ddfe710..e85d53627c4 100644 --- a/htdocs/langs/en_US/printipp.lang +++ b/htdocs/langs/en_US/printipp.lang @@ -15,3 +15,23 @@ NoDefaultPrinterDefined=No default printer defined DefaultPrinter=Default printer Printer=Printer CupsServer=CUPS Server +IPP_Uri=Printer Uri +IPP_Name=Printer Name +IPP_State=Printer State +IPP_State_reason=State reason +IPP_State_reason1=State reason1 +IPP_BW=BW +IPP_Color=Color +IPP_Device=Device +IPP_Media=Printer media +IPP_Supported=Type of media +STATE_IPP_idle=Idle +STATE_IPP_stopped=Stopped +STATE_IPP_paused=Paused +STATE_IPP_toner-low-report=Low Toner +STATE_IPP_none=None +MEDIA_IPP_stationery=Stationery +MEDIA_IPP_thermal=Thermal +IPP_COLOR_print-black=BW Printer +IPP_COLOR_print-color=Color Printer +IPP_COLOR_=No From 16d860b3f7156fd87779c50144c37a973e9560b6 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 8 Dec 2014 22:17:28 +0100 Subject: [PATCH 035/152] Lang Correction --- htdocs/core/class/html.formfile.class.php | 6 +++--- htdocs/core/modules/printing/printgcp.modules.php | 2 ++ htdocs/core/modules/printing/printipp.modules.php | 2 ++ htdocs/langs/en_US/main.lang | 1 + htdocs/printing/admin/printing.php | 2 ++ 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 5081af493d5..c67a3196b33 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -614,9 +614,9 @@ class FormFile if ($printer) { //$out.= ''; - $out.= ' '.img_picto($langs->trans("Print"),'printer.png').''; + $out.= ' '.img_picto($langs->trans("PrintFile", $relativepath),'printer.png').''; } if ($morepicto) { diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index de414b9d18b..ab0ed428a69 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -1,5 +1,7 @@ + * * 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 diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index 7f789b859eb..013d9922e10 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -1,5 +1,7 @@ + * * 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 diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index cbc4deb40d7..4b27d7b285d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -683,6 +683,7 @@ XMoreLines=%s line(s) hidden PublicUrl=Public URL AddBox=Add box SelectElementAndClickRefresh=Select an element and click Refresh +PrintFile=Print File %s # Week day Monday=Monday Tuesday=Tuesday diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index f12c235dc2c..9db8a55af82 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -123,6 +123,7 @@ if ($mode == 'setup' && $user->admin) if (! empty($driver)) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; $classname = 'printing_'.$driver; + $langs->load($driver); $printer = new $classname($db); //print '
'.print_r($printer, true).'
'; $i=0; @@ -211,6 +212,7 @@ if ($mode == 'test' && $user->admin) if (! empty($driver)) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; $classname = 'printing_'.$driver; + $langs->load($driver); $printer = new $classname($db); //print '
'.print_r($printer, true).'
'; print $printer->listAvailablePrinters(); From 6b4d7b973b475a0501dd4b8052f2808d7a3cbb17 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 8 Dec 2014 23:30:17 +0100 Subject: [PATCH 036/152] Some changes --- htdocs/core/modules/modPrinting.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index 12d73e33875..f578c463d43 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -51,7 +51,7 @@ class modPrinting extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable Printing System."; - $this->version = 'experimental'; // 'development' or 'experimental' or 'dolibarr' or version + $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) $this->special = 1; From 608f4a7d7d8624d296c5530bd1f35e9cc6927f18 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Tue, 9 Dec 2014 23:37:04 +0100 Subject: [PATCH 037/152] Some correct html --- htdocs/core/modules/printing/printgcp.modules.php | 4 ++-- htdocs/core/modules/printing/printipp.modules.php | 4 ++-- htdocs/printing/admin/printing.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index ab0ed428a69..be479dd82f7 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -72,8 +72,8 @@ class printing_printgcp extends PrintingDriver global $bc, $conf, $langs; $langs->load('printgcp'); $var=true; - $html = ''; - $html.= ''; + + $html = ''; $html.= ''; $html.= ''; $html.= ''; diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index 013d9922e10..2e4b4c7161a 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -131,8 +131,8 @@ class printing_printipp extends PrintingDriver { global $bc, $conf, $langs; $var=true; - $html = '
'.$langs->trans('GCP_Name').''.$langs->trans('GCP_displayName').''.$langs->trans('GCP_Id').'
'; - $html.= ''; + + $html = ''; $html.= ''; $html.= ''; $html.= ''; diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 9db8a55af82..53b192c35e4 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -208,7 +208,7 @@ if ($mode == 'test' && $user->admin) print $langs->trans('PrintTestDesc'.$driver)."

\n"; - print '
'.$langs->trans('IPP_Uri').''.$langs->trans('IPP_Name').''.$langs->trans('IPP_State').'
'; + print '
'; if (! empty($driver)) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; $classname = 'printing_'.$driver; From df28ce77c084455b94a6864d8097058eaf9b221c Mon Sep 17 00:00:00 2001 From: frederic34 Date: Thu, 11 Dec 2014 21:58:56 +0100 Subject: [PATCH 038/152] Some progress on Printing --- .../modules/printing/printgcp.modules.php | 26 ++++++++++++-- .../modules/printing/printipp.modules.php | 4 +-- htdocs/printing/admin/printing.php | 36 +++++++++++++++++++ htdocs/printing/lib/printing.lib.php | 5 +++ 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index be479dd82f7..2091c1a89eb 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -166,7 +166,7 @@ class printing_printgcp extends PrintingDriver */ function print_file($file, $module, $subdir='') { - global $conf; + global $conf, $user, $db; if ($this->authtoken=='') { $this->GoogleLogin(); } @@ -174,8 +174,30 @@ class printing_printgcp extends PrintingDriver $fileprint=$conf->{$module}->dir_output; if ($subdir!='') $fileprint.='/'.$subdir; $fileprint.='/'.$file; + // select printer uri for module order, propal,... + $sql = 'SELECT rowid, printer_id, copy FROM '.MAIN_DB_PREFIX.'printing WHERE module="'.$module.'" AND driver="printgcp" AND userid='.$user->id; + $result = $db->query($sql); + if ($result) + { + $obj = $this->db->fetch_object($result); + if ($obj) + { + $printer_id=$obj->printer_id; + } + else + { + if (! empty($conf->global->PRINTIPP_GCP_DEFAULT)) + { + $printer_id=$conf->global->PRINTIPP_GCP_DEFAULT; + } + else + { + return 'NoDefaultPrinterDefined'; + } + } + } - $this->sendPrintToPrinter($conf->global->PRINTING_GCP_DEFAULT, $file, $fileprint, 'application/pdf'); + $this->sendPrintToPrinter($printer_id, $file, $fileprint, 'application/pdf'); } /** diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index 2e4b4c7161a..c8a19bffa31 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -76,7 +76,7 @@ class printing_printipp extends PrintingDriver */ function print_file($file, $module, $subdir='') { - global $conf,$db; + global $conf, $user, $db; include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; @@ -89,7 +89,7 @@ class printing_printipp extends PrintingDriver if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); // select printer uri for module order, propal,... - $sql = 'SELECT rowid,printer_id,copy FROM '.MAIN_DB_PREFIX.'printing WHERE module="'.$module.'" AND driver="printipp"'; + $sql = 'SELECT rowid,printer_id,copy FROM '.MAIN_DB_PREFIX.'printing WHERE module="'.$module.'" AND driver="printipp" AND userid='.$user->id; $result = $db->query($sql); if ($result) { diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 53b192c35e4..64823e63195 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -225,6 +225,42 @@ if ($mode == 'test' && $user->admin) dol_fiche_end(); } +if ($mode == 'userconf' && $user->admin) +{ + dol_fiche_head($head, $mode, $langs->trans("UserConf"), 0, 'technic'); + + print $langs->trans('PrintUserConfDesc'.$driver)."

\n"; + + print '
'; + $var=true; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $sql = 'SELECT p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid'; + $resql = $db->query($sql); + while ($row=$db->fetch_array($resql)) { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + print '
'.$langs->trans("User").''.$langs->trans("PrintModule").''.$langs->trans("PrintDriver").''.$langs->trans("Printer").''.$langs->trans("PrinterLocation").''.$langs->trans("PrinterId").''.$langs->trans("NumberOfCopy").'
'.$row['login'].''.$row['module'].''.$row['driver'].''.$row['printer_name'].''.$row['printer_location'].''.$row['printer_id'].''.$row['copy'].'
'; + + dol_fiche_end(); + +} llxFooter(); diff --git a/htdocs/printing/lib/printing.lib.php b/htdocs/printing/lib/printing.lib.php index fd02c240b15..1d09daba0dc 100644 --- a/htdocs/printing/lib/printing.lib.php +++ b/htdocs/printing/lib/printing.lib.php @@ -50,6 +50,11 @@ function printingadmin_prepare_head() $head[$h][2] = 'test'; $h++; + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=userconf"; + $head[$h][1] = $langs->trans("UserConf"); + $head[$h][2] = 'userconf'; + $h++; + //$object=new stdClass(); // Show more tabs from modules From 74f8f83432c0c099ac5cce2e241eb407f054c952 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sat, 13 Dec 2014 13:53:48 +0100 Subject: [PATCH 039/152] WIP Printing --- htdocs/printing/admin/printing.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index 64823e63195..63784e560f0 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -47,6 +47,14 @@ if (!$mode) $mode='config'; /* * Action */ + +if (($mode == 'test' || $mode == 'setup') && empty($driver)) +{ + setEventMessage($langs->trans('PleaseSelectaDriverfromList')); + header("Location: ".$_SERVER['PHP_SELF'].'?mode=config'); + exit; +} + if ($action == 'setconst' && $user->admin) { $error=0; @@ -241,8 +249,9 @@ if ($mode == 'userconf' && $user->admin) print '
'.$langs->trans("PrinterLocation").''.$langs->trans("PrinterId").''.$langs->trans("NumberOfCopy").''.$langs->trans("Delete").'
'.$row['printer_location'].''.$row['printer_id'].''.$row['copy'].''.img_picto($langs->trans("Delete"), 'delete').'
'; From da7dc2a393cb4722ad320f6a8c6726a5e433f09d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Thu, 25 Dec 2014 22:02:22 +0100 Subject: [PATCH 040/152] Fix: [ bug #1765 ] Unable to create a contract --- htdocs/contrat/class/contrat.class.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ae384195162..6dd9c5661b3 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -46,7 +46,6 @@ class Contrat extends CommonObject var $id; var $ref; - var $ref_ext; var $ref_supplier; var $socid; var $societe; // Objet societe @@ -413,7 +412,6 @@ class Contrat extends CommonObject $sql.= " fk_commercial_signature, fk_commercial_suivi,"; $sql.= " note_private, note_public, model_pdf, extraparams"; $sql.= " ,ref_supplier"; - $sql.= " ,ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; if ($ref) { @@ -433,7 +431,6 @@ class Contrat extends CommonObject $this->id = $result["rowid"]; $this->ref = (!isset($result["ref"]) || !$result["ref"]) ? $result["rowid"] : $result["ref"]; $this->ref_supplier = $result["ref_supplier"]; - $this->ref_ext = $result["ref_ext"]; $this->statut = $result["statut"]; $this->mise_en_service = $this->db->jdate($result["datemise"]); $this->date_contrat = $this->db->jdate($result["datecontrat"]); @@ -735,7 +732,7 @@ class Contrat extends CommonObject // Insert contract $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat,"; $sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; - $sql.= " ref, entity, note_private, note_public, ref_supplier, ref_ext)"; + $sql.= " ref, entity, note_private, note_public, ref_supplier)"; $sql.= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id; $sql.= ", '".$this->db->idate($this->date_contrat)."'"; $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); @@ -746,7 +743,6 @@ class Contrat extends CommonObject $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->ref_supplier)?("'".$this->db->escape($this->ref_supplier)."'"):"NULL"); - $sql.= ", ".(!empty($this->ref_ext)?("'".$this->db->escape($this->ref_ext)."'"):"NULL"); $sql.= ")"; $resql=$this->db->query($sql); if ($resql) @@ -998,7 +994,6 @@ class Contrat extends CommonObject if (isset($this->ref)) $this->ref=trim($this->ref); if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); - if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext); if (isset($this->entity)) $this->entity=trim($this->entity); if (isset($this->statut)) $this->statut=trim($this->statut); if (isset($this->fk_soc)) $this->fk_soc=trim($this->fk_soc); @@ -1022,7 +1017,6 @@ class Contrat extends CommonObject $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; $sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").","; - $sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").","; $sql.= " entity=".$conf->entity.","; $sql.= " date_contrat=".(dol_strlen($this->date_contrat)!=0 ? "'".$this->db->idate($this->date_contrat)."'" : 'null').","; $sql.= " statut=".(isset($this->statut)?$this->statut:"null").","; From 310be3d3b690cae935ae0d1004e47a934923a09a Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sun, 28 Dec 2014 11:29:53 +0100 Subject: [PATCH 041/152] Update lib with github.com/mfly/php-ipp --- htdocs/includes/printipp/BasicIPP.php | 3846 ++++++++--------- htdocs/includes/printipp/CupsPrintIPP.php | 631 +-- htdocs/includes/printipp/ExtendedPrintIPP.php | 1139 +++-- htdocs/includes/printipp/PrintIPP.php | 1617 +++---- htdocs/includes/printipp/http_class.php | 1035 +++-- 5 files changed, 4365 insertions(+), 3903 deletions(-) diff --git a/htdocs/includes/printipp/BasicIPP.php b/htdocs/includes/printipp/BasicIPP.php index 3869c75bc06..1cc7851fab2 100644 --- a/htdocs/includes/printipp/BasicIPP.php +++ b/htdocs/includes/printipp/BasicIPP.php @@ -1,6 +1,6 @@ errno = $errno; - } - public function getErrorFormatted() - { - $return = sprintf("[ipp]: %s -- " . _(" file %s, line %s"), - $this->getMessage() , $this->getFile() , $this->getLine()); - return $return; - } - public function getErrno() - { - return $this->errno; - } + protected $errno; + + public function __construct($msg, $errno = null) + { + parent::__construct($msg); + $this->errno = $errno; + } + + public function getErrorFormatted() + { + $return = sprintf("[ipp]: %s -- " . _(" file %s, line %s"), + $this->getMessage() , $this->getFile() , $this->getLine()); + return $return; + } + + public function getErrno() + { + return $this->errno; + } } class BasicIPP { - // - // variables declaration - // - - // setup variables - - public $paths = array( - "root" => "/", - "admin" => "/admin/", - "printers" => "/printers/", - "jobs" => "/jobs/" - ); - public $http_timeout = 30; // timeout at http connection (seconds) 0 => default => 30. - public $http_data_timeout = 30; // data reading timeout (milliseconds) 0 => default => 30. - public $ssl = false; - public $debug_level = 3; // max 3: almost silent - public $alert_on_end_tag; // debugging purpose: echo "END tag OK" if (1 and reads while end tag) - public $with_exceptions = 0; // compatibility mode for old scripts - public $handle_http_exceptions = 1; - - // readables variables - - public $jobs = array(); - public $jobs_uri = array(); - public $status = array(); - public $response_completed = array(); - public $last_job = ""; - public $attributes; // object you can read: attributes after validateJob() - public $printer_attributes; // object you can read: printer's attributes after getPrinterAttributes() - public $job_attributes; // object you can read: last job attributes - public $jobs_attributes; // object you can read: jobs attributes after getJobs() - public $available_printers = array(); - public $printers_uri = array(); - public $debug = array(); - public $response; - - // protected variables; - protected $log_level = 2; // max 3: very verbose - protected $log_type = 3; // 3: file | 1: e-mail | 0: logger - protected $log_destination; // e-mail or file - protected $serveroutput; - protected $setup; - protected $stringjob; - protected $data; - protected $debug_count = 0; - protected $username; - protected $charset; - protected $password; - protected $requesring_user; - protected $client_hostname = "localhost"; - protected $stream; - protected $host = "localhost"; - protected $port = "631"; - protected $printer_uri; - protected $timeout = "20"; //20 secs - protected $errNo; - protected $errStr; - protected $datatype; - protected $datahead; - protected $datatail; - public $meta; - protected $operation_id; - protected $delay; - protected $error_generation; //devel feature - protected $debug_http = 0; - protected $no_disconnect; - protected $job_tags; - protected $operation_tags; - protected $index; - protected $collection; //RFC3382 - protected $collection_index; //RFC3382 - protected $collection_key = array(); //RFC3382 - protected $collection_depth = - 1; //RFC3382 - protected $end_collection = false; //RFC3382 - protected $collection_nbr = array(); //RFC3382 - protected $unix = false; // true -> use unix sockets instead of http - - // constructor - public function __construct() - { - $tz = getenv("date.timezone"); - if (!$tz) $tz = @date_default_timezone_get(); - date_default_timezone_set($tz); - $this->meta = new stdClass(); - $this->setup = new stdClass(); - $this->values = new stdClass(); - $this->serveroutput = new stdClass(); - $this->error_generation = new stdClass(); - $this->_parsing = new stdClass(); - self::_initTags(); - } - - /***************** - * - * PUBLIC FUNCTIONS - * - *******************/ - - // - // SETUP - // - - public function setPort($port = '631') - { - $this->port = $port; - self::_putDebug("Port is " . $this->port, 2); - } - - public function setUnix($socket = '/var/run/cups/cups.sock') - { - $this->host = $socket; - $this->unix = true; - self::_putDebug("Host is " . $this->host, 2); - } - - public function setHost($host = 'localhost') - { - $this->host = $host; - $this->unix = false; - self::_putDebug("Host is " . $this->host, 2); - } - - public function setTimeout($timeout) - { - $this->timeout = $timeout; - } - - public function setPrinterURI($uri) - { - $length = strlen($uri); - $length = chr($length); - while (strlen($length) < 2) $length = chr(0x00) . $length; - $this->meta->printer_uri = chr(0x45) // uri type | value-tag - . chr(0x00) . chr(0x0B) // name-length - . "printer-uri" // printer-uri | name - . $length . $uri; - $this->printer_uri = $uri; - self::_putDebug(sprintf(_("Printer URI: %s") , $uri) , 2); - $this->setup->uri = 1; - } - - public function setData($data) - { - $this->data = $data; - self::_putDebug("Data set", 2); - } - - public function setRawText() - { - $this->setup->datatype = 'TEXT'; - $this->meta->mime_media_type = ""; - $this->setup->mime_media_type = 1; - $this->datahead = chr(0x16); - if (is_readable($this->data)) - { - //It's a filename. Open and stream. - $data = fopen($this->data, "rb"); - while (!feof($data)) $output = fread($data, 8192); - } - else - { - $output = $this->data; - } - if (substr($output, -1, 1) != chr(0x0c)) if (!isset($this->setup->noFormFeed)) $this->datatail = chr(0x0c); - self::_putDebug(_("Forcing data to be interpreted as RAW TEXT") , 2); - } - - public function unsetRawText() - { - $this->setup->datatype = 'BINARY'; - $this->datahead = ''; - $this->datatail = ''; - self::_putDebug(_("Unset forcing data to be interpreted as RAW TEXT") , 2); - } - - public function setBinary() - { - self::unsetRawText(); - } - - public function setFormFeed() - { - $this->datatail = "\r\n" . chr(0x0c); - unset($this->setup->noFormFeed); - } - - public function unsetFormFeed() - { - $this->datatail = ''; - $this->setup->noFormFeed = 1; - } - - public function setCharset($charset = 'us-ascii') - { - $charset = strtolower($charset); - $this->charset = $charset; - $this->meta->charset = chr(0x47) // charset type | value-tag - . chr(0x00) . chr(0x12) // name-length - . "attributes-charset" // attributes-charset | name - . self::_giveMeStringLength($charset) // value-length - . $charset; // value - self::_putDebug(sprintf(_("Charset: %s") , $charset) , 2); - $this->setup->charset = 1; - } - - public function setLanguage($language = 'en_us') - { - $language = strtolower($language); - $this->meta->language = chr(0x48) // natural-language type | value-tag - . chr(0x00) . chr(0x1B) // name-length - . "attributes-natural-language" //attributes-natural-language - . self::_giveMeStringLength($language) // value-length - . $language; // value - self::_putDebug(sprintf(_("Language: %s") , $language) , 2); - $this->setup->language = 1; - } - - public function setDocumentFormat($mime_media_type = 'application/octet-stream') - { - self::setBinary(); - $length = chr(strlen($mime_media_type)); - while (strlen($length) < 2) $length = chr(0x00) . $length; - self::_putDebug(sprintf(_("mime type: %s") , $mime_media_type) , 2); - $this->meta->mime_media_type = chr(0x49) // document-format tag - . self::_giveMeStringLength('document-format') . 'document-format' // - . self::_giveMeStringLength($mime_media_type) . $mime_media_type; // value - $this->setup->mime_media_type = 1; - } - - // setDocumentFormat alias for backward compatibility - public function setMimeMediaType($mime_media_type = "application/octet-stream") - { - self::setDocumentFormat($mime_media_type); - } - - public function setCopies($nbrcopies = 1) - { - $this->meta->copies = ""; - if ($nbrcopies == 1 || !$nbrcopies) return true; - $copies = self::_integerBuild($nbrcopies); - $this->meta->copies = chr(0x21) // integer type | value-tag - . chr(0x00) . chr(0x06) // name-length - . "copies" // copies | name - . self::_giveMeStringLength($copies) // value-length - . $copies; - self::_putDebug(sprintf(_("Copies: %s") , $nbrcopies) , 2); - $this->setup->copies = 1; - } - - public function setDocumentName($document_name = "") - { - $this->meta->document_name = ""; - if (!$document_name) return true; - $document_name = substr($document_name, 0, 1023); - $length = strlen($document_name); - $length = chr($length); - while (strlen($length) < 2) $length = chr(0x00) . $length; - self::_putDebug(sprintf(_("document name: %s") , $document_name) , 2); - $this->meta->document_name = chr(0x41) // textWithoutLanguage tag - . chr(0x00) . chr(0x0d) // name-length - . "document-name" // mimeMediaType - . self::_giveMeStringLength($document_name) . $document_name; // value - - } - - public function setJobName($jobname = '', $absolute = false) - { - $this->meta->jobname = ''; - if ($jobname == '') - { - $this->meta->jobname = ''; - return true; - } - $postpend = date('-H:i:s-') . $this->_setJobId(); - if ($absolute) $postpend = ''; - if (isset($this->values->jobname) && $jobname == '(PHP)') - { - $jobname = $this->values->jobname; - } - $this->values->jobname = $jobname; - $jobname.= $postpend; - $this->meta->jobname = chr(0x42) // nameWithoutLanguage type || value-tag - . chr(0x00) . chr(0x08) // name-length - . "job-name" // job-name || name - . self::_giveMeStringLength($jobname) // value-length - . $jobname; // value - self::_putDebug(sprintf(_("Job name: %s") , $jobname) , 2); - $this->setup->jobname = 1; - } - - public function setUserName($username = 'PHP-SERVER') - { - $this->requesting_user = $username; - $this->meta->username = ''; - if (!$username) return true; - if ($username == 'PHP-SERVER' && isset($this->meta->username)) return TRUE; - /* - $value_length = 0x00; - for ($i = 0; $i < strlen($username); $i++) - { - $value_length+= 0x01; - } - $value_length = chr($value_length); - while (strlen($value_length) < 2) $value_length = chr(0x00) . $value_length; - */ - $this->meta->username = chr(0x42) // keyword type || value-tag - . chr(0x00) . chr(0x14) // name-length - . "requesting-user-name" - . self::_giveMeStringLength($username) // value-length - . $username; - self::_putDebug(sprintf(_("Username: %s") , $username) , 2); - $this->setup->username = 1; - } - - public function setAuthentification($username, $password) - { - self::setAuthentication($username, $password); - } - - public function setAuthentication($username, $password) - { - $this->password = $password; - $this->username = $username; - self::_putDebug(_("Setting password") , 2); - $this->setup->password = 1; - } - - public function setSides($sides = 2) - { - $this->meta->sides = ''; - if (!$sides) return true; - switch ($sides) - { - case 1: - $sides = "one-sided"; - break; - - case 2: - $sides = "two-sided-long-edge"; - break; - - case "2CE": - $sides = "two-sided-short-edge"; - break; - - default: - $sides = $sides; // yeah, what ? - break; - } - $this->meta->sides = chr(0x44) // keyword type | value-tag - . chr(0x00) . chr(0x05) // name-length - . "sides" // sides | name - . self::_giveMeStringLength($sides) // value-length - . $sides; // one-sided | value - self::_putDebug(sprintf(_("Sides value set to %s") , $sides) , 2); - } - - public function setFidelity() - { - // whether the server can't replace any attributes - // (eg, 2 sided print is not possible, - // so print one sided) and DO NOT THE JOB. - $this->meta->fidelity = chr(0x22) // boolean type | value-tag - . chr(0x00) . chr(0x16) // name-length - . "ipp-attribute-fidelity" // ipp-attribute-fidelity | name - . chr(0x00) . chr(0x01) // value-length - . chr(0x01); // true | value - self::_putDebug(_("Fidelity attribute is set (paranoid mode)") , 3); - } - - public function unsetFidelity() - { - // whether the server can replace any attributes - // (eg, 2 sided print is not possible, - // so print one sided) and DO THE JOB. - $this->meta->fidelity = chr(0x22) // boolean type | value-tag - . chr(0x00) . chr(0x16) // name-length - . "ipp-attribute-fidelity" // ipp-attribute-fidelity | name - . chr(0x00) . chr(0x01) // value-length - . chr(0x00); // false | value - self::_putDebug(_("Fidelity attribute is unset") , 2); - } - - public function setMessage($message = '') - { - $this->meta->message = ''; - if (!$message) return true; - $this->meta->message = - chr(0x41) // attribute type = textWithoutLanguage - . chr(0x00) - . chr(0x07) - . "message" - . self::_giveMeStringLength(substr($message, 0, 127)) - . substr($message, 0, 127); - self::_putDebug(sprintf(_('Setting message to "%s"') , $message) , 2); - } - - public function setPageRanges($page_ranges) - { - // $pages_ranges = string: "1:5 10:25 40:52 ..." - // to unset, specify an empty string. - $this->meta->page_range = ''; - if (!$page_ranges) return true; - $page_ranges = trim(str_replace("-", ":", $page_ranges)); - $first = true; - #$page_ranges = split(' ', $page_ranges); - $page_ranges = preg_split('# #', $page_ranges); - foreach($page_ranges as $page_range) - { - $value = self::_rangeOfIntegerBuild($page_range); - if ($first) - { - $this->meta->page_ranges .= - $this->tags_types['rangeOfInteger']['tag'] - . self::_giveMeStringLength('page-ranges') - . 'page-ranges' - . self::_giveMeStringLength($value) - . $value; - } - else - { - $this->meta->page_ranges .= - $this->tags_types['rangeOfInteger']['tag'] - . self::_giveMeStringLength('') - . self::_giveMeStringLength($value) - . $value; - $first = false; - } - } - } - - public function setAttribute($attribute, $values) - { - $operation_attributes_tags = array_keys($this->operation_tags); - $job_attributes_tags = array_keys($this->job_tags); - $printer_attributes_tags = array_keys($this->printer_tags); - self::unsetAttribute($attribute); - if (in_array($attribute, $operation_attributes_tags)) - { - if (!is_array($values)) - { - self::_setOperationAttribute($attribute, $values); - } - else - { - foreach($values as $value) - { - self::_setOperationAttribute($attribute, $value); - } - } - } - elseif (in_array($attribute, $job_attributes_tags)) - { - if (!is_array($values)) - { - self::_setJobAttribute($attribute, $values); - } - else - { - foreach($values as $value) - { - self::_setJobAttribute($attribute, $value); - } - } - } - elseif (in_array($attribute, $printer_attributes_tags)) - { - if (!is_array($values)) - { - self::_setPrinterAttribute($attribute, $values); - } - else - { - foreach($values as $value) - { - self::_setPrinterAttribute($attribute, $value); - } - } - } - else - { - trigger_error( - sprintf(_('SetAttribute: Tag "%s" is not a printer or a job attribute'), - $attribute) , E_USER_NOTICE); - self::_putDebug( - sprintf(_('SetAttribute: Tag "%s" is not a printer or a job attribute'), - $attribute) , 3); - self::_errorLog( - sprintf(_('SetAttribute: Tag "%s" is not a printer or a job attribute'), - $attribute) , 2); - return FALSE; - } - } - - public function unsetAttribute($attribute) - { - $operation_attributes_tags = array_keys($this->operation_tags); - $job_attributes_tags = array_keys($this->job_tags); - $printer_attributes_tags = array_keys($this->printer_tags); - if (in_array($attribute, $operation_attributes_tags)) - { - unset( - $this->operation_tags[$attribute]['value'], - $this->operation_tags[$attribute]['systag'] - ); - } - elseif (in_array($attribute, $job_attributes_tags)) - { - unset( - $this->job_tags[$attribute]['value'], - $this->job_tags[$attribute]['systag'] - ); - } - elseif (in_array($attribute, $printer_attributes_tags)) - { - unset( - $this->printer_tags[$attribute]['value'], - $this->printer_tags[$attribute]['systag'] - ); - } - else - { - trigger_error( - sprintf(_('unsetAttribute: Tag "%s" is not a printer or a job attribute'), - $attribute) , E_USER_NOTICE); - self::_putDebug( - sprintf(_('unsetAttribute: Tag "%s" is not a printer or a job attribute'), - $attribute) , 3); - self::_errorLog( - sprintf(_('unsetAttribute: Tag "%s" is not a printer or a job attribute'), - $attribute) , 2); - return FALSE; - } - return true; - } - - // - // LOGGING / DEBUGGING - // - - public function setLog($log_destination, $destination_type = 'file', $level = 2) - { - - if (is_string($log_destination) && !empty($log_destination)) - { - $this->log_destination = $log_destination; - } - - switch ($destination_type) - { - case 'file': - case 3: - $this->log_destination = $log_destination; - $this->log_type = 3; - break; - - case 'logger': - case 0: - $this->log_destination = ''; - $this->log_type = 0; - break; - - case 'e-mail': - case 1: - $this->log_destination = $log_destination; - $this->log_type = 1; - break; - } - $this->log_level = $level; - } - - public function printDebug() - { - for ($i = 0; $i < $this->debug_count; $i++) - { - echo $this->debug[$i], "\n"; - } - $this->debug = array(); - $this->debug_count = 0; - } - - public function getDebug() - { - $debug = ''; - for ($i = 0; $i < $this->debug_count; $i++) - { - $debug.= $this->debug[$i]; - } - $this->debug = array(); - $this->debug_count = 0; - return $debug; - } - - // - // OPERATIONS - // - - public function printJob() - { - // this BASIC version of printJob do not parse server - // output for job's attributes - self::_putDebug( - sprintf( - "************** Date: %s ***********", - date('Y-m-d H:i:s') - ) - ); - if (!$this->_stringJob()) return FALSE; - if (is_readable($this->data)) - { - self::_putDebug(_("Printing a FILE")); - $this->output = $this->stringjob; - if ($this->setup->datatype == "TEXT") - { - $this->output.= chr(0x16); - } - $post_values = array( - "Content-Type" => "application/ipp", - "Data" => $this->output, - "File" => $this->data - ); - if ($this->setup->datatype == "TEXT" && !isset($this->setup->noFormFeed)) - { - $post_values = array_merge( - $post_values, - array( - "Filetype" => "TEXT" - ) - ); - } - } - else - { - self::_putDebug(_("Printing DATA")); - $this->output = - $this->stringjob - . $this->datahead - . $this->data - . $this->datatail; - $post_values = array( - "Content-Type" => "application/ipp", - "Data" => $this->output - ); - } - if (self::_sendHttp($post_values, $this->paths["printers"])) - { - self::_parseServerOutput(); - } - if (isset($this->serveroutput) && isset($this->serveroutput->status)) - { - $this->status = array_merge($this->status, array( - $this->serveroutput->status - )); - if ($this->serveroutput->status == "successfull-ok") - { - self::_errorLog( - sprintf("printing job %s: ", $this->last_job) - . $this->serveroutput->status, - 3); - } - else - { - self::_errorLog( - sprintf("printing job: ", $this->last_job) - . $this->serveroutput->status, - 1); - } - return $this->serveroutput->status; - } - - $this->status = - array_merge($this->status, array("OPERATION FAILED")); - $this->jobs = - array_merge($this->jobs, array("")); - $this->jobs_uri = - array_merge($this->jobs_uri, array("")); - - self::_errorLog("printing job : OPERATION FAILED", 1); - return false; - } - - - /****************** - * - * PROTECTED FUNCTIONS - * - *******************/ - - // - // HTTP OUTPUT - // - - protected function _sendHttp($post_values, $uri) - { - /* - This function Copyright (C) 2005-2006 Thomas Harding, Manuel Lemos - */ - $this->response_completed[] = "no"; - unset($this->serverouptut); - self::_putDebug(_("Processing HTTP request") , 2); - $this->serveroutput->headers = array(); - $this->serveroutput->body = ""; - $http = new http_class; - if (!$this->unix) $http->host = $this->host; - else $http->host = "localhost"; - $http->with_exceptions = $this->with_exceptions; - if ($this->debug_http) - { - $http->debug = 1; - $http->html_debug = 0; - } - else - { - $http->debug = 0; - $http->html_debug = 0; - } - $url = "http://" . $this->host; - if ($this->ssl) $url = "https://" . $this->host; - if ($this->unix) $url = "unix://" . $this->host; - $http->port = $this->port; - $http->timeout = $this->http_timeout; - $http->data_timeout = $this->http_data_timeout; - $http->force_multipart_form_post = false; - $http->user = $this->username; - $http->password = $this->password; - $error = $http->GetRequestArguments($url, $arguments); - $arguments["RequestMethod"] = "POST"; - $arguments["Headers"] = array( - "Content-Type" => "application/ipp" + public $paths = array( + "root" => "/", + "admin" => "/admin/", + "printers" => "/printers/", + "jobs" => "/jobs/" ); - $arguments["BodyStream"] = array( - array( - "Data" => $post_values["Data"] - ) - ); - if (isset($post_values["File"])) $arguments["BodyStream"][] = array( - "File" => $post_values["File"] - ); - if (isset($post_values["FileType"]) - && !strcmp($post_values["FileType"], "TEXT")) - { - $arguments["BodyStream"][] = array("Data" => Chr(12)); - } - $arguments["RequestURI"] = $uri; - if ($this->with_exceptions && $this->handle_http_exceptions) - { - try - { - $success = $http->Open($arguments); - } - catch(httpException $e) - { - throw new ippException( - sprintf("http error: %s", $e->getMessage()), - $e->getErrno()); - } - } - else - { - $success = $http->Open($arguments); - } - if ($success[0] == true) - { - $success = $http->SendRequest($arguments); - if ($success[0] == true) - { - self::_putDebug("H T T P R E Q U E S T :"); - self::_putDebug("Request headers:"); - for (Reset($http->request_headers) , $header = 0; $header < count($http->request_headers); Next($http->request_headers) , $header++) + public $http_timeout = 30; // timeout at http connection (seconds) 0 => default => 30. + public $http_data_timeout = 30; // data reading timeout (milliseconds) 0 => default => 30. + public $ssl = false; + public $debug_level = 3; // max 3: almost silent + public $alert_on_end_tag; // debugging purpose: echo "END tag OK" if (1 and reads while end tag) + public $with_exceptions = 0; // compatibility mode for old scripts + public $handle_http_exceptions = 1; + + // readables variables + public $jobs = array(); + public $jobs_uri = array(); + public $status = array(); + public $response_completed = array(); + public $last_job = ""; + public $attributes; // object you can read: attributes after validateJob() + public $printer_attributes; // object you can read: printer's attributes after getPrinterAttributes() + public $job_attributes; // object you can read: last job attributes + public $jobs_attributes; // object you can read: jobs attributes after getJobs() + public $available_printers = array(); + public $printer_map = array(); + public $printers_uri = array(); + public $debug = array(); + public $response; + public $meta; + + // protected variables; + protected $log_level = 2; // max 3: very verbose + protected $log_type = 3; // 3: file | 1: e-mail | 0: logger + protected $log_destination; // e-mail or file + protected $serveroutput; + protected $setup; + protected $stringjob; + protected $data; + protected $debug_count = 0; + protected $username; + protected $charset; + protected $password; + protected $requesring_user; + protected $client_hostname = "localhost"; + protected $stream; + protected $host = "localhost"; + protected $port = "631"; + protected $requesting_user = ''; + protected $printer_uri; + protected $timeout = "20"; //20 secs + protected $errNo; + protected $errStr; + protected $datatype; + protected $datahead; + protected $datatail; + protected $operation_id; + protected $delay; + protected $error_generation; //devel feature + protected $debug_http = 0; + protected $no_disconnect; + protected $job_tags; + protected $operation_tags; + protected $index; + protected $collection; //RFC3382 + protected $collection_index; //RFC3382 + protected $collection_key = array(); //RFC3382 + protected $collection_depth = - 1; //RFC3382 + protected $end_collection = false; //RFC3382 + protected $collection_nbr = array(); //RFC3382 + protected $unix = false; // true -> use unix sockets instead of http + protected $output; + + public function __construct() { - $header_name = Key($http->request_headers); - if (GetType($http->request_headers[$header_name]) == "array") - { - for ($header_value = 0; $header_value < count($http->request_headers[$header_name]); $header_value++) - { - self::_putDebug($header_name . ": " . $http->request_headers[$header_name][$header_value]); - } - } - else - { - self::_putDebug($header_name . ": " . $http->request_headers[$header_name]); - } + $tz = getenv("date.timezone"); + if (!$tz) + { + $tz = @date_default_timezone_get(); + } + + date_default_timezone_set($tz); + $this->meta = new \stdClass(); + $this->setup = new \stdClass(); + $this->values = new \stdClass(); + $this->serveroutput = new \stdClass(); + $this->error_generation = new \stdClass(); + $this->_parsing = new \stdClass(); + self::_initTags(); } - self::_putDebug("Request body:"); - self::_putDebug( - htmlspecialchars($http->request_body) - . "*********** END REQUEST BODY *********" + + public function setPort($port = '631') + { + $this->port = $port; + self::_putDebug("Port is " . $this->port, 2); + } + + public function setUnix($socket = '/var/run/cups/cups.sock') + { + $this->host = $socket; + $this->unix = true; + self::_putDebug("Host is " . $this->host, 2); + } + + public function setHost($host = 'localhost') + { + $this->host = $host; + $this->unix = false; + self::_putDebug("Host is " . $this->host, 2); + } + + public function setTimeout($timeout) + { + $this->timeout = $timeout; + } + + public function setPrinterURI($uri) + { + $length = strlen($uri); + $length = chr($length); + while (strlen($length) < 2) $length = chr(0x00) . $length; + $this->meta->printer_uri = chr(0x45) // uri type | value-tag + . chr(0x00) . chr(0x0B) // name-length + . "printer-uri" // printer-uri | name + . $length . $uri; + $this->printer_uri = $uri; + self::_putDebug(sprintf(_("Printer URI: %s") , $uri) , 2); + $this->setup->uri = 1; + } + + public function setData($data) + { + $this->data = $data; + self::_putDebug("Data set", 2); + } + + public function setRawText() + { + $this->setup->datatype = 'TEXT'; + $this->meta->mime_media_type = ""; + $this->setup->mime_media_type = 1; + $this->datahead = chr(0x16); + if (is_readable($this->data)) + { + //It's a filename. Open and stream. + $data = fopen($this->data, "rb"); + while (!feof($data)) $output = fread($data, 8192); + } + else + { + $output = $this->data; + } + if (substr($output, -1, 1) != chr(0x0c)) { + if (!isset($this->setup->noFormFeed)) + { + $this->datatail = chr(0x0c); + } + } + self::_putDebug(_("Forcing data to be interpreted as RAW TEXT") , 2); + } + + public function unsetRawText() + { + $this->setup->datatype = 'BINARY'; + $this->datahead = ''; + $this->datatail = ''; + self::_putDebug(_("Unset forcing data to be interpreted as RAW TEXT") , 2); + } + + public function setBinary() + { + self::unsetRawText(); + } + + public function setFormFeed() + { + $this->datatail = "\r\n" . chr(0x0c); + unset($this->setup->noFormFeed); + } + + public function unsetFormFeed() + { + $this->datatail = ''; + $this->setup->noFormFeed = 1; + } + + public function setCharset($charset = 'utf-8') + { + $charset = strtolower($charset); + $this->charset = $charset; + $this->meta->charset = chr(0x47) // charset type | value-tag + . chr(0x00) . chr(0x12) // name-length + . "attributes-charset" // attributes-charset | name + . self::_giveMeStringLength($charset) // value-length + . $charset; // value + self::_putDebug(sprintf(_("Charset: %s") , $charset) , 2); + $this->setup->charset = 1; + } + + public function setLanguage($language = 'en_us') + { + $language = strtolower($language); + $this->meta->language = chr(0x48) // natural-language type | value-tag + . chr(0x00) . chr(0x1B) // name-length + . "attributes-natural-language" //attributes-natural-language + . self::_giveMeStringLength($language) // value-length + . $language; // value + self::_putDebug(sprintf(_("Language: %s") , $language) , 2); + $this->setup->language = 1; + } + + public function setDocumentFormat($mime_media_type = 'application/octet-stream') + { + self::setBinary(); + $length = chr(strlen($mime_media_type)); + while (strlen($length) < 2) $length = chr(0x00) . $length; + self::_putDebug(sprintf(_("mime type: %s") , $mime_media_type) , 2); + $this->meta->mime_media_type = chr(0x49) // document-format tag + . self::_giveMeStringLength('document-format') . 'document-format' // + . self::_giveMeStringLength($mime_media_type) . $mime_media_type; // value + $this->setup->mime_media_type = 1; + } + + // setDocumentFormat alias for backward compatibility + public function setMimeMediaType($mime_media_type = "application/octet-stream") + { + self::setDocumentFormat($mime_media_type); + } + + public function setCopies($nbrcopies = 1) + { + $this->meta->copies = ""; + + if ($nbrcopies == 1 || !$nbrcopies) + { + return true; + } + + $copies = self::_integerBuild($nbrcopies); + $this->meta->copies = chr(0x21) // integer type | value-tag + . chr(0x00) . chr(0x06) // name-length + . "copies" // copies | name + . self::_giveMeStringLength($copies) // value-length + . $copies; + self::_putDebug(sprintf(_("Copies: %s") , $nbrcopies) , 2); + $this->setup->copies = 1; + } + + public function setDocumentName($document_name = "") + { + $this->meta->document_name = ""; + if (!$document_name) { + return true; + } + $document_name = substr($document_name, 0, 1023); + $length = strlen($document_name); + $length = chr($length); + while (strlen($length) < 2) $length = chr(0x00) . $length; + self::_putDebug(sprintf(_("document name: %s") , $document_name) , 2); + $this->meta->document_name = chr(0x41) // textWithoutLanguage tag + . chr(0x00) . chr(0x0d) // name-length + . "document-name" // mimeMediaType + . self::_giveMeStringLength($document_name) . $document_name; // value + + } + + public function setJobName($jobname = '', $absolute = false) + { + $this->meta->jobname = ''; + if ($jobname == '') + { + $this->meta->jobname = ''; + return true; + } + $postpend = date('-H:i:s-') . $this->_setJobId(); + if ($absolute) { + $postpend = ''; + } + if (isset($this->values->jobname) && $jobname == '(PHP)') + { + $jobname = $this->values->jobname; + } + $this->values->jobname = $jobname; + $jobname.= $postpend; + $this->meta->jobname = chr(0x42) // nameWithoutLanguage type || value-tag + . chr(0x00) . chr(0x08) // name-length + . "job-name" // job-name || name + . self::_giveMeStringLength($jobname) // value-length + . $jobname; // value + self::_putDebug(sprintf(_("Job name: %s") , $jobname) , 2); + $this->setup->jobname = 1; + } + + public function setUserName($username = 'PHP-SERVER') + { + $this->requesting_user = $username; + $this->meta->username = ''; + if (!$username) { + return true; + } + if ($username == 'PHP-SERVER' && isset($this->meta->username)) { + return TRUE; + } + /* + $value_length = 0x00; + for ($i = 0; $i < strlen($username); $i++) + { + $value_length+= 0x01; + } + $value_length = chr($value_length); + while (strlen($value_length) < 2) $value_length = chr(0x00) . $value_length; + */ + $this->meta->username = chr(0x42) // keyword type || value-tag + . chr(0x00) . chr(0x14) // name-length + . "requesting-user-name" + . self::_giveMeStringLength($username) // value-length + . $username; + self::_putDebug(sprintf(_("Username: %s") , $username) , 2); + $this->setup->username = 1; + } + + public function setAuthentification($username, $password) + { + self::setAuthentication($username, $password); + } + + public function setAuthentication($username, $password) + { + $this->password = $password; + $this->username = $username; + self::_putDebug(_("Setting password") , 2); + $this->setup->password = 1; + } + + public function setSides($sides = 2) + { + $this->meta->sides = ''; + if (!$sides) + { + return true; + } + + switch ($sides) + { + case 1: + $sides = "one-sided"; + break; + + case 2: + $sides = "two-sided-long-edge"; + break; + + case "2CE": + $sides = "two-sided-short-edge"; + break; + } + + $this->meta->sides = chr(0x44) // keyword type | value-tag + . chr(0x00) . chr(0x05) // name-length + . "sides" // sides | name + . self::_giveMeStringLength($sides) // value-length + . $sides; // one-sided | value + self::_putDebug(sprintf(_("Sides value set to %s") , $sides) , 2); + } + + public function setFidelity() + { + // whether the server can't replace any attributes + // (eg, 2 sided print is not possible, + // so print one sided) and DO NOT THE JOB. + $this->meta->fidelity = chr(0x22) // boolean type | value-tag + . chr(0x00) . chr(0x16) // name-length + . "ipp-attribute-fidelity" // ipp-attribute-fidelity | name + . chr(0x00) . chr(0x01) // value-length + . chr(0x01); // true | value + self::_putDebug(_("Fidelity attribute is set (paranoid mode)") , 3); + } + + public function unsetFidelity() + { + // whether the server can replace any attributes + // (eg, 2 sided print is not possible, + // so print one sided) and DO THE JOB. + $this->meta->fidelity = chr(0x22) // boolean type | value-tag + . chr(0x00) . chr(0x16) // name-length + . "ipp-attribute-fidelity" // ipp-attribute-fidelity | name + . chr(0x00) . chr(0x01) // value-length + . chr(0x00); // false | value + self::_putDebug(_("Fidelity attribute is unset") , 2); + } + + public function setMessage($message = '') + { + $this->meta->message = ''; + if (!$message) { + return true; + } + $this->meta->message = + chr(0x41) // attribute type = textWithoutLanguage + . chr(0x00) + . chr(0x07) + . "message" + . self::_giveMeStringLength(substr($message, 0, 127)) + . substr($message, 0, 127); + self::_putDebug(sprintf(_('Setting message to "%s"') , $message) , 2); + } + + public function setPageRanges($page_ranges) + { + // $pages_ranges = string: "1:5 10:25 40:52 ..." + // to unset, specify an empty string. + $this->meta->page_range = ''; + if (!$page_ranges) { + return true; + } + $page_ranges = trim(str_replace("-", ":", $page_ranges)); + $first = true; + #$page_ranges = split(' ', $page_ranges); + $page_ranges = preg_split('# #', $page_ranges); + foreach($page_ranges as $page_range) + { + $value = self::_rangeOfIntegerBuild($page_range); + if ($first) + { + $this->meta->page_ranges .= + $this->tags_types['rangeOfInteger']['tag'] + . self::_giveMeStringLength('page-ranges') + . 'page-ranges' + . self::_giveMeStringLength($value) + . $value; + } + else + { + $this->meta->page_ranges .= + $this->tags_types['rangeOfInteger']['tag'] + . self::_giveMeStringLength('') + . self::_giveMeStringLength($value) + . $value; + $first = false; + } + } + } + + public function setAttribute($attribute, $values) + { + $operation_attributes_tags = array_keys($this->operation_tags); + $job_attributes_tags = array_keys($this->job_tags); + $printer_attributes_tags = array_keys($this->printer_tags); + self::unsetAttribute($attribute); + if (in_array($attribute, $operation_attributes_tags)) + { + if (!is_array($values)) + { + self::_setOperationAttribute($attribute, $values); + } + else + { + foreach($values as $value) + { + self::_setOperationAttribute($attribute, $value); + } + } + } + elseif (in_array($attribute, $job_attributes_tags)) + { + if (!is_array($values)) + { + self::_setJobAttribute($attribute, $values); + } + else + { + foreach($values as $value) + { + self::_setJobAttribute($attribute, $value); + } + } + } + elseif (in_array($attribute, $printer_attributes_tags)) + { + if (!is_array($values)) + { + self::_setPrinterAttribute($attribute, $values); + } + else + { + foreach($values as $value) + { + self::_setPrinterAttribute($attribute, $value); + } + } + } + else + { + trigger_error( + sprintf(_('SetAttribute: Tag "%s" is not a printer or a job attribute'), + $attribute) , E_USER_NOTICE); + self::_putDebug( + sprintf(_('SetAttribute: Tag "%s" is not a printer or a job attribute'), + $attribute) , 3); + self::_errorLog( + sprintf(_('SetAttribute: Tag "%s" is not a printer or a job attribute'), + $attribute) , 2); + return FALSE; + } + } + + public function unsetAttribute($attribute) + { + $operation_attributes_tags = array_keys($this->operation_tags); + $job_attributes_tags = array_keys($this->job_tags); + $printer_attributes_tags = array_keys($this->printer_tags); + if (in_array($attribute, $operation_attributes_tags)) + { + unset( + $this->operation_tags[$attribute]['value'], + $this->operation_tags[$attribute]['systag'] ); - $i = 0; - $headers = array(); - unset($this->serveroutput->headers); - $http->ReadReplyHeaders($headers); - self::_putDebug("H T T P R E S P O N S E :"); - self::_putDebug("Response headers:"); - for (Reset($headers) , $header = 0; $header < count($headers); Next($headers) , $header++) - { - $header_name = Key($headers); - if (GetType($headers[$header_name]) == "array") - { - for ($header_value = 0; $header_value < count($headers[$header_name]); $header_value++) - { - self::_putDebug($header_name . ": " . $headers[$header_name][$header_value]); - $this->serveroutput->headers[$i] = - $header_name . ": " - . $headers[$header_name][$header_value]; - $i++; - } - } - else - { - self::_putDebug($header_name . ": " . $headers[$header_name]); - $this->serveroutput->headers[$i] = - $header_name - . ": " - . $headers[$header_name]; - $i++; - } + } + elseif (in_array($attribute, $job_attributes_tags)) + { + unset( + $this->job_tags[$attribute]['value'], + $this->job_tags[$attribute]['systag'] + ); + } + elseif (in_array($attribute, $printer_attributes_tags)) + { + unset( + $this->printer_tags[$attribute]['value'], + $this->printer_tags[$attribute]['systag'] + ); + } + else + { + trigger_error( + sprintf(_('unsetAttribute: Tag "%s" is not a printer or a job attribute'), + $attribute) , E_USER_NOTICE); + self::_putDebug( + sprintf(_('unsetAttribute: Tag "%s" is not a printer or a job attribute'), + $attribute) , 3); + self::_errorLog( + sprintf(_('unsetAttribute: Tag "%s" is not a printer or a job attribute'), + $attribute) , 2); + return FALSE; + } + return true; } - self::_putDebug("\n\nResponse body:\n"); - $this->serveroutput->body = ""; - for (;;) - { - $http->ReadReplyBody($body, 1024); - if (strlen($body) == 0) break; - self::_putDebug(htmlentities($body)); - $this->serveroutput->body.= $body; - } - self::_putDebug("********* END RESPONSE BODY ********"); - } - } - $http->Close(); - return true; - } - - // - // INIT - // - - protected function _initTags() - { - $this->tags_types = array( - "unsupported" => array( - "tag" => chr(0x10) , - "build" => "" - ) , - "reserved" => array( - "tag" => chr(0x11) , - "build" => "" - ) , - "unknown" => array( - "tag" => chr(0x12) , - "build" => "" - ) , - "no-value" => array( - "tag" => chr(0x13) , - "build" => "no_value" - ) , - "integer" => array( - "tag" => chr(0x21) , - "build" => "integer" - ) , - "boolean" => array( - "tag" => chr(0x22) , - "build" => "boolean" - ) , - "enum" => array( - "tag" => chr(0x23) , - "build" => "enum" - ) , - "octetString" => array( - "tag" => chr(0x30) , - "build" => "octet_string" - ) , - "datetime" => array( - "tag" => chr(0x31) , - "build" => "datetime" - ) , - "resolution" => array( - "tag" => chr(0x32) , - "build" => "resolution" - ) , - "rangeOfInteger" => array( - "tag" => chr(0x33) , - "build" => "range_of_integers" - ) , - "textWithLanguage" => array( - "tag" => chr(0x35) , - "build" => "string" - ) , - "nameWithLanguage" => array( - "tag" => chr(0x36) , - "build" => "string" - ) , - /* - "text" => array ("tag" => chr(0x40), - "build" => "string"), - "text string" => array ("tag" => chr(0x40), - "build" => "string"), + // + // LOGGING / DEBUGGING + // + /** + * Sets log file destination. Creates the file if has permission. + * + * @param string $log_destination + * @param string $destination_type + * @param int $level + * + * @throws ippException */ - "textWithoutLanguage" => array( - "tag" => chr(0x41) , - "build" => "string" - ) , - "nameWithoutLanguage" => array( - "tag" => chr(0x42) , - "buid" => "string" - ) , - "keyword" => array( - "tag" => chr(0x44) , - "build" => "string" - ) , - "uri" => array( - "tag" => chr(0x45) , - "build" => "string" - ) , - "uriScheme" => array( - "tag" => chr(0x46) , - "build" => "string" - ) , - "charset" => array( - "tag" => chr(0x47) , - "build" => "string" - ) , - "naturalLanguage" => array( - "tag" => chr(0x48) , - "build" => "string" - ) , - "mimeMediaType" => array( - "tag" => chr(0x49) , - "build" => "string" - ) , - "extendedAttributes" => array( - "tag" => chr(0x7F) , - "build" => "extended" - ) , - ); - $this->operation_tags = array( - "compression" => array( - "tag" => "keyword" - ) , - "document-natural-language" => array( - "tag" => "naturalLanguage" - ) , - "job-k-octets" => array( - "tag" => "integer" - ) , - "job-impressions" => array( - "tag" => "integer" - ) , - "job-media-sheets" => array( - "tag" => "integer" - ) , - ); - $this->job_tags = array( - "job-priority" => array( - "tag" => "integer" - ) , - "job-hold-until" => array( - "tag" => "keyword" - ) , - "job-sheets" => array( - "tag" => "keyword" - ) , //banner page - "multiple-document-handling" => array( - "tag" => "keyword" - ) , - //"copies" => array("tag" => "integer"), - "finishings" => array( - "tag" => "enum" - ) , - //"page-ranges" => array("tag" => "rangeOfInteger"), // has its own function - //"sides" => array("tag" => "keyword"), // has its own function - "number-up" => array( - "tag" => "integer" - ) , - "orientation-requested" => array( - "tag" => "enum" - ) , - "media" => array( - "tag" => "keyword" - ) , - "printer-resolution" => array( - "tag" => "resolution" - ) , - "print-quality" => array( - "tag" => "enum" - ) , - "job-message-from-operator" => array( - "tag" => "textWithoutLanguage" - ) , - ); - $this->printer_tags = array( - "requested-attributes" => array( - "tag" => "keyword" - ) - ); - } - - // - // SETUP - // - - protected function _setOperationId() - { - $prepend = ''; - $this->operation_id+= 1; - $this->meta->operation_id = self::_integerBuild($this->operation_id); - self::_putDebug("operation id is: " . $this->operation_id, 2); - } - - protected function _setJobId() - { - $this->meta->jobid+= 1; - $prepend = ''; - $prepend_length = 4 - strlen($this->meta->jobid); - for ($i = 0; $i < $prepend_length; $i++) $prepend.= '0'; - return $prepend . $this->meta->jobid; - } - - protected function _setJobUri($job_uri) - { - $this->meta->job_uri = chr(0x45) // type uri - . chr(0x00) . chr(0x07) // name-length - . "job-uri" - //. chr(0x00).chr(strlen($job_uri)) - . self::_giveMeStringLength($job_uri) . $job_uri; - self::_putDebug("job-uri is: " . $job_uri, 2); - } - - // - // RESPONSE PARSING - // - - protected function _parseServerOutput() - { - $this->serveroutput->response = array(); - if (!self::_parseHttpHeaders()) return FALSE; - $this->_parsing->offset = 0; - self::_parseIppVersion(); - self::_parseStatusCode(); - self::_parseRequestID(); - $this->_parseResponse(); - //devel - self::_putDebug( - sprintf("***** IPP STATUS: %s ******", $this->serveroutput->status), - 4); - self::_putDebug("****** END OF OPERATION ****"); - return true; - } - - protected function _parseHttpHeaders() - { - $response = ""; - switch ($this->serveroutput->headers[0]) - { - case "http/1.1 200 ok: ": - $this->serveroutput->httpstatus = "HTTP/1.1 200 OK"; - $response = "OK"; - break; - - // primitive http/1.0 for Lexmark printers (from Rick Baril) - case "http/1.0 200 ok: ": - $this->serveroutput->httpstatus = "HTTP/1.0 200 OK"; - $response = "OK"; - break; - - case "http/1.1 100 continue: ": - $this->serveroutput->httpstatus = "HTTP/1.1 100 CONTINUE"; - $response = "OK"; - break; - - case "": - $this->serveroutput->httpstatus = "HTTP/1.1 000 No Response From Server"; - $this->serveroutput->status = "HTTP-ERROR-000_NO_RESPONSE_FROM_SERVER"; - trigger_error("No Response From Server", E_USER_WARNING); - self::_errorLog("No Response From Server", 1); - $this->disconnected = 1; - return FALSE; - break; - - default: - $server_response = preg_replace("/: $/", '', $this->serveroutput->headers[0]); - #$strings = split(' ', $server_response, 3); - $strings = preg_split('# #', $server_response, 3); - $errno = $strings[1]; - $string = strtoupper(str_replace(' ', '_', $strings[2])); - trigger_error( - sprintf(_("server responds %s") , $server_response), - E_USER_WARNING); - self::_errorLog("server responds " . $server_response, 1); - $this->serveroutput->httpstatus = - strtoupper($strings[0]) - . " " - . $errno - . " " - . ucfirst($strings[2]); - - $this->serveroutput->status = - "HTTP-ERROR-" - . $errno - . "-" - . $string; - $this->disconnected = 1; - return FALSE; - break; - } - unset($this->serveroutput->headers); - return TRUE; - } - - protected function _parseIppVersion() - { - $ippversion = - (ord($this->serveroutput->body[$this->_parsing->offset]) * 256) - + ord($this->serveroutput->body[$this->_parsing->offset + 1]); - switch ($ippversion) - { - case 0x0101: - $this->serveroutput->ipp_version = "1.1"; - break; - - default: - $this->serveroutput->ipp_version = - sprintf("%u.%u (Unknown)", - ord($this->serveroutput->body[$this->_parsing->offset]) * 256, - ord($this->serveroutput->body[$this->_parsing->offset + 1])); - break; - } - self::_putDebug("I P P R E S P O N S E :\n\n"); - self::_putDebug( - sprintf("IPP version %s%s: %s", - ord($this->serveroutput->body[$this->_parsing->offset]), - ord($this->serveroutput->body[$this->_parsing->offset + 1]), - $this->serveroutput->ipp_version)); - $this->_parsing->offset+= 2; - return; - } - - protected function _parseStatusCode() - { - $status_code = - (ord($this->serveroutput->body[$this->_parsing->offset]) * 256) - + ord($this->serveroutput->body[$this->_parsing->offset + 1]); - $this->serveroutput->status = "NOT PARSED"; - $this->_parsing->offset+= 2; - if (strlen($this->serveroutput->body) < $this->_parsing->offset) - { - return false; - } - if ($status_code < 0x00FF) - { - $this->serveroutput->status = "successfull"; - } - elseif ($status_code < 0x01FF) - { - $this->serveroutput->status = "informational"; - } - elseif ($status_code < 0x02FF) - { - $this->serveroutput->status = "redirection"; - } - elseif ($status_code < 0x04FF) - { - $this->serveroutput->status = "client-error"; - } - elseif ($status_code < 0x05FF) - { - $this->serveroutput->status = "server-error"; - } - switch ($status_code) - { - case 0x0000: - $this->serveroutput->status = "successfull-ok"; - break; - - case 0x0001: - $this->serveroutput->status = "successful-ok-ignored-or-substituted-attributes"; - break; - - case 0x002: - $this->serveroutput->status = "successful-ok-conflicting-attributes"; - break; - - case 0x0400: - $this->serveroutput->status = "client-error-bad-request"; - break; - - case 0x0401: - $this->serveroutput->status = "client-error-forbidden"; - break; - - case 0x0402: - $this->serveroutput->status = "client-error-not-authenticated"; - break; - - case 0x0403: - $this->serveroutput->status = "client-error-not-authorized"; - break; - - case 0x0404: - $this->serveroutput->status = "client-error-not-possible"; - break; - - case 0x0405: - $this->serveroutput->status = "client-error-timeout"; - break; - - case 0x0406: - $this->serveroutput->status = "client-error-not-found"; - break; - - case 0x0407: - $this->serveroutput->status = "client-error-gone"; - break; - - case 0x0408: - $this->serveroutput->status = "client-error-request-entity-too-large"; - break; - - case 0x0409: - $this->serveroutput->status = "client-error-request-value-too-long"; - break; - - case 0x040A: - $this->serveroutput->status = "client-error-document-format-not-supported"; - break; - - case 0x040B: - $this->serveroutput->status = "client-error-attributes-or-values-not-supported"; - break; - - case 0x040C: - $this->serveroutput->status = "client-error-uri-scheme-not-supported"; - break; - - case 0x040D: - $this->serveroutput->status = "client-error-charset-not-supported"; - break; - - case 0x040E: - $this->serveroutput->status = "client-error-conflicting-attributes"; - break; - - case 0x040F: - $this->serveroutput->status = "client-error-compression-not-supported"; - break; - - case 0x0410: - $this->serveroutput->status = "client-error-compression-error"; - break; - - case 0x0411: - $this->serveroutput->status = "client-error-document-format-error"; - break; - - case 0x0412: - $this->serveroutput->status = "client-error-document-access-error"; - break; - - case 0x0413: // RFC3380 - $this->serveroutput->status = "client-error-attributes-not-settable"; - break; - - case 0x0500: - $this->serveroutput->status = "server-error-internal-error"; - break; - - case 0x0501: - $this->serveroutput->status = "server-error-operation-not-supported"; - break; - - case 0x0502: - $this->serveroutput->status = "server-error-service-unavailable"; - break; - - case 0x0503: - $this->serveroutput->status = "server-error-version-not-supported"; - break; - - case 0x0504: - $this->serveroutput->status = "server-error-device-error"; - break; - - case 0x0505: - $this->serveroutput->status = "server-error-temporary-error"; - break; - - case 0x0506: - $this->serveroutput->status = "server-error-not-accepting-jobs"; - break; - - case 0x0507: - $this->serveroutput->status = "server-error-busy"; - break; - - case 0x0508: - $this->serveroutput->status = "server-error-job-canceled"; - break; - - case 0x0509: - $this->serveroutput->status = "server-error-multiple-document-jobs-not-supported"; - break; - - default: - break; - } - self::_putDebug( - sprintf( - "status-code: %s%s: %s ", - $this->serveroutput->body[$this->_parsing->offset], - $this->serveroutput->body[$this->_parsing->offset + 1], - $this->serveroutput->status), - 4); - return; - } - - protected function _parseRequestID() - { - $this->serveroutput->request_id = - self::_interpretInteger( - substr($this->serveroutput->body, $this->_parsing->offset, 4) - ); - self::_putDebug("request-id " . $this->serveroutput->request_id, 2); - $this->_parsing->offset+= 4; - return; - } - - protected function _interpretInteger($value) - { - // they are _signed_ integers - $value_parsed = 0; - for ($i = strlen($value); $i > 0; $i --) - { - $value_parsed += - ( - (1 << (($i - 1) * 8)) - * - ord($value[strlen($value) - $i]) - ); - - } - if ($value_parsed >= 2147483648) - { - $value_parsed -= 4294967296; - } - return $value_parsed; - } - - protected function _parseResponse() - { - } - - // - // REQUEST BUILDING - // - - protected function _stringJob() - { - if (!isset($this->setup->charset)) self::setCharset('us-ascii'); - if (!isset($this->setup->datatype)) self::setBinary(); - if (!isset($this->setup->uri)) - { - $this->getPrinters(); - unset($this->jobs[count($this->jobs) - 1]); - unset($this->jobs_uri[count($this->jobs_uri) - 1]); - unset($this->status[count($this->status) - 1]); - if (array_key_exists(0, $this->available_printers)) - { - self::setPrinterURI($this->available_printers[0]); - } - else - { - trigger_error( - _("_stringJob: Printer URI is not set: die"), - E_USER_WARNING); - self::_putDebug(_("_stringJob: Printer URI is not set: die") , 4); - self::_errorLog(" Printer URI is not set, die", 2); - return FALSE; - } - } - if (!isset($this->setup->copies)) self::setCopies(1); - if (!isset($this->setup->language)) self::setLanguage('en_us'); - if (!isset($this->setup->mime_media_type)) self::setMimeMediaType(); - if (!isset($this->setup->jobname)) self::setJobName(); - unset($this->setup->jobname); - if (!isset($this->meta->username)) self::setUserName(); - if (!isset($this->meta->fidelity)) $this->meta->fidelity = ''; - if (!isset($this->meta->document_name)) $this->meta->document_name = ''; - if (!isset($this->meta->sides)) $this->meta->sides = ''; - if (!isset($this->meta->page_ranges)) $this->meta->page_ranges = ''; - $jobattributes = ''; - $operationattributes = ''; - $printerattributes = ''; - $this->_buildValues($operationattributes, $jobattributes, $printerattributes); - self::_setOperationId(); - if (!isset($this->error_generation->request_body_malformed)) - { - $this->error_generation->request_body_malformed = ""; - } - $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number - . chr(0x00) . chr(0x02) // Print-Job | operation-id - . $this->meta->operation_id // request-id - . chr(0x01) // start operation-attributes | operation-attributes-tag - . $this->meta->charset - . $this->meta->language - . $this->meta->printer_uri - . $this->meta->username - . $this->meta->jobname - . $this->meta->fidelity - . $this->meta->document_name - . $this->meta->mime_media_type - . $operationattributes; - if ($this->meta->copies || $this->meta->sides || $this->meta->page_ranges || !empty($jobattributes)) - { - $this->stringjob .= - chr(0x02) // start job-attributes | job-attributes-tag - . $this->meta->copies - . $this->meta->sides - . $this->meta->page_ranges - . $jobattributes - ; - } - $this->stringjob.= chr(0x03); // end-of-attributes | end-of-attributes-tag - self::_putDebug( - sprintf(_("String sent to the server is: %s"), - $this->stringjob) - ); - return TRUE; - } - - protected function _buildValues(&$operationattributes, &$jobattributes, &$printerattributes) - { - $operationattributes = ''; - foreach($this->operation_tags as $key => $values) - { - $item = 0; - if (array_key_exists('value', $values)) - { - foreach($values['value'] as $item_value) + public function setLog($log_destination, $destination_type = 'file', $level = 2) { - if ($item == 0) - { - $operationattributes .= - $values['systag'] - . self::_giveMeStringLength($key) - . $key - . self::_giveMeStringLength($item_value) - . $item_value; - } - else - { - $operationattributes .= - $values['systag'] - . self::_giveMeStringLength('') - . self::_giveMeStringLength($item_value) - . $item_value; - } - $item++; + if (!file_exists($log_destination) && is_writable(dirname($log_destination))) + { + touch($log_destination); + chmod($log_destination, 0777); + } + + switch ($destination_type) + { + case 'file': + case 3: + $this->log_destination = $log_destination; + $this->log_type = 3; + break; + + case 'logger': + case 0: + $this->log_destination = ''; + $this->log_type = 0; + break; + + case 'e-mail': + case 1: + $this->log_destination = $log_destination; + $this->log_type = 1; + break; + } + $this->log_level = $level; } - } - } - $jobattributes = ''; - foreach($this->job_tags as $key => $values) - { - $item = 0; - if (array_key_exists('value', $values)) - { - foreach($values['value'] as $item_value) + + public function printDebug() { - if ($item == 0) - { - $jobattributes .= - $values['systag'] - . self::_giveMeStringLength($key) - . $key - . self::_giveMeStringLength($item_value) - . $item_value; - } - else - { - $jobattributes .= - $values['systag'] - . self::_giveMeStringLength('') - . self::_giveMeStringLength($item_value) - . $item_value; - } - $item++; + for ($i = 0; $i < $this->debug_count; $i++) + { + echo $this->debug[$i], "\n"; + } + $this->debug = array(); + $this->debug_count = 0; } - } - } - $printerattributes = ''; - foreach($this->printer_tags as $key => $values) - { - $item = 0; - if (array_key_exists('value', $values)) - { - foreach($values['value'] as $item_value) + + public function getDebug() { - if ($item == 0) - { - $printerattributes .= - $values['systag'] - . self::_giveMeStringLength($key) - . $key - . self::_giveMeStringLength($item_value) - . $item_value; - } - else - { - $printerattributes .= - $values['systag'] - . self::_giveMeStringLength('') - . self::_giveMeStringLength($item_value) - . $item_value; - } - $item++; + $debug = ''; + for ($i = 0; $i < $this->debug_count; $i++) + { + $debug.= $this->debug[$i]; + } + $this->debug = array(); + $this->debug_count = 0; + return $debug; } - } - } - reset($this->job_tags); - reset($this->operation_tags); - reset($this->printer_tags); - return true; - } - protected function _giveMeStringLength($string) - { - $length = strlen($string); - if ($length > ((0xFF << 8) + 0xFF) ) - { - $errmsg = sprintf ( - _('max string length for an ipp meta-information = %d, while here %d'), - ((0xFF << 8) + 0xFF), $length); - - if ($this->with_exceptions) - { - throw new ippException($errmsg); - } - else - { - trigger_error ($errmsg, E_USER_ERROR); - } - } - $int1 = $length & 0xFF; - $length -= $int1; - $length = $length >> 8; - $int2 = $length & 0xFF; - return chr($int2) . chr($int1); - } - - protected function _enumBuild($tag, $value) - { - switch ($tag) - { - case "orientation-requested": - switch ($value) + // + // OPERATIONS + // + public function printJob() { - case 'portrait': - $value = chr(3); - break; - - case 'landscape': - $value = chr(4); - break; - - case 'reverse-landscape': - $value = chr(5); - break; - - case 'reverse-portrait': - $value = chr(6); - break; - } - break; - - case "print-quality": - switch ($value) - { - case 'draft': - $value = chr(3); - break; - - case 'normal': - $value = chr(4); - break; - - case 'high': - $value = chr(5); - break; - } - break; - - case "finishing": - switch ($value) - { - case 'none': - $value = chr(3); - break; - - case 'staple': - $value = chr(4); - break; - - case 'punch': - $value = chr(5); - break; - - case 'cover': - $value = chr(6); - break; - - case 'bind': - $value = chr(7); - break; - - case 'saddle-stitch': - $value = chr(8); - break; - - case 'edge-stitch': - $value = chr(9); - break; - - case 'staple-top-left': - $value = chr(20); - break; - - case 'staple-bottom-left': - $value = chr(21); - break; - - case 'staple-top-right': - $value = chr(22); - break; - - case 'staple-bottom-right': - $value = chr(23); - break; - - case 'edge-stitch-left': - $value = chr(24); - break; - - case 'edge-stitch-top': - $value = chr(25); - break; - - case 'edge-stitch-right': - $value = chr(26); - break; - - case 'edge-stitch-bottom': - $value = chr(27); - break; - - case 'staple-dual-left': - $value = chr(28); - break; - - case 'staple-dual-top': - $value = chr(29); - break; - - case 'staple-dual-right': - $value = chr(30); - break; - - case 'staple-dual-bottom': - $value = chr(31); - break; - } - break; - } - $prepend = ''; - while ((strlen($value) + strlen($prepend)) < 4) - { - $prepend .= chr(0); - } - return $prepend . $value; - } - - protected function _integerBuild($value) - { - if ($value >= 2147483647 || $value < - 2147483648) - { - trigger_error( - _("Values must be between -2147483648 and 2147483647: assuming '0'") , E_USER_WARNING); - return chr(0x00) . chr(0x00) . chr(0x00) . chr(0x00); - } - $initial_value = $value; - $int1 = $value & 0xFF; - $value -= $int1; - $value = $value >> 8; - $int2 = $value & 0xFF; - $value-= $int2; - $value = $value >> 8; - $int3 = $value & 0xFF; - $value-= $int3; - $value = $value >> 8; - $int4 = $value & 0xFF; //64bits - if ($initial_value < 0) $int4 = chr($int4) | chr(0x80); - else $int4 = chr($int4); - $value = $int4 . chr($int3) . chr($int2) . chr($int1); - return $value; - } - - protected function _rangeOfIntegerBuild($integers) - { - #$integers = split(":", $integers); - $integers = preg_split("#:#", $integers); - for ($i = 0; $i < 2; $i++) $outvalue[$i] = self::_integerBuild($integers[$i]); - return $outvalue[0] . $outvalue[1]; - } - - protected function _setJobAttribute($attribute, $value) - { - //used by setAttribute - $tag_type = $this->job_tags[$attribute]['tag']; - switch ($tag_type) - { - case 'integer': - $this->job_tags[$attribute]['value'][] = self::_integerBuild($value); - break; - - case 'nameWithoutLanguage': - case 'nameWithLanguage': - case 'textWithoutLanguage': - case 'textWithLanguage': - case 'keyword': - case 'naturalLanguage': - $this->job_tags[$attribute]['value'][] = $value; - break; - - case 'enum': - $value = $this->_enumBuild($attribute, $value); // may be overwritten by children - $this->job_tags[$attribute]['value'][] = $value; - break; - - case 'rangeOfInteger': - // $value have to be: INT1:INT2 , eg 100:1000 - $this->job_tags[$attribute]['value'][] = self::_rangeOfIntegerBuild($value); - break; - - case 'resolution': - if (preg_match("#dpi#", $value)) $unit = chr(0x3); - if (preg_match("#dpc#", $value)) $unit = chr(0x4); - $search = array( - "#(dpi|dpc)#", - '#(x|-)#' + // this BASIC version of printJob do not parse server + // output for job's attributes + self::_putDebug( + sprintf( + "************** Date: %s ***********", + date('Y-m-d H:i:s') + ) + ); + if (!$this->_stringJob()) { + return FALSE; + } + if (is_readable($this->data)) + { + self::_putDebug(_("Printing a FILE")); + $this->output = $this->stringjob; + if ($this->setup->datatype == "TEXT") + { + $this->output.= chr(0x16); + } + $post_values = array( + "Content-Type" => "application/ipp", + "Data" => $this->output, + "File" => $this->data ); - $replace = array( - "", - ":" - ); - $value = self::_rangeOfIntegerBuild(preg_replace($search, $replace, $value)) . $unit; - $this->job_tags[$attribute]['value'][] = $value; - break; + if ($this->setup->datatype == "TEXT" && !isset($this->setup->noFormFeed)) + { + $post_values = array_merge( + $post_values, + array( + "Filetype" => "TEXT" + ) + ); + } + } + else + { + self::_putDebug(_("Printing DATA")); + $this->output = + $this->stringjob + . $this->datahead + . $this->data + . $this->datatail; + $post_values = array( + "Content-Type" => "application/ipp", + "Data" => $this->output + ); + } + if (self::_sendHttp($post_values, $this->paths["printers"])) + { + self::_parseServerOutput(); + } + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { + $this->status = array_merge($this->status, array( + $this->serveroutput->status + )); + if ($this->serveroutput->status == "successfull-ok") + { + self::_errorLog( + sprintf("printing job %s: ", $this->last_job) + . $this->serveroutput->status, + 3); + } + else + { + self::_errorLog( + sprintf("printing job: ", $this->last_job) + . $this->serveroutput->status, + 1); + } + return $this->serveroutput->status; + } - default: - trigger_error(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , E_USER_NOTICE); - self::_putDebug(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); - self::_errorLog(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); - return FALSE; - break; - } - $this->job_tags[$attribute]['systag'] = $this->tags_types[$tag_type]['tag']; - } + $this->status = + array_merge($this->status, array("OPERATION FAILED")); + $this->jobs = + array_merge($this->jobs, array("")); + $this->jobs_uri = + array_merge($this->jobs_uri, array("")); - protected function _setOperationAttribute($attribute, $value) - { - //used by setAttribute - $tag_type = $this->operation_tags[$attribute]['tag']; - switch ($tag_type) - { - case 'integer': - $this->operation_tags[$attribute]['value'][] = self::_integerBuild($value); - break; + self::_errorLog("printing job : OPERATION FAILED", 1); + return false; + } - case 'keyword': - case 'naturalLanguage': - $this->operation_tags[$attribute]['value'][] = $value; - break; + // + // HTTP OUTPUT + // + protected function _sendHttp($post_values, $uri) + { + /* + This function Copyright (C) 2005-2006 Thomas Harding, Manuel Lemos + */ + $this->response_completed[] = "no"; + unset($this->serverouptut); + self::_putDebug(_("Processing HTTP request") , 2); + $this->serveroutput->headers = array(); + $this->serveroutput->body = ""; + $http = new http_class; + if (!$this->unix) { + $http->host = $this->host; + } + else { + $http->host = "localhost"; + } + $http->with_exceptions = $this->with_exceptions; + if ($this->debug_http) + { + $http->debug = 1; + $http->html_debug = 0; + } + else + { + $http->debug = 0; + $http->html_debug = 0; + } + $url = "http://" . $this->host; + if ($this->ssl) { + $url = "https://" . $this->host; + } + if ($this->unix) { + $url = "unix://" . $this->host; + } + $http->port = $this->port; + $http->timeout = $this->http_timeout; + $http->data_timeout = $this->http_data_timeout; + $http->force_multipart_form_post = false; + $http->user = $this->username; + $http->password = $this->password; + $error = $http->GetRequestArguments($url, $arguments); + $arguments["RequestMethod"] = "POST"; + $arguments["Headers"] = array( + "Content-Type" => "application/ipp" + ); + $arguments["BodyStream"] = array( + array( + "Data" => $post_values["Data"] + ) + ); + if (isset($post_values["File"])) { + $arguments["BodyStream"][] = array( + "File" => $post_values["File"] + ); + } + if (isset($post_values["FileType"]) + && !strcmp($post_values["FileType"], "TEXT") + ) + { + $arguments["BodyStream"][] = array("Data" => Chr(12)); + } + $arguments["RequestURI"] = $uri; + if ($this->with_exceptions && $this->handle_http_exceptions) + { + try + { + $success = $http->Open($arguments); + } + catch(httpException $e) + { + throw new ippException( + sprintf("http error: %s", $e->getMessage()), + $e->getErrno()); + } + } + else + { + $success = $http->Open($arguments); + } + if ($success[0] == true) + { + $success = $http->SendRequest($arguments); + if ($success[0] == true) + { + self::_putDebug("H T T P R E Q U E S T :"); + self::_putDebug("Request headers:"); + for (Reset($http->request_headers) , $header = 0; $header < count($http->request_headers); Next($http->request_headers) , $header++) + { + $header_name = Key($http->request_headers); + if (GetType($http->request_headers[$header_name]) == "array") + { + for ($header_value = 0; $header_value < count($http->request_headers[$header_name]); $header_value++) + { + self::_putDebug($header_name . ": " . $http->request_headers[$header_name][$header_value]); + } + } + else + { + self::_putDebug($header_name . ": " . $http->request_headers[$header_name]); + } + } + self::_putDebug("Request body:"); + self::_putDebug( + htmlspecialchars($http->request_body) + . "*********** END REQUEST BODY *********" + ); + $i = 0; + $headers = array(); + unset($this->serveroutput->headers); + $http->ReadReplyHeaders($headers); + self::_putDebug("H T T P R E S P O N S E :"); + self::_putDebug("Response headers:"); + for (Reset($headers) , $header = 0; $header < count($headers); Next($headers) , $header++) + { + $header_name = Key($headers); + if (GetType($headers[$header_name]) == "array") + { + for ($header_value = 0; $header_value < count($headers[$header_name]); $header_value++) + { + self::_putDebug($header_name . ": " . $headers[$header_name][$header_value]); + $this->serveroutput->headers[$i] = + $header_name . ": " + . $headers[$header_name][$header_value]; + $i++; + } + } + else + { + self::_putDebug($header_name . ": " . $headers[$header_name]); + $this->serveroutput->headers[$i] = + $header_name + . ": " + . $headers[$header_name]; + $i++; + } + } + self::_putDebug("\n\nResponse body:\n"); + $this->serveroutput->body = ""; + for (;;) + { + $http->ReadReplyBody($body, 1024); + if (strlen($body) == 0) { + break; + } - default: - trigger_error(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , E_USER_NOTICE); - self::_putDebug(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); - self::_errorLog(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); - return FALSE; - break; - } - $this->operation_tags[$attribute]['systag'] = $this->tags_types[$tag_type]['tag']; - } + self::_putDebug(htmlentities($body)); + $this->serveroutput->body.= $body; + } + self::_putDebug("********* END RESPONSE BODY ********"); + } + } + $http->Close(); + return true; + } - protected function _setPrinterAttribute($attribute, $value) - { - //used by setAttribute - $tag_type = $this->printer_tags[$attribute]['tag']; - switch ($tag_type) - { - case 'integer': - $this->printer_tags[$attribute]['value'][] = self::_integerBuild($value); - break; + // + // INIT + // + protected function _initTags() + { + $this->tags_types = array( + "unsupported" => array( + "tag" => chr(0x10) , + "build" => "" + ) , + "reserved" => array( + "tag" => chr(0x11) , + "build" => "" + ) , + "unknown" => array( + "tag" => chr(0x12) , + "build" => "" + ) , + "no-value" => array( + "tag" => chr(0x13) , + "build" => "no_value" + ) , + "integer" => array( + "tag" => chr(0x21) , + "build" => "integer" + ) , + "boolean" => array( + "tag" => chr(0x22) , + "build" => "boolean" + ) , + "enum" => array( + "tag" => chr(0x23) , + "build" => "enum" + ) , + "octetString" => array( + "tag" => chr(0x30) , + "build" => "octet_string" + ) , + "datetime" => array( + "tag" => chr(0x31) , + "build" => "datetime" + ) , + "resolution" => array( + "tag" => chr(0x32) , + "build" => "resolution" + ) , + "rangeOfInteger" => array( + "tag" => chr(0x33) , + "build" => "range_of_integers" + ) , + "textWithLanguage" => array( + "tag" => chr(0x35) , + "build" => "string" + ) , + "nameWithLanguage" => array( + "tag" => chr(0x36) , + "build" => "string" + ) , + /* + "text" => array ("tag" => chr(0x40), + "build" => "string"), + "text string" => array ("tag" => chr(0x40), + "build" => "string"), + */ + "textWithoutLanguage" => array( + "tag" => chr(0x41) , + "build" => "string" + ) , + "nameWithoutLanguage" => array( + "tag" => chr(0x42) , + "buid" => "string" + ) , + "keyword" => array( + "tag" => chr(0x44) , + "build" => "string" + ) , + "uri" => array( + "tag" => chr(0x45) , + "build" => "string" + ) , + "uriScheme" => array( + "tag" => chr(0x46) , + "build" => "string" + ) , + "charset" => array( + "tag" => chr(0x47) , + "build" => "string" + ) , + "naturalLanguage" => array( + "tag" => chr(0x48) , + "build" => "string" + ) , + "mimeMediaType" => array( + "tag" => chr(0x49) , + "build" => "string" + ) , + "extendedAttributes" => array( + "tag" => chr(0x7F) , + "build" => "extended" + ) , + ); + $this->operation_tags = array( + "compression" => array( + "tag" => "keyword" + ) , + "document-natural-language" => array( + "tag" => "naturalLanguage" + ) , + "job-k-octets" => array( + "tag" => "integer" + ) , + "job-impressions" => array( + "tag" => "integer" + ) , + "job-media-sheets" => array( + "tag" => "integer" + ) , + ); + $this->job_tags = array( + "job-priority" => array( + "tag" => "integer" + ) , + "job-hold-until" => array( + "tag" => "keyword" + ) , + "job-sheets" => array( + "tag" => "keyword" + ) , //banner page + "multiple-document-handling" => array( + "tag" => "keyword" + ) , + //"copies" => array("tag" => "integer"), + "finishings" => array( + "tag" => "enum" + ) , + //"page-ranges" => array("tag" => "rangeOfInteger"), // has its own function + //"sides" => array("tag" => "keyword"), // has its own function + "number-up" => array( + "tag" => "integer" + ) , + "orientation-requested" => array( + "tag" => "enum" + ) , + "media" => array( + "tag" => "keyword" + ) , + "printer-resolution" => array( + "tag" => "resolution" + ) , + "print-quality" => array( + "tag" => "enum" + ) , + "job-message-from-operator" => array( + "tag" => "textWithoutLanguage" + ) , + ); + $this->printer_tags = array( + "requested-attributes" => array( + "tag" => "keyword" + ) + ); + } - case 'keyword': - case 'naturalLanguage': - $this->printer_tags[$attribute]['value'][] = $value; - break; + // + // SETUP + // + protected function _setOperationId() + { + $prepend = ''; + $this->operation_id+= 1; + $this->meta->operation_id = self::_integerBuild($this->operation_id); + self::_putDebug("operation id is: " . $this->operation_id, 2); + } - default: - trigger_error(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , E_USER_NOTICE); - self::_putDebug(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); - self::_errorLog(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); - return FALSE; - break; - } - $this->printer_tags[$attribute]['systag'] = $this->tags_types[$tag_type]['tag']; - } + protected function _setJobId() + { + $this->meta->jobid+= 1; + $prepend = ''; + $prepend_length = 4 - strlen($this->meta->jobid); + for ($i = 0; $i < $prepend_length; $i++) { + $prepend.= '0'; + } + return $prepend . $this->meta->jobid; + } - // - // DEBUGGING - // - protected function _putDebug($string, $level = 1) - { - if ($level === false) return; - if ($level < $this->debug_level) return; - $this->debug[$this->debug_count] = substr($string, 0, 1024); - $this->debug_count++; - //$this->debug .= substr($string,0,1024); + protected function _setJobUri($job_uri) + { + $this->meta->job_uri = chr(0x45) // type uri + . chr(0x00) . chr(0x07) // name-length + . "job-uri" + //. chr(0x00).chr(strlen($job_uri)) + . self::_giveMeStringLength($job_uri) . $job_uri; + self::_putDebug("job-uri is: " . $job_uri, 2); + } - } + // + // RESPONSE PARSING + // + protected function _parseServerOutput() + { + $this->serveroutput->response = array(); + if (!self::_parseHttpHeaders()) { + return FALSE; + } + $this->_parsing->offset = 0; + self::_parseIppVersion(); + self::_parseStatusCode(); + self::_parseRequestID(); + $this->_parseResponse(); + //devel + self::_putDebug( + sprintf("***** IPP STATUS: %s ******", $this->serveroutput->status), + 4); + self::_putDebug("****** END OF OPERATION ****"); + return true; + } - // - // LOGGING - // - protected function _errorLog($string_to_log, $level) - { - if ($level < $this->log_level) return; - $string = sprintf('%s : %s:%s user %s : %s', basename($_SERVER['PHP_SELF']) , $this->host, $this->port, $this->requesting_user, $string_to_log); - if ($this->log_type == 0) - { - error_log($string); - return; - } - $string = sprintf("%s %s Host %s:%s user %s : %s\n", date('M d H:i:s') , basename($_SERVER['PHP_SELF']) , $this->host, $this->port, $this->requesting_user, $string_to_log); - error_log($string, $this->log_type, $this->log_destination); - return; - } + protected function _parseHttpHeaders() + { + $response = ""; + switch ($this->serveroutput->headers[0]) + { + case "http/1.1 200 ok: ": + $this->serveroutput->httpstatus = "HTTP/1.1 200 OK"; + $response = "OK"; + break; -}; -/* - * Local variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ -?> + // primitive http/1.0 for Lexmark printers (from Rick Baril) + case "http/1.0 200 ok: ": + $this->serveroutput->httpstatus = "HTTP/1.0 200 OK"; + $response = "OK"; + break; + + case "http/1.1 100 continue: ": + $this->serveroutput->httpstatus = "HTTP/1.1 100 CONTINUE"; + $response = "OK"; + break; + + case "": + $this->serveroutput->httpstatus = "HTTP/1.1 000 No Response From Server"; + $this->serveroutput->status = "HTTP-ERROR-000_NO_RESPONSE_FROM_SERVER"; + trigger_error("No Response From Server", E_USER_WARNING); + self::_errorLog("No Response From Server", 1); + $this->disconnected = 1; + return FALSE; + break; + + default: + $server_response = preg_replace("/: $/", '', $this->serveroutput->headers[0]); + #$strings = split(' ', $server_response, 3); + $strings = preg_split('# #', $server_response, 3); + $errno = $strings[1]; + $string = strtoupper(str_replace(' ', '_', $strings[2])); + trigger_error( + sprintf(_("server responds %s") , $server_response), + E_USER_WARNING); + self::_errorLog("server responds " . $server_response, 1); + $this->serveroutput->httpstatus = + strtoupper($strings[0]) + . " " + . $errno + . " " + . ucfirst($strings[2]); + + $this->serveroutput->status = + "HTTP-ERROR-" + . $errno + . "-" + . $string; + $this->disconnected = 1; + return FALSE; + break; + } + unset($this->serveroutput->headers); + return TRUE; + } + + protected function _parseIppVersion() + { + $ippversion = + (ord($this->serveroutput->body[$this->_parsing->offset]) * 256) + + ord($this->serveroutput->body[$this->_parsing->offset + 1]); + switch ($ippversion) + { + case 0x0101: + $this->serveroutput->ipp_version = "1.1"; + break; + + default: + $this->serveroutput->ipp_version = + sprintf("%u.%u (Unknown)", + ord($this->serveroutput->body[$this->_parsing->offset]) * 256, + ord($this->serveroutput->body[$this->_parsing->offset + 1])); + break; + } + self::_putDebug("I P P R E S P O N S E :\n\n"); + self::_putDebug( + sprintf("IPP version %s%s: %s", + ord($this->serveroutput->body[$this->_parsing->offset]), + ord($this->serveroutput->body[$this->_parsing->offset + 1]), + $this->serveroutput->ipp_version)); + $this->_parsing->offset+= 2; + return; + } + + protected function _parseStatusCode() + { + $status_code = + (ord($this->serveroutput->body[$this->_parsing->offset]) * 256) + + ord($this->serveroutput->body[$this->_parsing->offset + 1]); + $this->serveroutput->status = "NOT PARSED"; + $this->_parsing->offset+= 2; + if (strlen($this->serveroutput->body) < $this->_parsing->offset) + { + return false; + } + if ($status_code < 0x00FF) + { + $this->serveroutput->status = "successfull"; + } + elseif ($status_code < 0x01FF) + { + $this->serveroutput->status = "informational"; + } + elseif ($status_code < 0x02FF) + { + $this->serveroutput->status = "redirection"; + } + elseif ($status_code < 0x04FF) + { + $this->serveroutput->status = "client-error"; + } + elseif ($status_code < 0x05FF) + { + $this->serveroutput->status = "server-error"; + } + switch ($status_code) + { + case 0x0000: + $this->serveroutput->status = "successfull-ok"; + break; + + case 0x0001: + $this->serveroutput->status = "successful-ok-ignored-or-substituted-attributes"; + break; + + case 0x002: + $this->serveroutput->status = "successful-ok-conflicting-attributes"; + break; + + case 0x0400: + $this->serveroutput->status = "client-error-bad-request"; + break; + + case 0x0401: + $this->serveroutput->status = "client-error-forbidden"; + break; + + case 0x0402: + $this->serveroutput->status = "client-error-not-authenticated"; + break; + + case 0x0403: + $this->serveroutput->status = "client-error-not-authorized"; + break; + + case 0x0404: + $this->serveroutput->status = "client-error-not-possible"; + break; + + case 0x0405: + $this->serveroutput->status = "client-error-timeout"; + break; + + case 0x0406: + $this->serveroutput->status = "client-error-not-found"; + break; + + case 0x0407: + $this->serveroutput->status = "client-error-gone"; + break; + + case 0x0408: + $this->serveroutput->status = "client-error-request-entity-too-large"; + break; + + case 0x0409: + $this->serveroutput->status = "client-error-request-value-too-long"; + break; + + case 0x040A: + $this->serveroutput->status = "client-error-document-format-not-supported"; + break; + + case 0x040B: + $this->serveroutput->status = "client-error-attributes-or-values-not-supported"; + break; + + case 0x040C: + $this->serveroutput->status = "client-error-uri-scheme-not-supported"; + break; + + case 0x040D: + $this->serveroutput->status = "client-error-charset-not-supported"; + break; + + case 0x040E: + $this->serveroutput->status = "client-error-conflicting-attributes"; + break; + + case 0x040F: + $this->serveroutput->status = "client-error-compression-not-supported"; + break; + + case 0x0410: + $this->serveroutput->status = "client-error-compression-error"; + break; + + case 0x0411: + $this->serveroutput->status = "client-error-document-format-error"; + break; + + case 0x0412: + $this->serveroutput->status = "client-error-document-access-error"; + break; + + case 0x0413: // RFC3380 + $this->serveroutput->status = "client-error-attributes-not-settable"; + break; + + case 0x0500: + $this->serveroutput->status = "server-error-internal-error"; + break; + + case 0x0501: + $this->serveroutput->status = "server-error-operation-not-supported"; + break; + + case 0x0502: + $this->serveroutput->status = "server-error-service-unavailable"; + break; + + case 0x0503: + $this->serveroutput->status = "server-error-version-not-supported"; + break; + + case 0x0504: + $this->serveroutput->status = "server-error-device-error"; + break; + + case 0x0505: + $this->serveroutput->status = "server-error-temporary-error"; + break; + + case 0x0506: + $this->serveroutput->status = "server-error-not-accepting-jobs"; + break; + + case 0x0507: + $this->serveroutput->status = "server-error-busy"; + break; + + case 0x0508: + $this->serveroutput->status = "server-error-job-canceled"; + break; + + case 0x0509: + $this->serveroutput->status = "server-error-multiple-document-jobs-not-supported"; + break; + + default: + break; + } + self::_putDebug( + sprintf( + "status-code: %s%s: %s ", + $this->serveroutput->body[$this->_parsing->offset], + $this->serveroutput->body[$this->_parsing->offset + 1], + $this->serveroutput->status), + 4); + return; + } + + protected function _parseRequestID() + { + $this->serveroutput->request_id = + self::_interpretInteger( + substr($this->serveroutput->body, $this->_parsing->offset, 4) + ); + self::_putDebug("request-id " . $this->serveroutput->request_id, 2); + $this->_parsing->offset+= 4; + return; + } + + protected function _interpretInteger($value) + { + // they are _signed_ integers + $value_parsed = 0; + for ($i = strlen($value); $i > 0; $i --) + { + $value_parsed += + ( + (1 << (($i - 1) * 8)) + * + ord($value[strlen($value) - $i]) + ); + } + if ($value_parsed >= 2147483648) + { + $value_parsed -= 4294967296; + } + return $value_parsed; + } + + protected function _parseResponse() + { + } + + // + // REQUEST BUILDING + // + protected function _stringJob() + { + if (!isset($this->setup->charset)) { + self::setCharset(); + } + if (!isset($this->setup->datatype)) { + self::setBinary(); + } + if (!isset($this->setup->uri)) + { + $this->getPrinters(); + unset($this->jobs[count($this->jobs) - 1]); + unset($this->jobs_uri[count($this->jobs_uri) - 1]); + unset($this->status[count($this->status) - 1]); + if (array_key_exists(0, $this->available_printers)) + { + self::setPrinterURI($this->available_printers[0]); + } + else + { + trigger_error( + _("_stringJob: Printer URI is not set: die"), + E_USER_WARNING); + self::_putDebug(_("_stringJob: Printer URI is not set: die") , 4); + self::_errorLog(" Printer URI is not set, die", 2); + return FALSE; + } + } + if (!isset($this->setup->copies)) { + self::setCopies(1); + } + if (!isset($this->setup->language)) { + self::setLanguage('en_us'); + } + if (!isset($this->setup->mime_media_type)) { + self::setMimeMediaType(); + } + if (!isset($this->setup->jobname)) { + self::setJobName(); + } + unset($this->setup->jobname); + if (!isset($this->meta->username)) { + self::setUserName(); + } + if (!isset($this->meta->fidelity)) { + $this->meta->fidelity = ''; + } + if (!isset($this->meta->document_name)) { + $this->meta->document_name = ''; + } + if (!isset($this->meta->sides)) { + $this->meta->sides = ''; + } + if (!isset($this->meta->page_ranges)) { + $this->meta->page_ranges = ''; + } + $jobattributes = ''; + $operationattributes = ''; + $printerattributes = ''; + $this->_buildValues($operationattributes, $jobattributes, $printerattributes); + self::_setOperationId(); + if (!isset($this->error_generation->request_body_malformed)) + { + $this->error_generation->request_body_malformed = ""; + } + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number + . chr(0x00) . chr(0x02) // Print-Job | operation-id + . $this->meta->operation_id // request-id + . chr(0x01) // start operation-attributes | operation-attributes-tag + . $this->meta->charset + . $this->meta->language + . $this->meta->printer_uri + . $this->meta->username + . $this->meta->jobname + . $this->meta->fidelity + . $this->meta->document_name + . $this->meta->mime_media_type + . $operationattributes; + if ($this->meta->copies || $this->meta->sides || $this->meta->page_ranges || !empty($jobattributes)) + { + $this->stringjob .= + chr(0x02) // start job-attributes | job-attributes-tag + . $this->meta->copies + . $this->meta->sides + . $this->meta->page_ranges + . $jobattributes; + } + $this->stringjob.= chr(0x03); // end-of-attributes | end-of-attributes-tag + self::_putDebug( + sprintf(_("String sent to the server is: %s"), + $this->stringjob) + ); + return TRUE; + } + + protected function _buildValues(&$operationattributes, &$jobattributes, &$printerattributes) + { + $operationattributes = ''; + foreach($this->operation_tags as $key => $values) + { + $item = 0; + if (array_key_exists('value', $values)) + { + foreach($values['value'] as $item_value) + { + if ($item == 0) + { + $operationattributes .= + $values['systag'] + . self::_giveMeStringLength($key) + . $key + . self::_giveMeStringLength($item_value) + . $item_value; + } + else + { + $operationattributes .= + $values['systag'] + . self::_giveMeStringLength('') + . self::_giveMeStringLength($item_value) + . $item_value; + } + $item++; + } + } + } + $jobattributes = ''; + foreach($this->job_tags as $key => $values) + { + $item = 0; + if (array_key_exists('value', $values)) + { + foreach($values['value'] as $item_value) + { + if ($item == 0) + { + $jobattributes .= + $values['systag'] + . self::_giveMeStringLength($key) + . $key + . self::_giveMeStringLength($item_value) + . $item_value; + } + else + { + $jobattributes .= + $values['systag'] + . self::_giveMeStringLength('') + . self::_giveMeStringLength($item_value) + . $item_value; + } + $item++; + } + } + } + $printerattributes = ''; + foreach($this->printer_tags as $key => $values) + { + $item = 0; + if (array_key_exists('value', $values)) + { + foreach($values['value'] as $item_value) + { + if ($item == 0) + { + $printerattributes .= + $values['systag'] + . self::_giveMeStringLength($key) + . $key + . self::_giveMeStringLength($item_value) + . $item_value; + } + else + { + $printerattributes .= + $values['systag'] + . self::_giveMeStringLength('') + . self::_giveMeStringLength($item_value) + . $item_value; + } + $item++; + } + } + } + reset($this->job_tags); + reset($this->operation_tags); + reset($this->printer_tags); + return true; + } + + protected function _giveMeStringLength($string) + { + $length = strlen($string); + if ($length > ((0xFF << 8) + 0xFF) ) + { + $errmsg = sprintf ( + _('max string length for an ipp meta-information = %d, while here %d'), + ((0xFF << 8) + 0xFF), $length); + + if ($this->with_exceptions) + { + throw new ippException($errmsg); + } + else + { + trigger_error ($errmsg, E_USER_ERROR); + } + } + $int1 = $length & 0xFF; + $length -= $int1; + $length = $length >> 8; + $int2 = $length & 0xFF; + return chr($int2) . chr($int1); + } + + protected function _enumBuild($tag, $value) + { + switch ($tag) + { + case "orientation-requested": + switch ($value) + { + case 'portrait': + $value = chr(3); + break; + + case 'landscape': + $value = chr(4); + break; + + case 'reverse-landscape': + $value = chr(5); + break; + + case 'reverse-portrait': + $value = chr(6); + break; + } + break; + + case "print-quality": + switch ($value) + { + case 'draft': + $value = chr(3); + break; + + case 'normal': + $value = chr(4); + break; + + case 'high': + $value = chr(5); + break; + } + break; + + case "finishing": + switch ($value) + { + case 'none': + $value = chr(3); + break; + + case 'staple': + $value = chr(4); + break; + + case 'punch': + $value = chr(5); + break; + + case 'cover': + $value = chr(6); + break; + + case 'bind': + $value = chr(7); + break; + + case 'saddle-stitch': + $value = chr(8); + break; + + case 'edge-stitch': + $value = chr(9); + break; + + case 'staple-top-left': + $value = chr(20); + break; + + case 'staple-bottom-left': + $value = chr(21); + break; + + case 'staple-top-right': + $value = chr(22); + break; + + case 'staple-bottom-right': + $value = chr(23); + break; + + case 'edge-stitch-left': + $value = chr(24); + break; + + case 'edge-stitch-top': + $value = chr(25); + break; + + case 'edge-stitch-right': + $value = chr(26); + break; + + case 'edge-stitch-bottom': + $value = chr(27); + break; + + case 'staple-dual-left': + $value = chr(28); + break; + + case 'staple-dual-top': + $value = chr(29); + break; + + case 'staple-dual-right': + $value = chr(30); + break; + + case 'staple-dual-bottom': + $value = chr(31); + break; + } + break; + } + $prepend = ''; + while ((strlen($value) + strlen($prepend)) < 4) + { + $prepend .= chr(0); + } + return $prepend . $value; + } + + protected function _integerBuild($value) + { + if ($value >= 2147483647 || $value < - 2147483648) + { + trigger_error( + _("Values must be between -2147483648 and 2147483647: assuming '0'") , E_USER_WARNING); + return chr(0x00) . chr(0x00) . chr(0x00) . chr(0x00); + } + $initial_value = $value; + $int1 = $value & 0xFF; + $value -= $int1; + $value = $value >> 8; + $int2 = $value & 0xFF; + $value-= $int2; + $value = $value >> 8; + $int3 = $value & 0xFF; + $value-= $int3; + $value = $value >> 8; + $int4 = $value & 0xFF; //64bits + if ($initial_value < 0) { + $int4 = chr($int4) | chr(0x80); + } + else { + $int4 = chr($int4); + } + $value = $int4 . chr($int3) . chr($int2) . chr($int1); + return $value; + } + + protected function _rangeOfIntegerBuild($integers) + { + #$integers = split(":", $integers); + $integers = preg_split("#:#", $integers); + for ($i = 0; $i < 2; $i++) { + $outvalue[$i] = self::_integerBuild($integers[$i]); + } + return $outvalue[0] . $outvalue[1]; + } + + protected function _setJobAttribute($attribute, $value) + { + //used by setAttribute + $tag_type = $this->job_tags[$attribute]['tag']; + switch ($tag_type) + { + case 'integer': + $this->job_tags[$attribute]['value'][] = self::_integerBuild($value); + break; + + case 'boolean': + case 'nameWithoutLanguage': + case 'nameWithLanguage': + case 'textWithoutLanguage': + case 'textWithLanguage': + case 'keyword': + case 'naturalLanguage': + $this->job_tags[$attribute]['value'][] = $value; + break; + + case 'enum': + $value = $this->_enumBuild($attribute, $value); // may be overwritten by children + $this->job_tags[$attribute]['value'][] = $value; + break; + + case 'rangeOfInteger': + // $value have to be: INT1:INT2 , eg 100:1000 + $this->job_tags[$attribute]['value'][] = self::_rangeOfIntegerBuild($value); + break; + + case 'resolution': + if (preg_match("#dpi#", $value)) { + $unit = chr(0x3); + } + if (preg_match("#dpc#", $value)) { + $unit = chr(0x4); + } + $search = array( + "#(dpi|dpc)#", + '#(x|-)#' + ); + $replace = array( + "", + ":" + ); + $value = self::_rangeOfIntegerBuild(preg_replace($search, $replace, $value)) . $unit; + $this->job_tags[$attribute]['value'][] = $value; + break; + + default: + trigger_error(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , E_USER_NOTICE); + self::_putDebug(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); + self::_errorLog(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); + return FALSE; + break; + } + $this->job_tags[$attribute]['systag'] = $this->tags_types[$tag_type]['tag']; + } + + protected function _setOperationAttribute($attribute, $value) + { + //used by setAttribute + $tag_type = $this->operation_tags[$attribute]['tag']; + switch ($tag_type) + { + case 'integer': + $this->operation_tags[$attribute]['value'][] = self::_integerBuild($value); + break; + + case 'keyword': + case 'naturalLanguage': + $this->operation_tags[$attribute]['value'][] = $value; + break; + + default: + trigger_error(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , E_USER_NOTICE); + self::_putDebug(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); + self::_errorLog(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); + return FALSE; + break; + } + $this->operation_tags[$attribute]['systag'] = $this->tags_types[$tag_type]['tag']; + } + + protected function _setPrinterAttribute($attribute, $value) + { + //used by setAttribute + $tag_type = $this->printer_tags[$attribute]['tag']; + switch ($tag_type) + { + case 'integer': + $this->printer_tags[$attribute]['value'][] = self::_integerBuild($value); + break; + + case 'keyword': + case 'naturalLanguage': + $this->printer_tags[$attribute]['value'][] = $value; + break; + + default: + trigger_error(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , E_USER_NOTICE); + self::_putDebug(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); + self::_errorLog(sprintf(_('SetAttribute: Tag "%s": cannot set attribute') , $attribute) , 2); + return FALSE; + break; + } + $this->printer_tags[$attribute]['systag'] = $this->tags_types[$tag_type]['tag']; + } + + // + // DEBUGGING + // + protected function _putDebug($string, $level = 1) + { + if ($level === false) { + return; + } + + if ($level < $this->debug_level) { + return; + } + + $this->debug[$this->debug_count] = substr($string, 0, 1024); + $this->debug_count++; + //$this->debug .= substr($string,0,1024); + + } + + // + // LOGGING + // + protected function _errorLog($string_to_log, $level) + { + if ($level > $this->log_level) { + return; + } + + $string = sprintf('%s : %s:%s user %s : %s', basename($_SERVER['PHP_SELF']) , $this->host, $this->port, $this->requesting_user, $string_to_log); + + if ($this->log_type == 0) + { + error_log($string); + return; + } + + $string = sprintf("%s %s Host %s:%s user %s : %s\n", date('M d H:i:s') , basename($_SERVER['PHP_SELF']) , $this->host, $this->port, $this->requesting_user, $string_to_log); + error_log($string, $this->log_type, $this->log_destination); + return; + } +} diff --git a/htdocs/includes/printipp/CupsPrintIPP.php b/htdocs/includes/printipp/CupsPrintIPP.php index a7e5a305da5..7808c64a722 100644 --- a/htdocs/includes/printipp/CupsPrintIPP.php +++ b/htdocs/includes/printipp/CupsPrintIPP.php @@ -1,5 +1,5 @@ jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); $this->parsed = array(); unset($this->printer_attributes); - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en'); - + } + self::_setOperationId(); - + for($i = 0 ; $i < count($attributes) ; $i++) + { if ($i == 0) + { $this->meta->attributes = chr(0x44) // Keyword . self::_giveMeStringLength('requested-attributes') . 'requested-attributes' . self::_giveMeStringLength($attributes[0]) . $attributes[0]; + } else + { $this->meta->attributes .= chr(0x44) // Keyword . chr(0x0).chr(0x0) // zero-length name . self::_giveMeStringLength($attributes[$i]) . $attributes[$i]; - - $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 + } + } + + $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 . chr(0x40). chr(0x01) // operation: cups vendor extension: get defaults . $this->meta->operation_id // request-id . chr(0x01) // start operation-attributes | operation-attributes-tag @@ -97,69 +103,83 @@ class CupsPrintIPP extends ExtendedPrintIPP { . $this->meta->language . $this->meta->attributes . chr(0x03); // end operations attribute - + $this->output = $this->stringjob; - + self::_putDebug("Request: ".$this->output); - + $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output); - - if (self::_sendHttp ($post_values,'/')) { - + + if (self::_sendHttp ($post_values,'/')) + { + if(self::_parseServerOutput()) + { self::_parsePrinterAttributes(); } - + } + $this->attributes = &$this->printer_attributes; - - if (isset($this->printer_attributes->printer_type)) { + + if (isset($this->printer_attributes->printer_type)) + { $printer_type = $this->printer_attributes->printer_type->_value0; $table = self::_interpretPrinterType($printer_type); - - for($i = 0 ; $i < count($table) ; $i++ ) { + + for($i = 0 ; $i < count($table) ; $i++ ) + { $index = '_value'.$i; $this->printer_attributes->printer_type->$index = $table[$i]; } - } - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { + $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog("getting defaults: ".$this->serveroutput->status,3); + } else + { self::_errorLog("getting defaults: ".$this->serveroutput->status,1); - - return $this->serveroutput->status; - - } else { + } + + return $this->serveroutput->status; + } + else + { $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog("getting defaults : OPERATION FAILED",1); } - return false; + return false; } - // }}} - - // {{{ cupsAcceptJobs ($printer_uri) - public function cupsAcceptJobs($printer_uri) { + + + public function cupsAcceptJobs($printer_uri) + { //The CUPS-Get-Default operation returns the default printer URI and attributes - + $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); $this->parsed = array(); unset($this->printer_attributes); - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en'); - + } + self::_setOperationId(); - - $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 + + $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 . chr(0x40). chr(0x08) // operation: cups vendor extension: Accept-Jobs . $this->meta->operation_id // request-id . chr(0x01) // start operation-attributes | operation-attributes-tag @@ -171,65 +191,80 @@ class CupsPrintIPP extends ExtendedPrintIPP { . self::_giveMeStringLength($printer_uri) . $printer_uri . chr(0x03); // end operations attribute - + $this->output = $this->stringjob; - + self::_putDebug("Request: ".$this->output); - + $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output); - - if (self::_sendHttp ($post_values,'/admin/')) { - + + if (self::_sendHttp ($post_values,'/admin/')) + { + if(self::_parseServerOutput()) + { self::_parseAttributes(); } - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + } + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { + $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog("getting defaults: ".$this->serveroutput->status,3); + } else + { self::_errorLog("getting defaults: ".$this->serveroutput->status,1); - - return $this->serveroutput->status; - - } else { + } + + return $this->serveroutput->status; + } + else + { $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog("getting defaults : OPERATION FAILED",1); } - return false; + return false; } - // }}} - // {{{ cupsRejectJobs ($printer_uri,$printer_state_message=false) - public function cupsRejectJobs($printer_uri,$printer_state_message) { + + public function cupsRejectJobs($printer_uri,$printer_state_message) + { //The CUPS-Get-Default operation returns the default printer URI and attributes - + $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); $this->parsed = array(); unset($this->attributes); - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en'); - + } + self::_setOperationId(); - + $message = ""; if ($printer_state_message) + { $message = chr(0x04) // start printer-attributes . chr(0x41) // textWithoutLanguage . self::_giveMeStringLength("printer-state-message") . "printer-state-message" . self::_giveMeStringLength($printer_state_message) . $printer_state_message; + } - $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 + $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 . chr(0x40). chr(0x09) // operation: cups vendor extension: Reject-Jobs . $this->meta->operation_id // request-id . chr(0x01) // start operation-attributes | operation-attributes-tag @@ -242,89 +277,111 @@ class CupsPrintIPP extends ExtendedPrintIPP { . $printer_uri . $message . chr(0x03); // end operations attribute - + $this->output = $this->stringjob; - + self::_putDebug("Request: ".$this->output); - + $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output); - - if (self::_sendHttp ($post_values,'/admin/')) { - + + if (self::_sendHttp ($post_values,'/admin/')) + { + if(self::_parseServerOutput()) + { self::_parseAttributes(); } - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + } + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { + $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog("getting defaults: ".$this->serveroutput->status,3); + } else + { self::_errorLog("getting defaults: ".$this->serveroutput->status,1); - - return $this->serveroutput->status; - - } else { + } + + return $this->serveroutput->status; + } + else + { $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog("getting defaults : OPERATION FAILED",1); - } - return false; + } + return false; } - // }}} - // {{{ getPrinters() - public function getPrinters($printer_location=false,$printer_info=false,$attributes=array()) { - + + public function getPrinters($printer_location=false,$printer_info=false,$attributes=array()) + { if (count($attributes) == 0) - true; - $attributes=array('printer-uri-supported','printer-location','printer-info','printer-type','color-supported'); + { + true; + } + $attributes=array('printer-uri-supported', 'printer-location', 'printer-info', 'printer-type', 'color-supported', 'printer-name'); $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); - + unset ($this->printers_attributes); - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en-us'); - + } + self::_setOperationId(); - + $this->meta->attributes=''; - + if ($printer_location) + { $this->meta->attributes .= chr(0x41) // textWithoutLanguage . self::_giveMeStringLength('printer-location') . 'printer-location' . self::_giveMeStringLength($printer_location) . $printer_location; - - + } + if ($printer_info) + { $this->meta->attributes .= chr(0x41) // textWithoutLanguage . self::_giveMeStringLength('printer-info') . 'printer-info' . self::_giveMeStringLength($printer_info) . $printer_info; - + } + for($i = 0 ; $i < count($attributes) ; $i++) + { if ($i == 0) + { $this->meta->attributes .= chr(0x44) // Keyword . self::_giveMeStringLength('requested-attributes') . 'requested-attributes' . self::_giveMeStringLength($attributes[0]) . $attributes[0]; + } else + { $this->meta->attributes .= chr(0x44) // Keyword . chr(0x0).chr(0x0) // zero-length name . self::_giveMeStringLength($attributes[$i]) . $attributes[$i]; + } + } - - $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 + $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 . chr(0x40). chr(0x02) // operation: cups vendor extension: get printers . $this->meta->operation_id // request-id . chr(0x01) // start operation-attributes | operation-attributes-tag @@ -332,78 +389,89 @@ class CupsPrintIPP extends ExtendedPrintIPP { . $this->meta->language . $this->meta->attributes . chr(0x03); // end operations attribute - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output); - - if (self::_sendHttp ($post_values,'/')) { - - if(self::_parseServerOutput()) - $this->_getAvailablePrinters(); + if (self::_sendHttp ($post_values,'/')) + { + + if(self::_parseServerOutput()) + { + $this->_getAvailablePrinters(); } - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + } + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { + $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog("getting printers: ".$this->serveroutput->status,3); + } else + { self::_errorLog("getting printers: ".$this->serveroutput->status,1); - return $this->serveroutput->status; - - } else { + } + return $this->serveroutput->status; + } + else + { $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog("getting printers : OPERATION FAILED",1); - } - return false; + } + return false; } - // }}} - // {{{ cupsGetPrinters () - public function cupsGetPrinters () { - // alias for getPrinters(); + + public function cupsGetPrinters () + { + // alias for getPrinters(); self::getPrinters(); } - // }}} - // {{{ getPrinterAttributes() - public function getPrinterAttributes() { - // complete informations from parent with Cups-specific stuff - + + public function getPrinterAttributes() + { + // complete informations from parent with Cups-specific stuff + if(!$result = parent::getPrinterAttributes()) + { return FALSE; + } if(!isset($this->printer_attributes)) + { return FALSE; - - if (isset ($this->printer_attributes->printer_type)) { + } + + if (isset ($this->printer_attributes->printer_type)) + { $printer_type = $this->printer_attributes->printer_type->_value0; $table = self::_interpretPrinterType($printer_type); - - for($i = 0 ; $i < count($table) ; $i++ ) { + + for($i = 0 ; $i < count($table) ; $i++ ) + { $index = '_value'.$i; $this->printer_attributes->printer_type->$index = $table[$i]; - } } + } - return $result; + return $result; } - // }}} // // SETUP // - - // {{{ _initTags () - protected function _initTags () { - + protected function _initTags () + { // override parent with specific cups attributes - - $operation_tags = array (); + + $operation_tags = array (); $this->operation_tags = array_merge ($this->operation_tags, $operation_tags); - + $job_tags = array ( "job-billing" => array("tag" => "textWithoutLanguage"), "blackplot" => array("tag" => "boolean"), "brightness" => array("tag" => "integer"), @@ -430,25 +498,23 @@ class CupsPrintIPP extends ExtendedPrintIPP { "saturation" => array("tag" => "integer"), "scaling" => array("tag" => "integer"), "wrap" => array("tag","boolean"), - + ); $this->job_tags = array_merge ($this->job_tags, $job_tags); } - // }}} -// -// REQUEST BUILDING -// - - // {{{ _enumBuild ($tag,$value) - protected function _enumBuild ($tag,$value) { - + // + // REQUEST BUILDING + // + protected function _enumBuild ($tag,$value) + { $value_built = parent::_enumBuild($tag,$value); - - switch ($tag) { - case "cpi": - switch ($value) { + switch ($tag) + { + case "cpi": + switch ($value) + { case '10': $value_built = chr(10); break; @@ -463,7 +529,8 @@ class CupsPrintIPP extends ExtendedPrintIPP { } break; case "lpi": - switch ($value) { + switch ($value) + { case '6': $value_built = chr(6); break; @@ -479,60 +546,66 @@ class CupsPrintIPP extends ExtendedPrintIPP { $prepend = ''; while ((strlen($value_built) + strlen($prepend)) < 4) $prepend .= chr(0); - return $prepend.$value_built; + return $prepend.$value_built; } - // }}} - -// -// RESPONSE PARSING -// - // {{{ _getAvailablePrinters () - private function _getAvailablePrinters () { - + // + // RESPONSE PARSING + // + private function _getAvailablePrinters () + { $this->available_printers = array(); + $this->printer_map = array(); $k = 0; - $this->printers_attributes = new stdClass(); + $this->printers_attributes = new \stdClass(); for ($i = 0 ; (array_key_exists($i,$this->serveroutput->response)) ; $i ++) - if (($this->serveroutput->response[$i]['attributes']) == "printer-attributes") { + { + if (($this->serveroutput->response[$i]['attributes']) == "printer-attributes") + { $phpname = "_printer".$k; - $this->printers_attributes->$phpname = new stdClass(); - for ($j = 0 ; array_key_exists($j,$this->serveroutput->response[$i]) ; $j++) { - + $this->printers_attributes->$phpname = new \stdClass(); + for ($j = 0 ; array_key_exists($j,$this->serveroutput->response[$i]) ; $j++) + { + $value = $this->serveroutput->response[$i][$j]['value']; $name = str_replace("-","_",$this->serveroutput->response[$i][$j]['name']); - - switch ($name) { + + switch ($name) + { case "printer_uri_supported": $this->available_printers = array_merge($this->available_printers,array($value)); break; case "printer_type": $table = self::_interpretPrinterType($value); - $this->printers_attributes->$phpname->$name = new stdClass(); - - for($l = 0 ; $l < count($table) ; $l++ ) { + $this->printers_attributes->$phpname->$name = new \stdClass(); + + for($l = 0 ; $l < count($table) ; $l++ ) + { $index = '_value'.$l; $this->printers_attributes->$phpname->$name->$index = $table[$l]; } - + break; case '': break; + case 'printer_name': + $this->printer_map[$value] = $k; + break; default: $this->printers_attributes->$phpname->$name = $value; break; - } - - } - $k ++; + } } + $k ++; + } + } } - // }}} - - // {{{ _getEnumVendorExtensions - protected function _getEnumVendorExtensions ($value_parsed) { - switch ($value_parsed) { + + protected function _getEnumVendorExtensions ($value_parsed) + { + switch ($value_parsed) + { case 0x4002: $value = 'Get-Availables-Printers'; break; @@ -541,110 +614,152 @@ class CupsPrintIPP extends ExtendedPrintIPP { break; } - if (isset($value)) - return ($value); - - return sprintf('Unknown: 0x%x',$value_parsed); - } - // }}} + if (isset($value)) + { + return ($value); + } - // {{{ _interpretPrinterType($type) - private function _interpretPrinterType($value) { + return sprintf('Unknown: 0x%x',$value_parsed); + } + + + private function _interpretPrinterType($value) + { $value_parsed = 0; for ($i = strlen($value) ; $i > 0 ; $i --) + { $value_parsed += pow(256,($i - 1)) * ord($value[strlen($value) - $i]); - + } + $type[0] = $type[1] = $type[2] = $type[3] = $type[4] = $type[5] = ''; $type[6] = $type[7] = $type[8] = $type[9] = $type[10] = ''; $type[11] = $type[12] = $type[13] = $type[14] = $type[15] = ''; $type[16] = $type[17] = $type[18] = $type[19] = ''; - - if ($value_parsed %2 == 1) { + + if ($value_parsed %2 == 1) + { $type[0] = 'printer-class'; $value_parsed -= 1; - } - if ($value_parsed %4 == 2 ) { + } + + if ($value_parsed %4 == 2 ) + { $type[1] = 'remote-destination'; $value_parsed -= 2; - } - if ($value_parsed %8 == 4 ) { + } + + if ($value_parsed %8 == 4 ) + { $type[2] = 'print-black'; $value_parsed -= 4; - } - if ($value_parsed %16 == 8 ) { + } + + if ($value_parsed %16 == 8 ) + { $type[3] = 'print-color'; $value_parsed -= 8; - } - if ($value_parsed %32 == 16) { + } + + if ($value_parsed %32 == 16) + { $type[4] = 'hardware-print-on-both-sides'; $value_parsed -= 16; - } - if ($value_parsed %64 == 32) { + } + + if ($value_parsed %64 == 32) + { $type[5] = 'hardware-staple-output'; $value_parsed -= 32; - } - if ($value_parsed %128 == 64) { + } + + if ($value_parsed %128 == 64) + { $type[6] = 'hardware-fast-copies'; $value_parsed -= 64; - } - if ($value_parsed %256 == 128) { + } + + if ($value_parsed %256 == 128) + { $type[7] = 'hardware-fast-copy-collation'; $value_parsed -= 128; - } - if ($value_parsed %512 == 256) { + } + + if ($value_parsed %512 == 256) + { $type[8] = 'punch-output'; $value_parsed -= 256; - } - if ($value_parsed %1024 == 512) { + } + + if ($value_parsed %1024 == 512) + { $type[9] = 'cover-output'; $value_parsed -= 512; - } - if ($value_parsed %2048 == 1024) { + } + + if ($value_parsed %2048 == 1024) + { $type[10] = 'bind-output'; $value_parsed -= 1024; - } - if ($value_parsed %4096 == 2048) { + } + + if ($value_parsed %4096 == 2048) + { $type[11] = 'sort-output'; $value_parsed -= 2048; - } - if ($value_parsed %8192 == 4096) { + } + + if ($value_parsed %8192 == 4096) + { $type[12] = 'handle-media-up-to-US-Legal-A4'; $value_parsed -= 4096; - } - if ($value_parsed %16384 == 8192) { + } + + if ($value_parsed %16384 == 8192) + { $type[13] = 'handle-media-between-US-Legal-A4-and-ISO_C-A2'; $value_parsed -= 8192; - } - if ($value_parsed %32768 == 16384) { + } + + if ($value_parsed %32768 == 16384) + { $type[14] = 'handle-media-larger-than-ISO_C-A2'; $value_parsed -= 16384; - } - if ($value_parsed %65536 == 32768) { + } + + if ($value_parsed %65536 == 32768) + { $type[15] = 'handle-user-defined-media-sizes'; $value_parsed -= 32768; - } - if ($value_parsed %131072 == 65536) { + } + + if ($value_parsed %131072 == 65536) + { $type[16] = 'implicit-server-generated-class'; $value_parsed -= 65536; - } - if ($value_parsed %262144 == 131072) { + } + + if ($value_parsed %262144 == 131072) + { $type[17] = 'network-default-printer'; $value_parsed -= 131072; - } - if ($value_parsed %524288 == 262144) { + } + + if ($value_parsed %524288 == 262144) + { $type[18] = 'fax-device'; $value_parsed -= 262144; - } - return $type; - } - // }}} + } - // {{{ _interpretEnum() - protected function _interpretEnum($attribute_name,$value) { - + return $type; + } + + + protected function _interpretEnum($attribute_name,$value) + { $value_parsed = self::_interpretInteger($value); - - switch ($attribute_name) { + + switch ($attribute_name) + { case 'cpi': case 'lpi': $value = $value_parsed; @@ -652,20 +767,8 @@ class CupsPrintIPP extends ExtendedPrintIPP { default: $value = parent::_interpretEnum($attribute_name,$value); break; - } - - - return $value; - } - // }}} - -}; + } -/* - * Local variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ -?> + return $value; + } +} \ No newline at end of file diff --git a/htdocs/includes/printipp/ExtendedPrintIPP.php b/htdocs/includes/printipp/ExtendedPrintIPP.php index e736f4bd972..3effacb828f 100644 --- a/htdocs/includes/printipp/ExtendedPrintIPP.php +++ b/htdocs/includes/printipp/ExtendedPrintIPP.php @@ -1,5 +1,5 @@ document_uri = $uri; $this->setup->uri = 1; } - + if(!$this->_stringUri()) + { return FALSE; - + } + $this->output = $this->stringjob; - + $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output); - - - if (self::_sendHttp ($post_values,$this->paths['printers'])) { - - if(self::_parseServerOutput()) { + + if (self::_sendHttp ($post_values,$this->paths['printers'])) + { + if(self::_parseServerOutput()) + { $this->_parseJobAttributes(); $this->_getJobId(); //$this->_getPrinterUri(); $this->_getJobUri(); } } - + $this->attributes = &$this->job_attributes; - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf("printing uri %s, job %s: ",$uri,$this->last_job) .$this->serveroutput->status,3); - else { + } + else + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); self::_errorLog(sprintf("printing uri %s: ",$uri,$this->last_job) .$this->serveroutput->status,1); - } - return $this->serveroutput->status; } - + return $this->serveroutput->status; + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog("printing uri $uri : OPERATION FAILED",1); - - return false; - } - // }}} - // {{{ purgeJobs() - public function purgeJobs() { - + return false; + } + + + public function purgeJobs() + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - - if (!isset($this->setup->uri)) { + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("purgeJobs: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("purgeJobs: Printer URI is not set: die\n")); self::_errorLog("purgeJobs: Printer URI is not set, die",2); return FALSE; } } - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - + } + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x12) // purge-Jobs | operation-id . $this->meta->operation_id // request-id @@ -164,116 +169,141 @@ class ExtendedPrintIPP extends PrintIPP { . self::_giveMeStringLength(chr(0x01)) . chr(0x01) . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("purging jobs of %s\n"),$this->printer_uri)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - - if (self::_sendHttp ($post_values,$this->paths['admin'])) { + + if (self::_sendHttp ($post_values,$this->paths['admin'])) + { self::_parseServerOutput(); self::_parseAttributes(); } - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("purging jobs of %s: "),$this->printer_uri) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("purging jobs of %s: "),$this->printer_uri) .$this->serveroutput->status,1); - + } + return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("purging jobs of %s : OPERATION FAILED"), $this->printer_uri),3); - - return false; + + return false; } - // }}} - - // {{{ createJob() - public function createJob() { - - + public function createJob() + { self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - - if (!isset($this->setup->uri)) { + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("createJob: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("createJob: Printer URI is not set: die\n")); self::_errorLog("createJob: Printer URI is not set, die",2); return FALSE; } } - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - + } + if (!isset($this->setup->copies)) + { self::setCopies(1); + } if (!isset($this->meta->fidelity)) + { $this->meta->fidelity = ''; + } if (!isset($this->meta->sides)) + { $this->meta->sides = ''; - + } + if (!isset($this->meta->page_ranges)) + { $this->meta->page_ranges = ''; - + } + if (!isset($this->setup->jobname)) + { if (is_readable($this->data)) + { self::setJobName(basename($this->data),true); + } else + { self::setJobName(); + } + } unset($this->setup->jobname); if (!isset($this->timeout)) + { $this->timeout = 60; - + } + $timeout = self::_integerBuild($this->timeout); - $this->meta->timeout = chr(0x21) // integer . self::_giveMeStringLength("multiple-operation-time-out") . "multiple-operation-time-out" . self::_giveMeStringLength($timeout) . $timeout; - + $jobattributes = ''; $operationattributes = ''; $printerattributes = ''; self::_buildValues($operationattributes,$jobattributes,$printerattributes); - + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x05) // Create-Job | operation-id . $this->meta->operation_id // request-id @@ -292,40 +322,44 @@ class ExtendedPrintIPP extends PrintIPP { . $this->meta->page_ranges . $jobattributes . chr(0x03); // end-of-attributes | end-of-attributes-tag - + unset ($this->meta->copies,$this->meta->sides,$this->meta->page_ranges); self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("creating job %s, printer %s\n"),$this->last_job,$this->printer_uri)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - + if (self::_sendHttp ($post_values,$this->paths['printers'])) - if(self::_parseServerOutput()) { + { + if(self::_parseServerOutput()) + { $this->_getJobId(); $this->_getJobUri(); $this->_parseJobAttributes(); - } else { + } + else + { $this->jobs = array_merge($this->jobs,array('')); $this->jobs_uri = array_merge($this->jobs_uri,array('')); - } + } + } - - - - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("Create job: job %s"),$this->last_job) .$this->serveroutput->status,3); - else { + } + else + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); @@ -333,186 +367,207 @@ class ExtendedPrintIPP extends PrintIPP { } return $this->serveroutput->status; } - + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("Creating job on %s : OPERATION FAILED"), $this->printer_uri),3); - + $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); - return false; + return false; } - // }}} - - // {{{ sendDocument($job) - public function sendDocument($job,$is_last=false){ - + public function sendDocument($job,$is_last=false) + { self::_putDebug( sprintf("*************************\nDate: %s\n*************************\n\n",date('Y-m-d H:i:s'))); if (!$this->_stringDocument($job,$is_last)) + { return FALSE; - - if (is_readable($this->data)){ + } + + if (is_readable($this->data)) + { self::_putDebug( _("sending Document\n")); - + $this->output = $this->stringjob; - + if ($this->setup->datatype == "TEXT") - $this->output .= chr(0x16); // ASCII "SYN" - - + { + $this->output .= chr(0x16); + } // ASCII "SYN" + $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output, "File" => $this->data); - + if ($this->setup->datatype == "TEXT" && !isset($this->setup->noFormFeed)) + { $post_values = array_merge($post_values,array("Filetype"=>"TEXT")); - - } else { + } + } + else + { self::_putDebug( _("sending DATA as document\n")); - + $this->output = $this->stringjob; $this->output .= $this->datahead; $this->output .= $this->data; $this->output .= $this->datatail; - + $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output); - - - } - - if (self::_sendHttp ($post_values,$this->paths['printers'])) { - - if(self::_parseServerOutput()) { + } + + if (self::_sendHttp ($post_values,$this->paths['printers'])) + { + + if(self::_parseServerOutput()) + { $this->_getJobId(); //$this->_getPrinterUri(); $this->_getJobUri(); $this->_parseJobAttributes(); - } else { + } + else + { $this->jobs = array_merge($this->jobs,array($job)); $this->jobs_uri = array_merge($this->jobs_uri,array($job)); } - } - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf("sending document, job %s: %s",$job,$this->serveroutput->status),3); - else { + } + else + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); self::_errorLog(sprintf("sending document, job %s: %s",$job,$this->serveroutput->status),1); - } - return $this->serveroutput->status; - } + return $this->serveroutput->status; + } $this->status = array_merge($this->status,array("OPERATION FAILED")); $this->jobs = array_merge($this->jobs,array($job)); $this->jobs_uri = array_merge($this->jobs_uri,array($job)); self::_errorLog(sprintf("sending document, job %s : OPERATION FAILED",$job),1); - - return false; + + return false; } - // }}} - // {{{ sendURI ($uri,$job,$is_last=false) - public function sendURI ($uri,$job,$is_last=false){ + public function sendURI ($uri,$job,$is_last=false) + { self::_putDebug( sprintf("*************************\nDate: %s\n*************************\n\n",date('Y-m-d H:i:s'))); if (!$this->_stringSendUri($uri,$job,$is_last)) + { return FALSE; - + } + self::_putDebug( _("sending URI $uri\n")); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output); - - if (self::_sendHttp ($post_values,$this->paths['printers'])) { - - if(self::_parseServerOutput()) { + + if (self::_sendHttp ($post_values,$this->paths['printers'])) + { + if(self::_parseServerOutput()) + { $this->_getJobId(); //$this->_getPrinterUri(); $this->_getJobUri(); $this->_parseJobAttributes(); - } else { + } + else + { $this->jobs = array_merge($this->jobs,array($job)); $this->jobs_uri = array_merge($this->jobs_uri,array($job)); } - } - + $this->attributes = &$this->job_attributes; - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf("sending uri %s, job %s: %s",$uri,$job,$this->serveroutput->status),3); - else { + } + else + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); self::_errorLog(sprintf("sending uri, job %s: %s",$uri,$job,$this->serveroutput->status),1); - } - return $this->serveroutput->status; - } + return $this->serveroutput->status; + } $this->status = array_merge($this->status,array("OPERATION FAILED")); $this->jobs = array_merge($this->jobs,array($job)); $this->jobs_uri = array_merge($this->jobs_uri,array($job)); self::_errorLog(sprintf("sending uri %s, job %s : OPERATION FAILED",$uri,$job),1); - - return false; - } - // }}} - // {{{ pausePrinter () - public function pausePrinter() { - + return false; + } + + + public function pausePrinter() + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - - if (!isset($this->setup->uri)) { + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("pausePrinter: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("pausePrinter: Printer URI is not set: die\n")); self::_errorLog("pausePrinter: Printer URI is not set, die",2); return FALSE; - } } - + } + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - + } + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x10) // Pause-Printer | operation-id . $this->meta->operation_id // request-id @@ -527,81 +582,94 @@ class ExtendedPrintIPP extends PrintIPP { . self::_giveMeStringLength(chr(0x01)) . chr(0x01) */ . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("pause printer %s\n"),$this->printer_uri)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - - if (self::_sendHttp ($post_values,$this->paths['admin'])) { + + if (self::_sendHttp ($post_values,$this->paths['admin'])) + { self::_parseServerOutput(); self::_parseAttributes(); - } + } - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("Pause printer %s: "),$this->printer_uri) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("pause printer %s: "),$this->printer_uri) .$this->serveroutput->status,1); - + } + return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("pause printer %s : OPERATION FAILED"), $this->printer_uri),3); - - return false; - } - // }}} - // {{{ resumePrinter () - public function resumePrinter() { - + return false; + } + + + public function resumePrinter() + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - - if (!isset($this->setup->uri)) { + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("resumePrinter: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("resumePrinter: Printer URI is not set: die\n")); self::_errorLog(" Printer URI is not set, die",2); return FALSE; - } } - + } + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - + } + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x11) // suse-Printer | operation-id . $this->meta->operation_id // request-id @@ -611,82 +679,97 @@ class ExtendedPrintIPP extends PrintIPP { . $this->meta->printer_uri . $this->meta->username . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("resume printer %s\n"),$this->printer_uri)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - - if (self::_sendHttp ($post_values,$this->paths['admin'])) { + + if (self::_sendHttp ($post_values,$this->paths['admin'])) + { self::_parseServerOutput(); self::_parseAttributes(); - } + } - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("resume printer %s: "),$this->printer_uri) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("resume printer %s: "),$this->printer_uri) .$this->serveroutput->status,1); - + } + return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("resume printer %s : OPERATION FAILED"), $this->printer_uri),3); - - return false; - } - // }}} - // {{{ holdJob ($job_uri) - public function holdJob ($job_uri,$until='indefinite') { - + return false; + } + + + public function holdJob ($job_uri,$until='indefinite') + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array(trim($job_uri))); self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - + } + if (!isset($this->meta->message)) + { $this->meta->message = ''; + } self::_setJobUri($job_uri); $until_strings = array('no-hold','day-time','evening','night','weekend','second-shift','third-shift'); if (in_array($until,$until_strings)) + { true; + } else + { $until = 'indefinite'; + } $this->meta->job_hold_until = chr(0x42) // keyword . self::_giveMeStringLength('job-hold-until') . 'job-hold-until' . self::_giveMeStringLength($until) . $until; - + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x0C) // Hold-Job | operation-id . $this->meta->operation_id // request-id @@ -698,68 +781,81 @@ class ExtendedPrintIPP extends PrintIPP { . $this->meta->message . $this->meta->job_hold_until . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("hold job %s until %s\n"),$job_uri,$until)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - - if (self::_sendHttp ($post_values,$this->paths['jobs'])) { + + if (self::_sendHttp ($post_values,$this->paths['jobs'])) + { self::_parseServerOutput(); self::_parseAttributes(); } - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("hold job %s until %s: "),$job_uri,$until) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("hold job %s until %s: "),$job_uri,$until) .$this->serveroutput->status,1); - + } + return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("hold job %s until %s : OPERATION FAILED"), $job_uri,$until),3); - - return false; + + return false; } - // }}} - - // {{{ releaseJob ($job_uri) - public function releaseJob ($job_uri) { + + public function releaseJob ($job_uri) + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array(trim($job_uri))); self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - + } + if (!isset($this->meta->message)) + { $this->meta->message = ''; + } self::_setJobUri($job_uri); - + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x0D) // Hold-Job | operation-id . $this->meta->operation_id // request-id @@ -770,75 +866,85 @@ class ExtendedPrintIPP extends PrintIPP { . $this->meta->username . $this->meta->message . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("release job %s\n"),$job_uri)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - - if (self::_sendHttp ($post_values,$this->paths['jobs'])) { + + if (self::_sendHttp ($post_values,$this->paths['jobs'])) + { self::_parseServerOutput(); self::_parseAttributes(); - } - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + } + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("release job %s: "),$job_uri) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("release job %s: "),$job_uri) .$this->serveroutput->status,1); - + } + return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("release job %s: OPERATION FAILED"), $job_uri),3); - - return false; + + return false; } - // }}} - - // {{{ restartJob ($job_uri) - public function restartJob ($job_uri) { - + + + public function restartJob ($job_uri) + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array(trim($job_uri))); self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - + } + if (!isset($this->meta->message)) + { $this->meta->message = ''; + } self::_setJobUri($job_uri); - - + $jobattributes = ''; $operationattributes = ''; $printerattributes = ''; self::_buildValues ($operationattributes,$jobattributes,$printerattributes); - $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x0E) // Hold-Job | operation-id . $this->meta->operation_id // request-id @@ -850,92 +956,110 @@ class ExtendedPrintIPP extends PrintIPP { . $this->meta->message . $jobattributes // job-hold-until is set by setAttribute($attribute,$value) . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("release job %s\n"),$job_uri)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - - if (self::_sendHttp ($post_values,$this->paths['jobs'])) { + + if (self::_sendHttp ($post_values,$this->paths['jobs'])) + { self::_parseServerOutput(); self::_parseAttributes(); - } - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + } + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("release job %s: "),$job_uri) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("release job %s: "),$job_uri) .$this->serveroutput->status,1); - + } + return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("release job %s: OPERATION FAILED"), $job_uri),3); - - return false; + + return false; } - // }}} - - // {{{ setJobAttributes ($job_uri,$deleted_attributes=array()) - public function setJobAttributes ($job_uri,$deleted_attributes=array()) { - + + + public function setJobAttributes ($job_uri,$deleted_attributes=array()) + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array(trim($job_uri))); self::_setOperationId(); $this->parsed = array(); unset ($this->attributes); - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - - if (!isset($this->meta->message)) - $this->meta->message = ''; + } + + if (!isset($this->meta->message)) + { + $this->meta->message = ''; + } - if (!isset($this->meta->copies)) + { $this->meta->copies = ''; + } if (!isset($this->meta->sides)) + { $this->meta->sides = ''; - + } + if (!isset($this->meta->page_ranges)) + { $this->meta->page_ranges = ''; + } self::_setJobUri($job_uri); - + $operationattributes = ''; $jobattributes = ''; $printerattributes = ''; self::_buildValues ($operationattributes,$jobattributes,$printerattributes); - + $this->meta->deleted_attributes = ""; for ($i = 0 ; $i < count($deleted_attributes) ; $i++) - $this->meta->deleted_attributes .= chr(0x16) // out-of-band value - . self::_giveMeStringLength($deleted_attributes[$i]) - . $deleted_attributes[$i] - . chr(0x0).chr(0x0); // value-length = 0; - - + { + $this->meta->deleted_attributes .= chr(0x16) // out-of-band value + . self::_giveMeStringLength($deleted_attributes[$i]) + . $deleted_attributes[$i] + . chr(0x0).chr(0x0); + } // value-length = 0; + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x14) // Set-Job-Attributes | operation-id . $this->meta->operation_id // request-id @@ -952,47 +1076,52 @@ class ExtendedPrintIPP extends PrintIPP { . $this->meta->page_ranges . $this->meta->deleted_attributes . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("set job attributes for job %s\n"),$job_uri)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - - if (self::_sendHttp ($post_values,$this->paths['jobs'])) { + + if (self::_sendHttp ($post_values,$this->paths['jobs'])) + { self::_parseServerOutput(); self::_parseAttributes(); - } - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + } + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("set job attributes for job %s: "),$job_uri) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("set job attributes for job %s: "),$job_uri) .$this->serveroutput->status,1); + } $this->last_job = $job_uri; $this->jobs_uri[count($this->jobs_uri) - 1] = $job_uri; return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("set job attributes for job %s: OPERATION FAILED"), $job_uri),3); - - return false; + + return false; } - // }}} - - // {{{ setPrinterAttributes () - public function setPrinterAttributes ($document_format='',$deleted_attributes=array()) { + + + public function setPrinterAttributes ($document_format='',$deleted_attributes=array()) + { /* $document_format (RFC 3380) If the client includes this attribute, the Printer MUST change the supplied attributes for the document format specified by @@ -1010,55 +1139,72 @@ class ExtendedPrintIPP extends PrintIPP { supplied attributes for all document formats, whether or not they vary by document-format. */ - + $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); unset ($this->attributes); - + self::_setOperationId(); $this->parsed = array(); - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - + } + if (!isset($this->meta->message)) + { $this->meta->message = ''; - + } + if (!isset($this->meta->copies)) + { $this->meta->copies = ''; + } if (!isset($this->meta->sides)) + { $this->meta->sides = ''; - + } + if (!isset($this->meta->page_ranges)) + { $this->meta->page_ranges = ''; - + } + if ($document_format) + { $document_format = chr(0x49) // document-format tag - . self::_giveMeStringLength('document-format') - . 'document-format' // - . self::_giveMeStringLength($document_format) - . $document_format; // value + . self::_giveMeStringLength('document-format') + . 'document-format' // + . self::_giveMeStringLength($document_format) + . $document_format; + } // value $operationattributes = ''; $jobattributes = ''; $printerattributes = ''; self::_buildValues ($operationattributes,$jobattributes,$printerattributes); - + $this->meta->deleted_attributes = ""; for ($i = 0 ; $i < count($deleted_attributes) ; $i++) + { $this->meta->deleted_attributes .= chr(0x16) // out-of-band "deleted" value . self::_giveMeStringLength($deleted_attributes[$i]) . $deleted_attributes[$i] - . chr(0x0).chr(0x0); // value-length = 0; - - + . chr(0x0).chr(0x0); + } // value-length = 0; + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x13) // Set-Printer-Attributes | operation-id . $this->meta->operation_id // request-id @@ -1076,144 +1222,176 @@ class ExtendedPrintIPP extends PrintIPP { . $this->meta->page_ranges . $this->meta->deleted_attributes . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("set printer attributes for job %s\n"),$this->printer_uri)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - - if (self::_sendHttp ($post_values,$this->paths['printers'])) { + + if (self::_sendHttp ($post_values,$this->paths['printers'])) + { self::_parseServerOutput(); self::_parseAttributes(); - } - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + } + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("set printer attributes for printer %s: "),$this->printer_uri) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("set printer attributes for printer %s: "),$this->printer_uri) .$this->serveroutput->status,1); - + } + return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("set printer attributes for printer %s: OPERATION FAILED"), $this->printer_uri),1); - - return false; - + + return false; } - // }}} -// REQUEST BUILDING - - // {{{ _setDocumentUri ($job_uri) - protected function _setDocumentUri () { - + // REQUEST BUILDING + protected function _setDocumentUri () + { $this->meta->document_uri = chr(0x45) // type uri . chr(0x00).chr(0x0c) // name-length . "document-uri" . self::_giveMeStringLength($this->document_uri) . $this->document_uri; - + self::_putDebug( "document uri is: ".$this->document_uri."\n"); $this->setup->document_uri = 1; - } - // }}} - // {{{ _stringUri () - protected function _stringUri () { - + + protected function _stringUri () + { self::_setDocumentUri(); - - if (!isset($this->setup->document_uri)) { + + if (!isset($this->setup->document_uri)) + { trigger_error(_("_stringUri: Document URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringUri: Document URI is not set: die\n")); self::_errorLog("Document URI is not set, die",2); return FALSE; } unset ($this->setup->document_uri); - - if (!isset($this->setup->uri)) { + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("_stringUri: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringUri: Printer URI is not set: die\n")); self::_errorLog("_stringUri: Printer URI is not set, die",2); return FALSE; - } } + } if (!isset($this->setup->charset)) + { $this->meta->charset = ""; - // self::setCharset('us-ascii'); + } if (!isset($this->setup->datatype)) + { self::setBinary(); - if (!isset($this->setup->uri)) { + } + if (!isset($this->setup->uri)) + { trigger_error(_("_stringUri: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringUri: Printer URI is not set: die\n")); self::_errorLog("Printer URI is not set, die",2); return FALSE; - } + } if (!isset($this->setup->copies)) + { self::setCopies(1); - + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->setup->mime_media_type)) + { self::setMimeMediaType(); + } unset ($this->setup->mime_media_type); - + if (!isset($this->setup->jobname)) + { if (is_readable($this->data)) + { self::setJobName(basename($this->data),true); + } else + { self::setJobName(); + } + } unset($this->setup->jobname); if (!isset($this->meta->username)) + { self::setUserName(); + } if (!isset($this->meta->fidelity)) + { $this->meta->fidelity = ''; - + } + if (!isset($this->meta->document_name)) + { $this->meta->document_name = ''; + } if (!isset($this->meta->sides)) + { $this->meta->sides = ''; - + } + if (!isset($this->meta->page_ranges)) + { $this->meta->page_ranges = ''; - + } + $jobattributes = ''; $operationattributes = ''; $printerattributes = ''; self::_buildValues($operationattributes,$jobattributes,$printerattributes); - + self::_setOperationId(); - + if (!isset($this->error_generation->request_body_malformed)) + { $this->error_generation->request_body_malformed = ""; - + } + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x03) // Print-URI | operation-id . $this->meta->operation_id // request-id @@ -1234,72 +1412,98 @@ class ExtendedPrintIPP extends PrintIPP { . $this->meta->page_ranges . $jobattributes . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug( sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); return TRUE; } - // }}} - - // {{{ _stringDocument ($job,$is_last) - protected function _stringDocument ($job,$is_last) { - - if ($is_last == false) - $is_last = chr(0x00); - else - $is_last = chr(0x01); - - if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - if (!isset($this->setup->datatype)) - self::setBinary(); - if (!isset($this->setup->uri)) { + + protected function _stringDocument ($job,$is_last) + { + if ($is_last == false) + { + $is_last = chr(0x00); + } + else + { + $is_last = chr(0x01); + } + + if (!isset($this->setup->charset)) + { + self::setCharset(); + } + if (!isset($this->setup->datatype)) + { + self::setBinary(); + } + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("_stringJob: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringJob: Printer URI is not set: die\n")); self::_errorLog(" Printer URI is not set, die",2); return FALSE; } } - + if (!isset($this->setup->copies)) + { $this->meta->copies = ""; - + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->setup->mime_media_type)) + { $this->meta->mime_media_type = ""; + } if ($this->setup->datatype != "TEXT") + { unset ($this->setup->mime_media_type); - + } + if (!isset($this->meta->fidelity)) + { $this->meta->fidelity = ''; - + } + if (!isset($this->meta->document_name)) + { $this->meta->document_name = ''; + } if (!isset($this->meta->sides)) + { $this->meta->sides = ''; - + } + if (!isset($this->meta->page_ranges)) + { $this->meta->page_ranges = ''; - + } + $operationattributes = ''; $jobattributes = ''; $printerattributes = ''; self::_buildValues($operationattributes,$jobattributes,$printerattributes); - + self::_setOperationId(); - $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x06) // Send-Document | operation-id . $this->meta->operation_id // request-id @@ -1322,84 +1526,107 @@ class ExtendedPrintIPP extends PrintIPP { . self::_giveMeStringLength($is_last) . $is_last . chr(0x03); // end-of-attributes | end-of-attributes-tag - self::_putDebug( sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); return TRUE; } - // }}} - // {{{ _stringSendUri ($uri,$job,$is_last) - protected function _stringSendUri ($uri,$job,$is_last) { - + + protected function _stringSendUri ($uri,$job,$is_last) + { $this->document_uri = $uri; self::_setDocumentUri(); - - if (!isset($this->setup->document_uri)) { + + if (!isset($this->setup->document_uri)) + { trigger_error(_("_stringUri: Document URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringUri: Document URI is not set: die\n")); self::_errorLog("Document URI is not set, die",2); return FALSE; } unset ($this->setup->document_uri); - - - if ($is_last == false) - $is_last = chr(0x00); - else - $is_last = chr(0x01); - - if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - if (!isset($this->setup->datatype)) - self::setBinary(); - if (!isset($this->setup->uri)) { + if ($is_last == false) + { + $is_last = chr(0x00); + } + else + { + $is_last = chr(0x01); + } + + if (!isset($this->setup->charset)) + { + self::setCharset(); + } + if (!isset($this->setup->datatype)) + { + self::setBinary(); + } + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("_stringJob: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringJob: Printer URI is not set: die\n")); self::_errorLog(" Printer URI is not set, die",2); return FALSE; } } - + if (!isset($this->setup->copies)) + { $this->meta->copies = ""; - + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->setup->mime_media_type)) + { $this->meta->mime_media_type = ""; + } unset ($this->setup->mime_media_type); - + if (!isset($this->meta->fidelity)) + { $this->meta->fidelity = ''; - + } + if (!isset($this->meta->document_name)) + { $this->meta->document_name = ''; + } if (!isset($this->meta->sides)) + { $this->meta->sides = ''; - + } + if (!isset($this->meta->page_ranges)) + { $this->meta->page_ranges = ''; - + } + $operationattributes = ''; $jobattributes = ''; $printerattributes = ''; self::_buildValues($operationattributes,$jobattributes,$printerattributes); - + self::_setOperationId(); - $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x07) // Send-Uri | operation-id . $this->meta->operation_id // request-id @@ -1422,20 +1649,8 @@ class ExtendedPrintIPP extends PrintIPP { . self::_giveMeStringLength($is_last) . $is_last . chr(0x03); // end-of-attributes | end-of-attributes-tag - self::_putDebug( sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); return TRUE; } - // }}} - -}; - -/* - * Local variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ -?> +} \ No newline at end of file diff --git a/htdocs/includes/printipp/PrintIPP.php b/htdocs/includes/printipp/PrintIPP.php index 9ed502c2d11..ffda9e8f1f7 100644 --- a/htdocs/includes/printipp/PrintIPP.php +++ b/htdocs/includes/printipp/PrintIPP.php @@ -1,5 +1,5 @@ _stringJob()) + { return FALSE; - - if (is_readable($this->data)){ + } + + if (is_readable($this->data)) + { self::_putDebug( _("Printing a FILE\n"),3); - + $this->output = $this->stringjob; - + if ($this->setup->datatype == "TEXT") + { $this->output .= chr(0x16); - - + } + $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output, "File" => $this->data); - + if ($this->setup->datatype == "TEXT" && !isset($this->setup->noFormFeed)) + { $post_values = array_merge($post_values,array("Filetype"=>"TEXT")); - - } else { + } + } + else + { self::_putDebug( _("Printing DATA\n"),3); - + $this->output = $this->stringjob; $this->output .= $this->datahead; $this->output .= $this->data; @@ -99,25 +90,25 @@ class PrintIPP extends BasicIPP { $post_values = array( "Content-Type" => "application/ipp", "Data" => $this->output); - - - } - - if (self::_sendHttp ($post_values,$this->paths['printers'])) { - - if(self::_parseServerOutput()) { + } + + if (self::_sendHttp ($post_values,$this->paths['printers'])) + { + if(self::_parseServerOutput()) + { $this->_getJobId(); $this->_getJobUri(); $this->_parseJobAttributes(); - } else { + } + else + { $this->jobs = array_merge($this->jobs,array('')); $this->jobs_uri = array_merge($this->jobs_uri,array('')); } - } - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") @@ -131,138 +122,174 @@ class PrintIPP extends BasicIPP { self::_errorLog(sprintf("printing job: ",$this->last_job) .$this->serveroutput->status,1); if ($this->with_exceptions) { - throw new ippException(sprintf("job status: %s", + throw new ippException(sprintf("job status: %s", $this->serveroutput->status)); } } return $this->serveroutput->status; - - } + } $this->status = array_merge($this->status,array("OPERATION FAILED")); $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); self::_errorLog("printing job : OPERATION FAILED",1); - - return false; - } - // }}} - // {{{ cancelJob ($job_uri) - public function cancelJob ($job_uri) { - + return false; + } + + public function cancelJob ($job_uri) + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); - + self::_putDebug( sprintf("*************************\nDate: %s\n*************************\n\n",date('Y-m-d H:i:s'))); - + if (!$this->_stringCancel($job_uri)) - return FALSE; - + { + return FALSE; + } + self::_putDebug( _("Cancelling Job $job_uri\n"),3); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - + if (self::_sendHttp ($post_values,$this->paths['jobs'])) + { self::_parseServerOutput(); - - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + } + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog("cancelling job $job_uri: ".$this->serveroutput->status,3); - else - self::_errorLog("cancelling job $job_uri: ".$this->serveroutput->status,1); - return $this->serveroutput->status; - } + else + { + self::_errorLog("cancelling job $job_uri: ".$this->serveroutput->status,1); + } + return $this->serveroutput->status; + } - $this->status = array_merge($this->status,array("OPERATION FAILED")); - self::_errorLog("cancelling job : OPERATION FAILED",3); - - return false; + $this->status = array_merge($this->status,array("OPERATION FAILED")); + self::_errorLog("cancelling job : OPERATION FAILED",3); + + return false; } - // }}} - // {{{ validateJob () - public function validateJob () { - + public function validateJob () + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); - + $this->serveroutput->response = ''; self::_putDebug( sprintf("*************************\nDate: %s\n*************************\n\n",date('Y-m-d H:i:s'))); - - - self::_putDebug( _("Validate Job\n"),2); - - if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - if (!isset($this->setup->datatype)) - self::setBinary(); - if (!isset($this->setup->uri)) { + self::_putDebug( _("Validate Job\n"),2); + + if (!isset($this->setup->charset)) + { + self::setCharset(); + } + if (!isset($this->setup->datatype)) + { + self::setBinary(); + } + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("_stringJob: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringJob: Printer URI is not set: die\n"),3); self::_errorLog(" Printer URI is not set, die",2); return FALSE; } } - + if (!isset($this->meta->copies)) + { self::setCopies(1); + } + if (!isset($this->setup->copies)) + { self::setCopies(1); - + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->setup->mime_media_type)) + { self::setMimeMediaType(); + } + if ($this->setup->datatype != "TEXT") - unset ($this->setup->mime_media_type); - + { + unset ($this->setup->mime_media_type); + } + if (!isset($this->setup->jobname)) + { if (is_readable($this->data)) + { self::setJobName(basename($this->data),true); + } else + { self::setJobName(); + } + } unset($this->setup->jobname); if (!isset($this->meta->username)) + { self::setUserName(); + } if (!isset($this->meta->fidelity)) + { $this->meta->fidelity = ''; - + } + if (!isset($this->meta->document_name)) + { $this->meta->document_name = ''; + } if (!isset($this->meta->sides)) + { $this->meta->sides = ''; - + } + if (!isset($this->meta->page_ranges)) + { $this->meta->page_ranges = ''; - + } + $jobattributes = ''; $operationattributes = ''; $printerattributes = ''; self::_buildValues ($operationattributes,$jobattributes,$printerattributes); - + self::_setOperationId(); $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number @@ -284,43 +311,45 @@ class PrintIPP extends BasicIPP { . $this->meta->page_ranges . $jobattributes . chr(0x03); // end-of-attributes | end-of-attributes-tag - self::_putDebug( sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - + if (self::_sendHttp ($post_values,$this->paths['printers'])) - if(self::_parseServerOutput()) - self::_parseAttributes(); - - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + { + if(self::_parseServerOutput()) + { + self::_parseAttributes(); + } + } + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog("validate job: ".$this->serveroutput->status,3); - else - self::_errorLog("validate job: ".$this->serveroutput->status,1); - - return $this->serveroutput->status; - } + else + { + self::_errorLog("validate job: ".$this->serveroutput->status,1); + } + return $this->serveroutput->status; + } - $this->status = array_merge($this->status,array("OPERATION FAILED")); - self::_errorLog("validate job : OPERATION FAILED",3); - - return false; + $this->status = array_merge($this->status,array("OPERATION FAILED")); + self::_errorLog("validate job : OPERATION FAILED",3); + + return false; } - // }}} - // {{{ getPrinterAttributes() - public function getPrinterAttributes() { - + public function getPrinterAttributes() + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); @@ -330,32 +359,42 @@ class PrintIPP extends BasicIPP { self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - - if (!isset($this->setup->uri)) { + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("_stringJob: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringJob: Printer URI is not set: die\n"),3); self::_errorLog(" Printer URI is not set, die",2); return FALSE; } } - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); - + } + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x0b) // Print-URI | operation-id . $this->meta->operation_id // request-id @@ -366,109 +405,137 @@ class PrintIPP extends BasicIPP { . $this->meta->username . $printerattributes . chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("Getting printer attributes of %s\n"),$this->printer_uri),2); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - + if (self::_sendHttp ($post_values,$this->paths['root'])) + { if (self::_parseServerOutput()) + { self::_parsePrinterAttributes(); - + } + } + $this->attributes = &$this->printer_attributes; - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("getting printer attributes of %s: %s"),$this->printer_uri, $this->serveroutput->status),3); + } else + { self::_errorLog(sprintf(_("getting printer attributes of %s: %s"),$this->printer_uri, $this->serveroutput->status),1); - - return $this->serveroutput->status; } - $this->status = array_merge($this->status,array("OPERATION FAILED")); - self::_errorLog(date("Y-m-d H:i:s : ") - .basename($_SERVER['PHP_SELF']) - .sprintf(_("getting printer's attributes of %s : OPERATION FAILED"), - $this->printer_uri),3); - - return false; - } - // }}} + return $this->serveroutput->status; + } - // {{{ getJobs ($my_jobs=true,$limit=0,$which_jobs=""); - public function getJobs($my_jobs=true,$limit=0,$which_jobs="not-completed",$subset=false) { - + $this->status = array_merge($this->status,array("OPERATION FAILED")); + self::_errorLog(date("Y-m-d H:i:s : ") + .basename($_SERVER['PHP_SELF']) + .sprintf(_("getting printer's attributes of %s : OPERATION FAILED"), + $this->printer_uri),3); + + return false; + } + + public function getJobs($my_jobs=true,$limit=0,$which_jobs="not-completed",$subset=false) + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - - if (!isset($this->setup->uri)) { + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("getJobs: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringJob: Printer URI is not set: die\n"),3); self::_errorLog("getJobs: Printer URI is not set, die",2); return FALSE; } } - + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); + } - if ($limit) { + if ($limit) + { $limit = self::_integerBuild($limit); $this->meta->limit = chr(0x21) // integer . self::_giveMeStringLength('limit') . 'limit' . self::_giveMeStringLength($limit) . $limit; - } else + } + else + { $this->meta->limit = ''; - + } + if ($which_jobs == 'completed') + { $this->meta->which_jobs = chr(0x44) // keyword . self::_giveMeStringLength('which-jobs') . 'which-jobs' . self::_giveMeStringLength($which_jobs) . $which_jobs; + } else + { $this->meta->which_jobs = ""; + } if ($my_jobs) + { $this->meta->my_jobs = chr(0x22) // boolean . self::_giveMeStringLength('my-jobs') . 'my-jobs' . self::_giveMeStringLength(chr(0x01)) . chr(0x01); + } else + { $this->meta->my_jobs = ''; - + } + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x0A) // Get-Jobs | operation-id . $this->meta->operation_id // request-id @@ -479,9 +546,9 @@ class PrintIPP extends BasicIPP { . $this->meta->username . $this->meta->limit . $this->meta->which_jobs - . $this->meta->my_jobs - ; - if ($subset) { + . $this->meta->my_jobs; + if ($subset) + { $this->stringjob .= chr(0x44) // keyword . self::_giveMeStringLength('requested-attributes') @@ -502,106 +569,122 @@ class PrintIPP extends BasicIPP { . self::_giveMeStringLength('') . '' . self::_giveMeStringLength('job-state-reason') - . 'job-state-reason' - ; + . 'job-state-reason'; } - else { # cups 1.4.4 doesn't return much of anything without this + else + { # cups 1.4.4 doesn't return much of anything without this $this->stringjob .= chr(0x44) // keyword . self::_giveMeStringLength('requested-attributes') . 'requested-attributes' . self::_giveMeStringLength('all') - . 'all' - ; + . 'all'; } $this->stringjob .= chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("getting jobs of %s\n"),$this->printer_uri),2); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - + if (self::_sendHttp ($post_values,$this->paths['jobs'])) + { if (self::_parseServerOutput()) + { self::_parseJobsAttributes(); - + } + } + $this->attributes = &$this->jobs_attributes; - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("getting jobs of printer %s: "),$this->printer_uri) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("getting jobs of printer %s: "),$this->printer_uri) .$this->serveroutput->status,1); - + } + return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("getting jobs of %s : OPERATION FAILED"), $this->printer_uri),3); - + return false; } - // }}} - // {{{ getJobAttributes ($job_uri,subset="false",$attributes_group="all"); - public function getJobAttributes($job_uri,$subset=false,$attributes_group="all") { - + + public function getJobAttributes($job_uri,$subset=false,$attributes_group="all") + { $this->jobs = array_merge($this->jobs,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array("")); - - if (!$job_uri) { + + if (!$job_uri) + { trigger_error(_("getJobAttributes: Job URI is not set, die.")); return FALSE; } - + self::_setOperationId(); $this->parsed = array(); unset($this->printer_attributes); - - if (!isset($this->setup->uri)) { + + if (!isset($this->setup->uri)) + { $this->getPrinters(); unset($this->jobs[count($this->jobs) - 1]); unset($this->jobs_uri[count($this->jobs_uri) - 1]); unset($this->status[count($this->status) - 1]); - + if (array_key_exists(0,$this->available_printers)) + { self::setPrinterURI($this->available_printers[0]); - else { + } + else + { trigger_error(_("getJobs: Printer URI is not set: die"),E_USER_WARNING); self::_putDebug( _("_stringJob: Printer URI is not set: die\n"),3); self::_errorLog("getJobs: Printer URI is not set, die",2); return FALSE; - } } - + } + if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); - + { + self::setCharset(); + } + if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!isset($this->meta->username)) + { self::setUserName(); + } $this->meta->job_uri = chr(0x45) // URI . self::_giveMeStringLength('job-uri') . 'job-uri' . self::_giveMeStringLength($job_uri) . $job_uri; - + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x09) // Get-Job-Attributes | operation-id . $this->meta->operation_id // request-id @@ -609,10 +692,10 @@ class PrintIPP extends BasicIPP { . $this->meta->charset . $this->meta->language . $this->meta->job_uri - . $this->meta->username - ; - if ($subset) - $this->stringjob .= + . $this->meta->username; + if ($subset) + { + $this->stringjob .= chr(0x44) // keyword . self::_giveMeStringLength('requested-attributes') . 'requested-attributes' @@ -632,10 +715,12 @@ class PrintIPP extends BasicIPP { . self::_giveMeStringLength('') . '' . self::_giveMeStringLength('job-state-reason') - . 'job-state-reason' - ; - elseif($attributes_group) { - switch($attributes_group) { + . 'job-state-reason'; + } + elseif($attributes_group) + { + switch($attributes_group) + { case 'job-template': break; case 'job-description': @@ -646,127 +731,116 @@ class PrintIPP extends BasicIPP { trigger_error(_('not a valid attribute group: ').$attributes_group,E_USER_NOTICE); $attributes_group = ''; break; - } + } $this->stringjob .= chr(0x44) // keyword . self::_giveMeStringLength('requested-attributes') . 'requested-attributes' . self::_giveMeStringLength($attributes_group) . $attributes_group; - } + } $this->stringjob .= chr(0x03); // end-of-attributes | end-of-attributes-tag - + self::_putDebug(sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); - + self::_putDebug(sprintf(_("getting jobs of %s\n"),$this->printer_uri),2); - + $this->output = $this->stringjob; - + $post_values = array( "Content-Type"=>"application/ipp", "Data"=>$this->output); - + if (self::_sendHttp ($post_values,$this->paths['jobs'])) + { if (self::_parseServerOutput()) + { self::_parseJobAttributes(); - + } + } + $this->attributes = &$this->job_attributes; - - if (isset($this->serveroutput) && isset($this->serveroutput->status)) { - + + if (isset($this->serveroutput) && isset($this->serveroutput->status)) + { $this->status = array_merge($this->status,array($this->serveroutput->status)); - + if ($this->serveroutput->status == "successfull-ok") + { self::_errorLog(sprintf(_("getting job attributes for %s: "),$job_uri) .$this->serveroutput->status,3); + } else + { self::_errorLog(sprintf(_("getting job attributes for %s: "),$job_uri) .$this->serveroutput->status,1); - + } + return $this->serveroutput->status; - } - + } + $this->status = array_merge($this->status,array("OPERATION FAILED")); self::_errorLog(date("Y-m-d H:i:s : ") .basename($_SERVER['PHP_SELF']) .sprintf(_("getting jobs attributes of %s : OPERATION FAILED"), $job_uri),3); - - return false; + + return false; } - // }}} - - // {{{ getPrinters(); - public function getPrinters() { - + public function getPrinters() + { // placeholder for vendor extension operation (getAvailablePrinters for CUPS) $this->jobs = array_merge($this->jobs,array('')); $this->jobs_uri = array_merge($this->jobs_uri,array('')); $this->status = array_merge($this->status,array('')); } - // }}} -/****************** -* -* DEVELOPPEMENT FUNCTIONS -* -*******************/ - - // {{{ generateError($error) - public function generateError ($error) { - switch ($error) { + public function generateError ($error) + { + switch ($error) + { case "request_body_malformed": $this->error_generation->request_body_malformed = chr(0xFF); break; default: true; break; - } - // }}} + } - // {{{ resetError ($error) trigger_error(sprintf(_('Setting Error %s'),$error),E_USER_NOTICE); } - public function resetError ($error) { + public function resetError ($error) + { unset ($this->error_generation->$error); trigger_error(sprintf(_('Reset Error %s'),$error),E_USER_NOTICE); } - // }}} -/****************** -* -* PROTECTED FUNCTIONS -* -*******************/ - -// SETUP - - // {{{ _setOperationId () - protected function _setOperationId () { + // SETUP + protected function _setOperationId () + { $prepend = ''; $this->operation_id += 1; $this->meta->operation_id = self::_integerBuild($this->operation_id); self::_putDebug( "operation id is: ".$this->operation_id."\n",2); } - // }}} - // {{{ _setJobId() - protected function _setJobId() { + protected function _setJobId() + { $this->meta->jobid +=1; $prepend = ''; $prepend_length = 4 - strlen($this->meta->jobid); for ($i = 0; $i < $prepend_length ; $i++ ) + { $prepend .= '0'; + } return $prepend.$this->meta->jobid; } - // }}} - // {{{ _setJobUri ($job_uri) - protected function _setJobUri ($job_uri) { - + protected function _setJobUri ($job_uri) + { $this->meta->job_uri = chr(0x45) // type uri . chr(0x00).chr(0x07) // name-length . "job-uri" @@ -776,441 +850,490 @@ class PrintIPP extends BasicIPP { self::_putDebug( "job-uri is: ".$job_uri."\n",2); } - // }}} - -// RESPONSE PARSING - - // {{{ _parsePrinterAttributes() - protected function _parsePrinterAttributes() { + // RESPONSE PARSING + protected function _parsePrinterAttributes() + { //if (!preg_match('#successful#',$this->serveroutput->status)) // return false; $k = -1; + $l = 0; for ($i = 0 ; $i < count($this->serveroutput->response) ; $i++) + { for ($j = 0 ; $j < (count($this->serveroutput->response[$i]) - 1) ; $j ++) - if (!empty($this->serveroutput->response[$i][$j]['name'])) { + { + if (!empty($this->serveroutput->response[$i][$j]['name'])) + { $k++; $l = 0; $this->parsed[$k]['range'] = $this->serveroutput->response[$i]['attributes']; $this->parsed[$k]['name'] = $this->serveroutput->response[$i][$j]['name']; $this->parsed[$k]['type'] = $this->serveroutput->response[$i][$j]['type']; $this->parsed[$k][$l] = $this->serveroutput->response[$i][$j]['value']; - } else { + } + else + { $l ++; $this->parsed[$k][$l] = $this->serveroutput->response[$i][$j]['value']; } + } + } $this->serveroutput->response = array(); - - $this->printer_attributes = new stdClass(); - for ($i = 0 ; $i < count($this->parsed) ; $i ++) { + + $this->printer_attributes = new \stdClass(); + for ($i = 0 ; $i < count($this->parsed) ; $i ++) + { $name = $this->parsed[$i]['name']; $php_name = str_replace('-','_',$name); $type = $this->parsed[$i]['type']; $range = $this->parsed[$i]['range']; - $this->printer_attributes->$php_name = new stdClass(); + $this->printer_attributes->$php_name = new \stdClass(); $this->printer_attributes->$php_name->_type = $type; $this->printer_attributes->$php_name->_range = $range; - for ($j = 0 ; $j < (count($this->parsed[$i]) - 3) ; $j ++) { + for ($j = 0 ; $j < (count($this->parsed[$i]) - 3) ; $j ++) + { $value = $this->parsed[$i][$j]; $index = '_value'.$j; $this->printer_attributes->$php_name->$index = $value; } } - + $this->parsed = array(); - - } - // }}} - - // {{{ _parseJobsAttributes() - protected function _parseJobsAttributes() { + protected function _parseJobsAttributes() + { //if ($this->serveroutput->status != "successfull-ok") // return false; - + $job = -1; - for ($i = 0 ; $i < count($this->serveroutput->response) ; $i++) { + $l = 0; + for ($i = 0 ; $i < count($this->serveroutput->response) ; $i++) + { if ($this->serveroutput->response[$i]['attributes'] == "job-attributes") + { $job ++; + } $k = -1; for ($j = 0 ; $j < (count($this->serveroutput->response[$i]) - 1) ; $j ++) - if (!empty($this->serveroutput->response[$i][$j]['name'])) { + { + if (!empty($this->serveroutput->response[$i][$j]['name'])) + { $k++; $l = 0; $this->parsed[$job][$k]['range'] = $this->serveroutput->response[$i]['attributes']; $this->parsed[$job][$k]['name'] = $this->serveroutput->response[$i][$j]['name']; $this->parsed[$job][$k]['type'] = $this->serveroutput->response[$i][$j]['type']; $this->parsed[$job][$k][$l] = $this->serveroutput->response[$i][$j]['value']; - } else { + } + else + { $l ++; $this->parsed[$job][$k][$l] = $this->serveroutput->response[$i][$j]['value']; - } - } - - $this->serveroutput->response = array(); - $this->jobs_attributes = new stdClass(); - for ($job_nbr = 0 ; $job_nbr <= $job ; $job_nbr ++) { - $job_index = "job_".$job_nbr; - $this->jobs_attributes->$job_index = new stdClass(); - for ($i = 0 ; $i < count($this->parsed[$job_nbr]) ; $i ++) { - $name = $this->parsed[$job_nbr][$i]['name']; - $php_name = str_replace('-','_',$name); - $type = $this->parsed[$job_nbr][$i]['type']; - $range = $this->parsed[$job_nbr][$i]['range']; - $this->jobs_attributes->$job_index->$php_name = new stdClass(); - $this->jobs_attributes->$job_index->$php_name->_type = $type; - $this->jobs_attributes->$job_index->$php_name->_range = $range; - for ($j = 0 ; $j < (count($this->parsed[$job_nbr][$i]) - 3) ; $j ++) { - # This causes incorrect parsing of integer job attributes. - # 2010-08-16 - # bpkroth - #$value = self::_interpretAttribute($name,$type,$this->parsed[$job_nbr][$i][$j]); - $value = $this->parsed[$job_nbr][$i][$j]; - $index = '_value'.$j; - $this->jobs_attributes->$job_index->$php_name->$index = $value; - } - } - } - - $this->parsed = array(); - - - } - // }}} - - // {{{ _readAttribute($attributes_type,$ji,&$collection=false) - protected function _readAttribute($attributes_type) { - - $tag = ord($this->serveroutput->body[$this->_parsing->offset]); - - $this->_parsing->offset += 1; - $j = $this->index; - - $tag = self::_readTag($tag); - - switch ($tag) { - case "begCollection": //RFC3382 (BLIND CODE) - if ($this->end_collection) - $this->index --; - $this->end_collection = false; - $this->serveroutput->response[$attributes_type][$j]['type'] = "collection"; - self::_putDebug( "tag is: begCollection\n"); - self::_readAttributeName ($attributes_type,$j); - if (!$this->serveroutput->response[$attributes_type][$j]['name']) { // it is a multi-valued collection - $this->collection_depth ++; - $this->index --; - $this->collection_nbr[$this->collection_depth] ++; - } else { - $this->collection_depth ++; - if ($this->collection_depth == 0) - $this->collection = (object) 'collection'; - if (array_key_exists($this->collection_depth,$this->collection_nbr)) - $this->collection_nbr[$this->collection_depth] ++; - else - $this->collection_nbr[$this->collection_depth] = 0; - unset($this->end_collection); - - } - self::_readValue ("begCollection",$attributes_type,$j); - break; - case "endCollection": //RFC3382 (BLIND CODE) - $this->serveroutput->response[$attributes_type][$j]['type'] = "collection"; - self::_putDebug( "tag is: endCollection\n"); - self::_readAttributeName ($attributes_type,$j,0); - self::_readValue ('name',$attributes_type,$j,0); - $this->collection_depth --; - $this->collection_key[$this->collection_depth] = 0; - $this->end_collection = true; - break; - case "memberAttrName": // RFC3382 (BLIND CODE) - $this->serveroutput->response[$attributes_type][$j]['type'] = "memberAttrName"; - $this->index -- ; - self::_putDebug( "tag is: memberAttrName\n"); - self::_readCollection ($attributes_type,$j); - break; - - default: - $this->collection_depth = -1; - $this->collection_key = array(); - $this->collection_nbr = array(); - $this->serveroutput->response[$attributes_type][$j]['type'] = $tag; - self::_putDebug( "tag is: $tag\n"); - $attribute_name = self::_readAttributeName ($attributes_type,$j); - if (!$attribute_name) - $attribute_name = $this->attribute_name; - else - $this->attribute_name = $attribute_name; - $value = self::_readValue ($tag,$attributes_type,$j); - $this->serveroutput->response[$attributes_type][$j]['value'] = - self::_interpretAttribute($attribute_name,$tag,$this->serveroutput->response[$attributes_type][$j]['value']); - break; - - } - return; - } - // }}} - - // {{{ _readTag($tag) - protected function _readTag($tag) { - - switch ($tag) { - case 0x10: - $tag = "unsupported"; - break; - case 0x11: - $tag = "reserved for 'default'"; - break; - case 0x12: - $tag = "unknown"; - break; - case 0x13: - $tag = "no-value"; - break; - case 0x15: // RFC 3380 - $tag = "not-settable"; - break; - case 0x16: // RFC 3380 - $tag = "delete-attribute"; - break; - case 0x17: // RFC 3380 - $tag = "admin-define"; - break; - case 0x20: - $tag = "IETF reserved (generic integer)"; - break; - case 0x21: - $tag = "integer"; - break; - case 0x22: - $tag = "boolean"; - break; - case 0x23: - $tag = "enum"; - break; - case 0x30: - $tag = "octetString"; - break; - case 0x31: - $tag = "datetime"; - break; - case 0x32: - $tag = "resolution"; - break; - case 0x33: - $tag = "rangeOfInteger"; - break; - case 0x34: //RFC3382 (BLIND CODE) - $tag = "begCollection"; - break; - case 0x35: - $tag = "textWithLanguage"; - break; - case 0x36: - $tag = "nameWithLanguage"; - break; - case 0x37: //RFC3382 (BLIND CODE) - $tag = "endCollection"; - break; - case 0x40: - $tag = "IETF reserved text string"; - break; - case 0x41: - $tag = "textWithoutLanguage"; - break; - case 0x42: - $tag = "nameWithoutLanguage"; - break; - case 0x43: - $tag = "IETF reserved for future"; - break; - case 0x44: - $tag = "keyword"; - break; - case 0x45: - $tag = "uri"; - break; - case 0x46: - $tag = "uriScheme"; - break; - case 0x47: - $tag = "charset"; - break; - case 0x48: - $tag = "naturalLanguage"; - break; - case 0x49: - $tag = "mimeMediaType"; - break; - case 0x4A: // RFC3382 (BLIND CODE) - $tag = "memberAttrName"; - break; - case 0x7F: - $tag = "extended type"; - break; - default: - - if ($tag >= 0x14 && $tag < 0x15 && $tag > 0x17 && $tag <= 0x1f) - $tag = "out-of-band"; - elseif (0x24 <= $tag && $tag <= 0x2f) - $tag = "new integer type"; - elseif (0x38 <= $tag && $tag <= 0x3F) - $tag = "new octet-stream type"; - elseif (0x4B <= $tag && $tag <= 0x5F) - $tag = "new character string type"; - elseif ((0x60 <= $tag && $tag < 0x7f) || $tag >= 0x80 ) - $tag = "IETF reserved for future"; - else - $tag = sprintf("UNKNOWN: 0x%x (%u)",$tag,$tag); - - break; } - return $tag; - } - // }}} + } + } - // {{{ _readCollection($attributes_type,$j,&$collection) - protected function _readCollection($attributes_type,$j) { - + $this->serveroutput->response = array(); + $this->jobs_attributes = new \stdClass(); + for ($job_nbr = 0 ; $job_nbr <= $job ; $job_nbr ++) + { + $job_index = "job_".$job_nbr; + $this->jobs_attributes->$job_index = new \stdClass(); + for ($i = 0 ; $i < count($this->parsed[$job_nbr]) ; $i ++) + { + $name = $this->parsed[$job_nbr][$i]['name']; + $php_name = str_replace('-','_',$name); + $type = $this->parsed[$job_nbr][$i]['type']; + $range = $this->parsed[$job_nbr][$i]['range']; + $this->jobs_attributes->$job_index->$php_name = new \stdClass(); + $this->jobs_attributes->$job_index->$php_name->_type = $type; + $this->jobs_attributes->$job_index->$php_name->_range = $range; + for ($j = 0 ; $j < (count($this->parsed[$job_nbr][$i]) - 3) ; $j ++) + { + # This causes incorrect parsing of integer job attributes. + # 2010-08-16 + # bpkroth + #$value = self::_interpretAttribute($name,$type,$this->parsed[$job_nbr][$i][$j]); + $value = $this->parsed[$job_nbr][$i][$j]; + $index = '_value'.$j; + $this->jobs_attributes->$job_index->$php_name->$index = $value; + } + } + } + + $this->parsed = array(); + } + + protected function _readAttribute($attributes_type) + { + $tag = ord($this->serveroutput->body[$this->_parsing->offset]); + + $this->_parsing->offset += 1; + $j = $this->index; + + $tag = self::_readTag($tag); + + switch ($tag) + { + case "begCollection": //RFC3382 (BLIND CODE) + if ($this->end_collection) + { + $this->index --; + } + $this->end_collection = false; + $this->serveroutput->response[$attributes_type][$j]['type'] = "collection"; + self::_putDebug( "tag is: begCollection\n"); + self::_readAttributeName ($attributes_type,$j); + if (!$this->serveroutput->response[$attributes_type][$j]['name']) + { // it is a multi-valued collection + $this->collection_depth ++; + $this->index --; + $this->collection_nbr[$this->collection_depth] ++; + } + else + { + $this->collection_depth ++; + if ($this->collection_depth == 0) + { + $this->collection = (object) 'collection'; + } + if (array_key_exists($this->collection_depth,$this->collection_nbr)) + { + $this->collection_nbr[$this->collection_depth] ++; + } + else + { + $this->collection_nbr[$this->collection_depth] = 0; + } + unset($this->end_collection); + } + self::_readValue ("begCollection",$attributes_type,$j); + break; + case "endCollection": //RFC3382 (BLIND CODE) + $this->serveroutput->response[$attributes_type][$j]['type'] = "collection"; + self::_putDebug( "tag is: endCollection\n"); + self::_readAttributeName ($attributes_type,$j,0); + self::_readValue ('name',$attributes_type,$j,0); + $this->collection_depth --; + $this->collection_key[$this->collection_depth] = 0; + $this->end_collection = true; + break; + case "memberAttrName": // RFC3382 (BLIND CODE) + $this->serveroutput->response[$attributes_type][$j]['type'] = "memberAttrName"; + $this->index -- ; + self::_putDebug( "tag is: memberAttrName\n"); + self::_readCollection ($attributes_type,$j); + break; + + default: + $this->collection_depth = -1; + $this->collection_key = array(); + $this->collection_nbr = array(); + $this->serveroutput->response[$attributes_type][$j]['type'] = $tag; + self::_putDebug( "tag is: $tag\n"); + $attribute_name = self::_readAttributeName ($attributes_type,$j); + if (!$attribute_name) + { + $attribute_name = $this->attribute_name; + } + else + { + $this->attribute_name = $attribute_name; + } + $value = self::_readValue ($tag,$attributes_type,$j); + $this->serveroutput->response[$attributes_type][$j]['value'] = + self::_interpretAttribute($attribute_name,$tag,$this->serveroutput->response[$attributes_type][$j]['value']); + break; + } + return; + } + + protected function _readTag($tag) + { + switch ($tag) + { + case 0x10: + $tag = "unsupported"; + break; + case 0x11: + $tag = "reserved for 'default'"; + break; + case 0x12: + $tag = "unknown"; + break; + case 0x13: + $tag = "no-value"; + break; + case 0x15: // RFC 3380 + $tag = "not-settable"; + break; + case 0x16: // RFC 3380 + $tag = "delete-attribute"; + break; + case 0x17: // RFC 3380 + $tag = "admin-define"; + break; + case 0x20: + $tag = "IETF reserved (generic integer)"; + break; + case 0x21: + $tag = "integer"; + break; + case 0x22: + $tag = "boolean"; + break; + case 0x23: + $tag = "enum"; + break; + case 0x30: + $tag = "octetString"; + break; + case 0x31: + $tag = "datetime"; + break; + case 0x32: + $tag = "resolution"; + break; + case 0x33: + $tag = "rangeOfInteger"; + break; + case 0x34: //RFC3382 (BLIND CODE) + $tag = "begCollection"; + break; + case 0x35: + $tag = "textWithLanguage"; + break; + case 0x36: + $tag = "nameWithLanguage"; + break; + case 0x37: //RFC3382 (BLIND CODE) + $tag = "endCollection"; + break; + case 0x40: + $tag = "IETF reserved text string"; + break; + case 0x41: + $tag = "textWithoutLanguage"; + break; + case 0x42: + $tag = "nameWithoutLanguage"; + break; + case 0x43: + $tag = "IETF reserved for future"; + break; + case 0x44: + $tag = "keyword"; + break; + case 0x45: + $tag = "uri"; + break; + case 0x46: + $tag = "uriScheme"; + break; + case 0x47: + $tag = "charset"; + break; + case 0x48: + $tag = "naturalLanguage"; + break; + case 0x49: + $tag = "mimeMediaType"; + break; + case 0x4A: // RFC3382 (BLIND CODE) + $tag = "memberAttrName"; + break; + case 0x7F: + $tag = "extended type"; + break; + default: + if ($tag >= 0x14 && $tag < 0x15 && $tag > 0x17 && $tag <= 0x1f) + { + $tag = "out-of-band"; + } + elseif (0x24 <= $tag && $tag <= 0x2f) + { + $tag = "new integer type"; + } + elseif (0x38 <= $tag && $tag <= 0x3F) + { + $tag = "new octet-stream type"; + } + elseif (0x4B <= $tag && $tag <= 0x5F) + { + $tag = "new character string type"; + } + elseif ((0x60 <= $tag && $tag < 0x7f) || $tag >= 0x80 ) + { + $tag = "IETF reserved for future"; + } + else + { + $tag = sprintf("UNKNOWN: 0x%x (%u)",$tag,$tag); + } + break; + } + + return $tag; + } + + protected function _readCollection($attributes_type,$j) + { $name_length = ord($this->serveroutput->body[$this->_parsing->offset]) * 256 + ord($this->serveroutput->body[$this->_parsing->offset + 1]); - + $this->_parsing->offset += 2; - + self::_putDebug( "Collection name_length ". $name_length ."\n"); - + $name = ''; - for ($i = 0; $i < $name_length; $i++) { + for ($i = 0; $i < $name_length; $i++) + { $name .= $this->serveroutput->body[$this->_parsing->offset]; $this->_parsing->offset += 1; if ($this->_parsing->offset > strlen($this->serveroutput->body)) + { return; } - + } + $collection_name = $name; - + $name_length = ord($this->serveroutput->body[$this->_parsing->offset]) * 256 + ord($this->serveroutput->body[$this->_parsing->offset + 1]); $this->_parsing->offset += 2; - + self::_putDebug( "Attribute name_length ". $name_length ."\n"); - + $name = ''; - for ($i = 0; $i < $name_length; $i++) { + for ($i = 0; $i < $name_length; $i++) + { $name .= $this->serveroutput->body[$this->_parsing->offset]; $this->_parsing->offset += 1; if ($this->_parsing->offset > strlen($this->serveroutput->body)) + { return; } - + } + $attribute_name = $name; - if ($attribute_name == "") { + if ($attribute_name == "") + { $attribute_name = $this->last_attribute_name; $this->collection_key[$this->collection_depth] ++; - } else { + } + else + { $this->collection_key[$this->collection_depth] = 0; } $this->last_attribute_name = $attribute_name; - + self::_putDebug( "Attribute name ".$name."\n"); - + $tag = self::_readTag(ord($this->serveroutput->body[$this->_parsing->offset])); $this->_parsing->offset ++; - + $type = $tag; - + $name_length = ord($this->serveroutput->body[$this->_parsing->offset]) * 256 + ord($this->serveroutput->body[$this->_parsing->offset + 1]); $this->_parsing->offset += 2; - + self::_putDebug( "Collection2 name_length ". $name_length ."\n"); - + $name = ''; - for ($i = 0; $i < $name_length; $i++) { + for ($i = 0; $i < $name_length; $i++) + { $name .= $this->serveroutput->body[$this->_parsing->offset]; $this->_parsing->offset += 1; if ($this->_parsing->offset > strlen($this->serveroutput->body)) + { return; } - + } + $collection_value = $name; $value_length = ord($this->serveroutput->body[$this->_parsing->offset]) * 256 + ord($this->serveroutput->body[$this->_parsing->offset + 1]); - + self::_putDebug( "Collection value_length ".$this->serveroutput->body[ $this->_parsing->offset] . $this->serveroutput->body[$this->_parsing->offset + 1] .": " . $value_length . " "); - + $this->_parsing->offset += 2; - + $value = ''; - for ($i = 0; $i < $value_length; $i++) { - + for ($i = 0; $i < $value_length; $i++) + { if ($this->_parsing->offset >= strlen($this->serveroutput->body)) + { return; + } $value .= $this->serveroutput->body[$this->_parsing->offset]; $this->_parsing->offset += 1; - - } - + } + $object = &$this->collection; - for ($i = 0 ; $i <= $this->collection_depth ; $i ++) { + for ($i = 0 ; $i <= $this->collection_depth ; $i ++) + { $indice = "_indice".$this->collection_nbr[$i]; if (!isset($object->$indice)) + { $object->$indice = (object) 'indice'; - $object = &$object->$indice; } - + $object = &$object->$indice; + } + $value_key = "_value".$this->collection_key[$this->collection_depth]; $col_name_key = "_collection_name".$this->collection_key[$this->collection_depth]; $col_val_key = "_collection_value".$this->collection_key[$this->collection_depth]; - + $attribute_value = self::_interpretAttribute($attribute_name,$tag,$value); $attribute_name = str_replace('-','_',$attribute_name); - - + self::_putDebug( sprintf("Value: %s\n",$value)); $object->$attribute_name->_type = $type; $object->$attribute_name->$value_key = $attribute_value; $object->$attribute_name->$col_name_key = $collection_name; $object->$attribute_name->$col_val_key = $collection_value; - - $this->serveroutput->response[$attributes_type][$j]['value'] = $this->collection; - } - // }}} - - // {{{ _readAttributeName ($attributes_type,$j) - protected function _readAttributeName ($attributes_type,$j,$write=1) { + $this->serveroutput->response[$attributes_type][$j]['value'] = $this->collection; + } + + protected function _readAttributeName ($attributes_type,$j,$write=1) + { $name_length = ord($this->serveroutput->body[ $this->_parsing->offset]) * 256 + ord($this->serveroutput->body[$this->_parsing->offset + 1]); $this->_parsing->offset += 2; - + self::_putDebug( "name_length ". $name_length ."\n"); - + $name = ''; - for ($i = 0; $i < $name_length; $i++) { + for ($i = 0; $i < $name_length; $i++) + { if ($this->_parsing->offset >= strlen($this->serveroutput->body)) + { return; + } $name .= $this->serveroutput->body[$this->_parsing->offset]; $this->_parsing->offset += 1; - } - + } + if($write) - $this->serveroutput->response[$attributes_type][$j]['name'] = $name; + { + $this->serveroutput->response[$attributes_type][$j]['name'] = $name; + } self::_putDebug( "name " . $name . "\n"); - - return $name; + + return $name; } - // }}} - - // {{{ _readValue ($type,$attributes_type,$j) - protected function _readValue ($type,$attributes_type,$j,$write=1) { + protected function _readValue ($type,$attributes_type,$j,$write=1) + { $value_length = ord($this->serveroutput->body[$this->_parsing->offset]) * 256 + ord($this->serveroutput->body[$this->_parsing->offset + 1]); @@ -1219,116 +1342,130 @@ class PrintIPP extends BasicIPP { .": " . $value_length . " "); - + $this->_parsing->offset += 2; - + $value = ''; - for ($i = 0; $i < $value_length; $i++) { - + for ($i = 0; $i < $value_length; $i++) + { if ($this->_parsing->offset >= strlen($this->serveroutput->body)) + { return; + } $value .= $this->serveroutput->body[$this->_parsing->offset]; $this->_parsing->offset += 1; - } - + self::_putDebug( sprintf("Value: %s\n",$value)); - + if ($write) - $this->serveroutput->response[$attributes_type][$j]['value'] = $value; + { + $this->serveroutput->response[$attributes_type][$j]['value'] = $value; + } - return $value; + return $value; } - // }}} - // {{{ _parseAttributes() - protected function _parseAttributes() { - + protected function _parseAttributes() + { $k = -1; + $l = 0; for ($i = 0 ; $i < count($this->serveroutput->response) ; $i++) + { for ($j = 0 ; $j < (count($this->serveroutput->response[$i]) - 1) ; $j ++) - if (!empty($this->serveroutput->response[$i][$j]['name'])) { + { + if (!empty($this->serveroutput->response[$i][$j]['name'])) + { $k++; $l = 0; $this->parsed[$k]['range'] = $this->serveroutput->response[$i]['attributes']; $this->parsed[$k]['name'] = $this->serveroutput->response[$i][$j]['name']; $this->parsed[$k]['type'] = $this->serveroutput->response[$i][$j]['type']; $this->parsed[$k][$l] = $this->serveroutput->response[$i][$j]['value']; - } else { + } + else + { $l ++; $this->parsed[$k][$l] = $this->serveroutput->response[$i][$j]['value']; - } + } + } + } $this->serveroutput->response = array(); - $this->attributes = new stdClass(); - for ($i = 0 ; $i < count($this->parsed) ; $i ++) { + $this->attributes = new \stdClass(); + for ($i = 0 ; $i < count($this->parsed) ; $i ++) + { $name = $this->parsed[$i]['name']; $php_name = str_replace('-','_',$name); $type = $this->parsed[$i]['type']; $range = $this->parsed[$i]['range']; - $this->attributes->$php_name = new stdClass(); + $this->attributes->$php_name = new \stdClass(); $this->attributes->$php_name->_type = $type; $this->attributes->$php_name->_range = $range; - for ($j = 0 ; $j < (count($this->parsed[$i]) - 3) ; $j ++) { + for ($j = 0 ; $j < (count($this->parsed[$i]) - 3) ; $j ++) + { $value = $this->parsed[$i][$j]; $index = '_value'.$j; $this->attributes->$php_name->$index = $value; } } - + $this->parsed = array(); - } - // }}} - - // {{{ _parseJobAttributes() - protected function _parseJobAttributes() { + protected function _parseJobAttributes() + { //if (!preg_match('#successful#',$this->serveroutput->status)) // return false; - $k = -1; + $l = 0; for ($i = 0 ; $i < count($this->serveroutput->response) ; $i++) + { for ($j = 0 ; $j < (count($this->serveroutput->response[$i]) - 1) ; $j ++) - if (!empty($this->serveroutput->response[$i][$j]['name'])) { + { + if (!empty($this->serveroutput->response[$i][$j]['name'])) + { $k++; $l = 0; $this->parsed[$k]['range'] = $this->serveroutput->response[$i]['attributes']; $this->parsed[$k]['name'] = $this->serveroutput->response[$i][$j]['name']; $this->parsed[$k]['type'] = $this->serveroutput->response[$i][$j]['type']; $this->parsed[$k][$l] = $this->serveroutput->response[$i][$j]['value']; - } else { + } + else + { $l ++; $this->parsed[$k][$l] = $this->serveroutput->response[$i][$j]['value']; - } - + } + } + } + $this->serveroutput->response = array(); - - $this->job_attributes = new stdClass(); - for ($i = 0 ; $i < count($this->parsed) ; $i ++) { + + $this->job_attributes = new \stdClass(); + for ($i = 0 ; $i < count($this->parsed) ; $i ++) + { $name = $this->parsed[$i]['name']; $php_name = str_replace('-','_',$name); $type = $this->parsed[$i]['type']; $range = $this->parsed[$i]['range']; - $this->job_attributes->$php_name = new stdClass(); + $this->job_attributes->$php_name = new \stdClass(); $this->job_attributes->$php_name->_type = $type; $this->job_attributes->$php_name->_range = $range; - for ($j = 0 ; $j < (count($this->parsed[$i]) - 3) ; $j ++) { + for ($j = 0 ; $j < (count($this->parsed[$i]) - 3) ; $j ++) + { $value = $this->parsed[$i][$j]; $index = '_value'.$j; $this->job_attributes->$php_name->$index = $value; } } - - $this->parsed = array(); - - - } - // }}} - // {{{ _interpretAttribute($attribute_name,$type,$value) - protected function _interpretAttribute($attribute_name,$type,$value) { - - switch ($type) { + $this->parsed = array(); + } + + protected function _interpretAttribute($attribute_name,$type,$value) + { + switch ($type) + { case "integer": $value = self::_interpretInteger($value); break; @@ -1338,9 +1475,13 @@ class PrintIPP extends BasicIPP { case 'boolean': $value = ord($value); if ($value == 0x00) + { $value = 'false'; + } else + { $value = 'true'; + } break; case 'datetime': $value = self::_interpretDateTime($value); @@ -1351,7 +1492,8 @@ class PrintIPP extends BasicIPP { case 'resolution': $unit = $value[8]; $value = self::_interpretRangeOfInteger(substr($value,0,8)); - switch($unit) { + switch($unit) + { case chr(0x03): $unit = "dpi"; break; @@ -1363,31 +1505,27 @@ class PrintIPP extends BasicIPP { break; default: break; - } - return $value; + } + return $value; } - // }}} - - // {{{ _interpretRangeOfInteger($value) - protected function _interpretRangeOfInteger($value) { - + + protected function _interpretRangeOfInteger($value) + { $value_parsed = 0; $integer1 = $integer2 = 0; - + $halfsize = strlen($value) / 2; - + $integer1 = self::_interpretInteger(substr($value,0,$halfsize)); $integer2 = self::_interpretInteger(substr($value,$halfsize,$halfsize)); - + $value_parsed = sprintf('%s-%s',$integer1,$integer2); - - - return $value_parsed; + + return $value_parsed; } - // }}} - - // {{{ _interpretDateTime($date) { - protected function _interpretDateTime($date) { + + protected function _interpretDateTime($date) + { $year = self::_interpretInteger(substr($date,0,2)); $month = self::_interpretInteger(substr($date,2,1)); $day = self::_interpretInteger(substr($date,3,1)); @@ -1397,21 +1535,21 @@ class PrintIPP extends BasicIPP { $direction = substr($date,8,1); $hours_from_utc = self::_interpretInteger(substr($date,9,1)); $minutes_from_utc = self::_interpretInteger(substr($date,10,1)); - + $date = sprintf('%s-%s-%s %s:%s:%s %s%s:%s',$year,$month,$day,$hour,$minute,$second,$direction,$hours_from_utc,$minutes_from_utc); - return $date; - } - // }}} - - // {{{ _interpretEnum() - protected function _interpretEnum($attribute_name,$value) { - + return $date; + } + + protected function _interpretEnum($attribute_name,$value) + { $value_parsed = self::_interpretInteger($value); - - switch ($attribute_name) { + + switch ($attribute_name) + { case 'job-state': - switch ($value_parsed) { + switch ($value_parsed) + { case 0x03: $value = 'pending'; break; @@ -1433,14 +1571,17 @@ class PrintIPP extends BasicIPP { case 0x09: $value = 'completed'; break; - } + } if ($value_parsed > 0x09) + { $value = sprintf('Unknown(IETF standards track "job-state" reserved): 0x%x',$value_parsed); + } break; case 'print-quality': case 'print-quality-supported': case 'print-quality-default': - switch ($value_parsed) { + switch ($value_parsed) + { case 0x03: $value = 'draft'; break; @@ -1453,7 +1594,8 @@ class PrintIPP extends BasicIPP { } break; case 'printer-state': - switch ($value_parsed) { + switch ($value_parsed) + { case 0x03: $value = 'idle'; break; @@ -1463,13 +1605,16 @@ class PrintIPP extends BasicIPP { case 0x05: $value = 'stopped'; break; - } + } if ($value_parsed > 0x05) + { $value = sprintf('Unknown(IETF standards track "printer-state" reserved): 0x%x',$value_parsed); + } break; - + case 'operations-supported': - switch($value_parsed) { + switch($value_parsed) + { case 0x0000: case 0x0001: $value = sprintf('Unknown(reserved) : %s',ord($value)); @@ -1602,20 +1747,31 @@ class PrintIPP extends BasicIPP { break; } if ($value_parsed > 0x002B && $value_parsed <= 0x3FFF) + { $value = sprintf('Unknown(IETF standards track operations reserved): 0x%x',$value_parsed); - elseif ($value_parsed >= 0x4000 && $value_parsed <= 0x8FFF) { - if (method_exists($this,'_getEnumVendorExtensions')) { + } + elseif ($value_parsed >= 0x4000 && $value_parsed <= 0x8FFF) + { + if (method_exists($this,'_getEnumVendorExtensions')) + { $value = $this->_getEnumVendorExtensions($value_parsed); - } else + } + else + { $value = sprintf('Unknown(Vendor extension for operations): 0x%x',$value_parsed); - } elseif ($value_parsed > 0x8FFF) + } + } + elseif ($value_parsed > 0x8FFF) + { $value = sprintf('Unknown operation (should not exists): 0x%x',$value_parsed); - + } + break; case 'finishings': case 'finishings-default': case 'finishings-supported': - switch ($value_parsed) { + switch ($value_parsed) + { case 3: $value = 'none'; break; @@ -1673,15 +1829,18 @@ class PrintIPP extends BasicIPP { case 31: $value = 'staple-dual-bottom'; break; - } + } if ($value_parsed > 31) + { $value = sprintf('Unknown(IETF standards track "finishing" reserved): 0x%x',$value_parsed); + } break; - + case 'orientation-requested': case 'orientation-requested-supported': case 'orientation-requested-default': - switch ($value_parsed) { + switch ($value_parsed) + { case 0x03: $value = 'portrait'; break; @@ -1694,77 +1853,87 @@ class PrintIPP extends BasicIPP { case 0x06: $value = 'reverse-portrait'; break; - } + } if ($value_parsed > 0x06) + { $value = sprintf('Unknown(IETF standards track "orientation" reserved): 0x%x',$value_parsed); + } break; - + default: break; - } - return $value; + } + return $value; } - // }}} - - // {{{ _getJobId () - protected function _getJobId () { - + + protected function _getJobId () + { if (!isset($this->serveroutput->response)) + { $this->jobs = array_merge($this->jobs,array('NO JOB')); - + } + $jobfinded = false; for ($i = 0 ; (!$jobfinded && array_key_exists($i,$this->serveroutput->response)) ; $i ++) + { if (($this->serveroutput->response[$i]['attributes']) == "job-attributes") + { for ($j = 0 ; array_key_exists($j,$this->serveroutput->response[$i]) ; $j++) - if ($this->serveroutput->response[$i][$j]['name'] == "job-id") { + { + if ($this->serveroutput->response[$i][$j]['name'] == "job-id") + { $this->last_job = $this->serveroutput->response[$i][$j]['value']; $this->jobs = array_merge($this->jobs,array($this->serveroutput->response[$i][$j]['value'])); return; - - } - + } + } + } + } } - // }}} - - // {{{ _getJobUri () - protected function _getJobUri () { + protected function _getJobUri () + { if (!isset($this->jobs_uri)) + { $this->jobs_uri = array(); - + } + $jobfinded = false; for ($i = 0 ; (!$jobfinded && array_key_exists($i,$this->serveroutput->response)) ; $i ++) + { if (($this->serveroutput->response[$i]['attributes']) == "job-attributes") + { for ($j = 0 ; array_key_exists($j,$this->serveroutput->response[$i]) ; $j++) - if ($this->serveroutput->response[$i][$j]['name'] == "job-uri") { + { + if ($this->serveroutput->response[$i][$j]['name'] == "job-uri") + { $this->last_job = $this->serveroutput->response[$i][$j]['value']; $this->jobs_uri = array_merge($this->jobs_uri,array($this->last_job)); return; - - } + } + } + } + } $this->last_job = ''; - } - // }}} - - // {{{ _parseResponse () - protected function _parseResponse () { + + protected function _parseResponse () + { $j = -1; $this->index = 0; - for ($i = $this->_parsing->offset; $i < strlen($this->serveroutput->body) ; $i = $this->_parsing->offset) { - - + for ($i = $this->_parsing->offset; $i < strlen($this->serveroutput->body) ; $i = $this->_parsing->offset) + { $tag = ord($this->serveroutput->body[$this->_parsing->offset]); - - - if ($tag > 0x0F) { - + + if ($tag > 0x0F) + { self::_readAttribute($j); $this->index ++; continue; - } + } - switch ($tag) { + switch ($tag) + { case 0x01: $j += 1; $this->serveroutput->response[$j]['attributes'] = "operation-attributes"; @@ -1782,7 +1951,9 @@ class PrintIPP extends BasicIPP { $this->serveroutput->response[$j]['attributes'] = "end-of-attributes"; self::_putDebug( "tag is: ".$this->serveroutput->response[$j]['attributes']."\n"); if ($this->alert_on_end_tag === 1) + { echo "END tag OK
"; + } $this->response_completed[(count($this->response_completed) -1)] = "completed"; return; case 0x04: @@ -1803,21 +1974,16 @@ class PrintIPP extends BasicIPP { $this->index = 0; $this->_parsing->offset += 1; break; - } - - self::_putDebug( "tag is: ".$this->serveroutput->response[$j]['attributes']."\n\n\n"); - - } - return; + } + + self::_putDebug( "tag is: ".$this->serveroutput->response[$j]['attributes']."\n\n\n"); + } + return; } - // }}} - - - /* // NOTICE : HAVE TO READ AGAIN RFC 2911 TO SEE IF IT IS PART OF SERVER'S RESPONSE (CUPS DO NOT) - // {{{ _getPrinterUri () + protected function _getPrinterUri () { for ($i = 0 ; (array_key_exists($i,$this->serveroutput->response)) ; $i ++) @@ -1833,32 +1999,43 @@ class PrintIPP extends BasicIPP { $this->printers_uri = array_merge($this->printers_uri,array('')); } - // }}} + */ -// REQUEST BUILDING - - // {{{ _stringCancel () - protected function _stringCancel ($job_uri) { + // REQUEST BUILDING + protected function _stringCancel ($job_uri) + { if (!isset($this->setup->charset)) - self::setCharset('us-ascii'); + { + self::setCharset(); + } if (!isset($this->setup->datatype)) + { self::setBinary(); + } if (!isset($this->setup->language)) + { self::setLanguage('en_us'); + } if (!$this->requesting_user) + { self::setUserName(); + } if (!isset($this->meta->message)) + { $this->meta->message = ''; + } self::_setOperationId(); - + self::_setJobUri($job_uri); - + if (!isset($this->error_generation->request_body_malformed)) + { $this->error_generation->request_body_malformed = ""; - + } + $this->stringjob = chr(0x01) . chr(0x01) // 1.1 | version-number . chr(0x00) . chr (0x08) // cancel-Job | operation-id . $this->meta->operation_id // request-id @@ -1874,16 +2051,4 @@ class PrintIPP extends BasicIPP { self::_putDebug( sprintf(_("String sent to the server is:\n%s\n"), $this->stringjob)); return TRUE; } - // }}} - - -}; - -/* - * Local variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ -?> +} diff --git a/htdocs/includes/printipp/http_class.php b/htdocs/includes/printipp/http_class.php index 569d4f6648f..30bb33d663b 100644 --- a/htdocs/includes/printipp/http_class.php +++ b/htdocs/includes/printipp/http_class.php @@ -29,7 +29,7 @@ */ /** * This class is intended to implement a subset of Hyper Text Transfer Protocol - * (HTTP/1.1) on client side  (currently: POST operation), with file streaming + * (HTTP/1.1) on client side (currently: POST operation), with file streaming * capability. * * It can perform Basic and Digest authentication. @@ -66,48 +66,58 @@ ************************/ class httpException extends Exception { - protected $errno; - public function __construct ($msg, $errno = null) - { - parent::__construct ($msg); - $this->errno = $errno; - } - public function getErrorFormatted () - { - return sprintf ("[http_class]: %s -- "._(" file %s, line %s"), - $this->getMessage (), $this->getFile (), $this->getLine ()); - } - public function getErrno () - { - return $this->errno; - } + protected $errno; + + public function __construct ($msg, $errno = null) + { + parent::__construct ($msg); + $this->errno = $errno; + } + + public function getErrorFormatted () + { + return sprintf ("[http_class]: %s -- "._(" file %s, line %s"), + $this->getMessage (), $this->getFile (), $this->getLine ()); + } + + public function getErrno () + { + return $this->errno; + } } function error2string($value) { - $level_names = array( - E_ERROR => 'E_ERROR', - E_WARNING => 'E_WARNING', - E_PARSE => 'E_PARSE', - E_NOTICE => 'E_NOTICE', - E_CORE_ERROR => 'E_CORE_ERROR', - E_CORE_WARNING => 'E_CORE_WARNING', - E_COMPILE_ERROR => 'E_COMPILE_ERROR', - E_COMPILE_WARNING => 'E_COMPILE_WARNING', - E_USER_ERROR => 'E_USER_ERROR', - E_USER_WARNING => 'E_USER_WARNING', - E_USER_NOTICE => 'E_USER_NOTICE' - ); - if(defined('E_STRICT')) $level_names[E_STRICT]='E_STRICT'; - $levels=array(); - if(($value&E_ALL)==E_ALL) - { - $levels[]='E_ALL'; - $value&=~E_ALL; - } - foreach($level_names as $level=>$name) - if(($value&$level)==$level) $levels[]=$name; - return implode(' | ',$levels); + $level_names = array( + E_ERROR => 'E_ERROR', + E_WARNING => 'E_WARNING', + E_PARSE => 'E_PARSE', + E_NOTICE => 'E_NOTICE', + E_CORE_ERROR => 'E_CORE_ERROR', + E_CORE_WARNING => 'E_CORE_WARNING', + E_COMPILE_ERROR => 'E_COMPILE_ERROR', + E_COMPILE_WARNING => 'E_COMPILE_WARNING', + E_USER_ERROR => 'E_USER_ERROR', + E_USER_WARNING => 'E_USER_WARNING', + E_USER_NOTICE => 'E_USER_NOTICE' + ); + if(defined('E_STRICT')) { + $level_names[E_STRICT]='E_STRICT'; + } + $levels=array(); + if(($value&E_ALL)==E_ALL) + { + $levels[]='E_ALL'; + $value&=~E_ALL; + } + foreach($level_names as $level=>$name) + { + if(($value&$level)==$level) + { + $levels[]=$name; + } + } + return implode(' | ',$levels); } /*********************** @@ -117,499 +127,486 @@ function error2string($value) ************************/ class http_class { - // variables declaration - public $debug; - public $html_debug; - public $timeout = 30; // time waiting for connection, seconds - public $data_timeout = 30; // time waiting for data, milliseconds - public $data_chunk_timeout = 1; // time waiting between data chunks, millisecond - public $force_multipart_form_post; - public $username; - public $password; - public $request_headers = array (); - public $request_body = "Not a useful information"; - public $status; - public $window_size = 1024; // chunk size of data - public $with_exceptions = 0; // compatibility mode for old scripts - public $port; - public $host; - private $default_port = 631; - private $headers; - private $reply_headers = array (); - private $reply_body = array (); - private $connection; - private $arguments; - private $bodystream = array (); - private $last_limit; - private $connected; - private $nc = 1; - private $user_agent = "PRINTIPP/0.81+CVS"; - private $readed_bytes = 0; + // variables declaration + public $debug; + public $html_debug; + public $timeout = 30; // time waiting for connection, seconds + public $data_timeout = 30; // time waiting for data, milliseconds + public $data_chunk_timeout = 1; // time waiting between data chunks, millisecond + public $force_multipart_form_post; + public $username; + public $password; + public $request_headers = array (); + public $request_body = "Not a useful information"; + public $status; + public $window_size = 1024; // chunk size of data + public $with_exceptions = 0; // compatibility mode for old scripts + public $port; + public $host; + private $default_port = 631; + private $headers; + private $reply_headers = array (); + private $reply_body = array (); + private $connection; + private $arguments; + private $bodystream = array (); + private $last_limit; + private $connected; + private $nc = 1; + private $user_agent = "PRINTIPP/0.81+CVS"; + private $readed_bytes = 0; - public function __construct () - { - true; - } - - /********************* - * - * Public functions - * - **********************/ - - public function GetRequestArguments ($url, &$arguments) - { - $this->arguments = array (); - $arguments["URL"] = $this->arguments["URL"] = $url; - $arguments["RequestMethod"] = $this->arguments["RequestMethod"] = "POST"; - $this->headers["Content-Length"] = 0; - $this->headers["Content-Type"] = "application/octet-stream"; - $this->headers["Host"] = $this->host; - $this->headers["User-Agent"] = $this->user_agent; - //$this->headers["Expect"] = "100-continue"; - - } - - public function Open ($arguments) - { - $this->connected = false; - $url = $arguments["URL"]; - $port = $this->default_port; - #$url = split (':', $url, 2); - $url = preg_split ('#:#', $url, 2); - $transport_type = $url[0]; - $unix = false; - switch ($transport_type) - { - case 'http': - $transport_type = 'tcp://'; - break; - - case 'https': - $transport_type = 'tls://'; - break; - - case 'unix': - $transport_type = 'unix://'; - $port = 0; - $unix = true; - break; - - default: - $transport_type = 'tcp://'; - break; - } - $url = $url[1]; - if (!$unix) - { - #$url = split ("/", preg_replace ("#^/{1,}#", '', $url), 2); - $url = preg_split ("#/#", preg_replace ("#^/{1,}#", '', $url), 2); - $url = $url[0]; - $port = $this->port; - $error = sprintf (_("Cannot resolve url: %s"), $url); - $ip = gethostbyname ($url); - $ip = @gethostbyaddr ($ip); - if (!$ip) - { - return $this->_HttpError ($error, E_USER_WARNING); - } - if (strstr ($url, ":")) // we got an ipv6 address - if (!strstr ($url, "[")) // it is not escaped - $url = sprintf ("[%s]", $url); - } - $this->connection = @fsockopen ($transport_type.$url, $port, $errno, $errstr, $this->timeout); - $error = - sprintf (_('Unable to connect to "%s%s port %s": %s'), $transport_type, - $url, $port, $errstr); - if (!$this->connection) - { - return $this->_HttpError ($error, E_USER_WARNING); - } - $this->connected = true; - return array (true, "success"); - } - - public function SendRequest ($arguments) - { - $error = - sprintf (_('Streaming request failed to %s'), $arguments['RequestURI']); - $result = self::_StreamRequest ($arguments); - if (!$result[0]) - { - return $this->_HttpError ($error." ".$result[1], E_USER_WARNING); - } - self::_ReadReply (); - if (!preg_match ('#http/1.1 401 unauthorized#', $this->status)) - { - return array (true, "success"); - } - $headers = array_keys ($this->reply_headers); - $error = _("need authentication but no mechanism provided"); - if (!in_array ("www-authenticate", $headers)) - { - return $this->_HttpError ($error, E_USER_WARNING); - } - #$authtype = split (' ', $this->reply_headers["www-authenticate"]); - $authtype = preg_split ('# #', $this->reply_headers["www-authenticate"]); - $authtype = strtolower ($authtype[0]); - switch ($authtype) - { - case 'basic': - $pass = base64_encode ($this->user.":".$this->password); - $arguments["Headers"]["Authorization"] = "Basic ".$pass; - break; - - case 'digest': - $arguments["Headers"]["Authorization"] = self::_BuildDigest (); - break; - - default: - $error = - sprintf (_("need '%s' authentication mechanism, but have not"), - $authtype[0]); - return $this->_HttpError ($error, E_USER_WARNING); - break; - - } - self::Close (); - self::Open ($arguments); - $error = - sprintf (_ - ('Streaming request failed to %s after a try to authenticate'), - $url); - $result = self::_StreamRequest ($arguments); - if (!$result[0]) - { - return $this->_HttpError ($error.": ".$result[1], E_USER_WARNING); - } - self::_ReadReply (); - return array (true, "success"); - } - - public function ReadReplyHeaders (&$headers) - { - $headers = $this->reply_headers; - } - - public function ReadReplyBody (&$body, $chunk_size) - { - $body = substr ($this->reply_body, $this->last_limit, $chunk_size); - $this->last_limit += $chunk_size; - } - - public function Close () - { - if (!$this->connected) - return; - fclose ($this->connection); - } - - /********************* - * - * Private functions - * - *********************/ - - private function _HttpError ($msg, $level, $errno = null) - { - $trace = ''; - $backtrace = debug_backtrace; - foreach ($backtrace as $trace) - { - $trace .= sprintf ("in [file: '%s'][function: '%s'][line: %s];\n", $trace['file'], $trace['function'],$trace['line']); - } - $msg = sprintf ( '%s\n%s: [errno: %s]: %s', - $trace, error2string ($level), $errno, $msg); - if ($this->with_exceptions) - { - throw new httpException ($msg, $errno); - } - else - { - trigger_error ($msg, $level); - return array (false, $msg); - } - } - - private function _streamString ($string) - { - $success = fwrite ($this->connection, $string); - if (!$success) - { - return false; - } - return true; - } - - private function _StreamRequest ($arguments) - { - $this->status = false; - $this->reply_headers = array (); - $this->reply_body = ""; - if (!$this->connected) - { - return _HttpError (_("not connected"), E_USER_WARNING); - } - $this->arguments = $arguments; - $content_length = 0; - foreach ($this->arguments["BodyStream"] as $argument) - { - list ($type, $value) = each ($argument); - reset ($argument); - if ($type == "Data") - { - $length = strlen ($value); - } - elseif ($type == "File") - { - if (is_readable ($value)) + public function __construct () { - $length = filesize ($value); + true; } - else + + /********************* + * + * Public functions + * + **********************/ + + public function GetRequestArguments ($url, &$arguments) { - $length = 0; - return - _HttpError (sprintf (_("%s: file is not readable"), $value), - E_USER_WARNING); + $this->arguments = array (); + $this->arguments["URL"] = $arguments["URL"] = $url; + $this->arguments["RequestMethod"] = $arguments["RequestMethod"] = "POST"; + $this->headers["Content-Length"] = 0; + $this->headers["Content-Type"] = "application/octet-stream"; + $this->headers["Host"] = $this->host; + $this->headers["User-Agent"] = $this->user_agent; + //$this->headers["Expect"] = "100-continue"; } - } - else - { - $length = 0; - return - _HttpError (sprintf - (_("%s: not a valid argument for content"), $type), - E_USER_WARNING); - } - $content_length += $length; - } - $this->request_body = sprintf (_("%s Bytes"), $content_length); - $this->headers["Content-Length"] = $content_length; - $this->arguments["Headers"] = - array_merge ($this->headers, $this->arguments["Headers"]); - if ($this->arguments["RequestMethod"] != "POST") - { - return - _HttpError (sprintf - (_("%s: method not implemented"), - $arguments["RequestMethod"]), E_USER_WARNING); - } - $string = - sprintf ("POST %s HTTP/1.1\r\n", $this->arguments["RequestURI"]); - $this->request_headers[$string] = ''; - if (!$this->_streamString ($string)) - { - return _HttpError (_("Error while puts POST operation"), - E_USER_WARNING); - } - foreach ($this->arguments["Headers"] as $header => $value) - { - $string = sprintf ("%s: %s\r\n", $header, $value); - $this->request_headers[$header] = $value; - if (!$this->_streamString ($string)) - { - return _HttpError (_("Error while puts HTTP headers"), - E_USER_WARNING); - } - } - $string = "\r\n"; - if (!$this->_streamString ($string)) - { - return _HttpError (_("Error while ends HTTP headers"), - E_USER_WARNING); - } - foreach ($this->arguments["BodyStream"] as $argument) - { - list ($type, $value) = each ($argument); - reset ($argument); - if ($type == "Data") - { - $streamed_length = 0; - while ($streamed_length < strlen ($value)) + + public function Open ($arguments) { - $string = substr ($value, $streamed_length, $this->window_size); - if (!$this->_streamString ($string)) - { - return _HttpError (_("error while sending body data"), - E_USER_WARNING); - } - $streamed_length += $this->window_size; + $this->connected = false; + $url = $arguments["URL"]; + $port = $this->default_port; + #$url = split (':', $url, 2); + $url = preg_split ('#:#', $url, 2); + $transport_type = $url[0]; + $unix = false; + switch ($transport_type) + { + case 'http': + $transport_type = 'tcp://'; + break; + + case 'https': + $transport_type = 'tls://'; + break; + + case 'unix': + $transport_type = 'unix://'; + $port = 0; + $unix = true; + break; + + default: + $transport_type = 'tcp://'; + break; + } + $url = $url[1]; + if (!$unix) + { + #$url = split ("/", preg_replace ("#^/{1,}#", '', $url), 2); + $url = preg_split ("#/#", preg_replace ("#^/{1,}#", '', $url), 2); + $url = $url[0]; + $port = $this->port; + $error = sprintf (_("Cannot resolve url: %s"), $url); + $ip = gethostbyname ($url); + $ip = @gethostbyaddr ($ip); + if (!$ip) + { + return $this->_HttpError ($error, E_USER_WARNING); + } + if (strstr ($url, ":")) // we got an ipv6 address + { + if (!strstr ($url, "[")) // it is not escaped + { + $url = sprintf ("[%s]", $url); + } + } + } + $this->connection = @fsockopen ($transport_type.$url, $port, $errno, $errstr, $this->timeout); + $error = + sprintf (_('Unable to connect to "%s%s port %s": %s'), $transport_type, + $url, $port, $errstr); + if (!$this->connection) + { + return $this->_HttpError ($error, E_USER_WARNING); + } + $this->connected = true; + return array (true, "success"); } - } - elseif ($type == "File") - { - if (is_readable ($value)) + + public function SendRequest ($arguments) { - $file = fopen ($value, 'rb'); - while (!feof ($file)) - { - if (gettype ($block = @fread ($file, $this->window_size)) != - "string") - { - return _HttpError (_("cannot read file to upload"), - E_USER_WARNING); - } - if (!$this->_streamString ($block)) - { - return _HttpError (_("error while sending body data"), - E_USER_WARNING); - } - } + $error = + sprintf (_('Streaming request failed to %s'), $arguments['RequestURI']); + $result = self::_StreamRequest ($arguments); + if (!$result[0]) + { + return $this->_HttpError ($error." ".$result[1], E_USER_WARNING); + } + self::_ReadReply (); + if (!preg_match ('#http/1.1 401 unauthorized#', $this->status)) + { + return array (true, "success"); + } + $headers = array_keys ($this->reply_headers); + $error = _("need authentication but no mechanism provided"); + if (!in_array ("www-authenticate", $headers)) + { + return $this->_HttpError ($error, E_USER_WARNING); + } + #$authtype = split (' ', $this->reply_headers["www-authenticate"]); + $authtype = preg_split ('# #', $this->reply_headers["www-authenticate"]); + $authtype = strtolower ($authtype[0]); + switch ($authtype) + { + case 'basic': + $pass = base64_encode ($this->user.":".$this->password); + $arguments["Headers"]["Authorization"] = "Basic ".$pass; + break; + + case 'digest': + $arguments["Headers"]["Authorization"] = self::_BuildDigest (); + break; + + default: + $error = + sprintf (_("need '%s' authentication mechanism, but have not"), + $authtype[0]); + return $this->_HttpError ($error, E_USER_WARNING); + break; + } + self::Close (); + self::Open ($arguments); + + $error = sprintf(_('Streaming request failed to %s after a try to authenticate'), $arguments['RequestURI']); + $result = self::_StreamRequest ($arguments); + if (!$result[0]) + { + return $this->_HttpError ($error.": ".$result[1], E_USER_WARNING); + } + self::_ReadReply (); + return array (true, "success"); } - } - } - return array (true, "success"); - } - private function _ReadReply () - { - if (!$this->connected) - { - return array (false, _("not connected")); - } - $this->reply_headers = array (); - $this->reply_body = ""; - $headers = array (); - $body = ""; - while (!feof ($this->connection)) - { - $line = fgets ($this->connection, 1024); - if (strlen (trim($line)) == 0) - break; // \r\n => end of headers - if (preg_match ('#^[[:space:]]#', $line)) - { - $headers[-1] .= sprintf(' %s', trim ($line)); - continue; - } - $headers[] = trim ($line); - } - $this->status = isset ($headers[0]) ? strtolower ($headers[0]) : false; - foreach ($headers as $header) - { - $header = preg_split ("#: #", $header); - $header[0] = strtolower ($header[0]); - if ($header[0] !== "www-authenticate") - { - $header[1] = isset ($header[1]) ? strtolower ($header[1]) : ""; - } - if (!isset ($this->reply_headers[$header[0]])) - { - $this->reply_headers[$header[0]] = $header[1]; - } - } - self::_ReadStream (); - return true; - } + public function ReadReplyHeaders (&$headers) + { + $headers = $this->reply_headers; + } - private function _ReadStream () - { - if (! array_key_exists ("content-length", $this->reply_headers)) - { - stream_set_blocking($this->connection, 0); - $this->reply_body = stream_get_contents($this->connection); - return true; - } - stream_set_blocking($this->connection, 1); - $content_length = $this->reply_headers["content-length"]; - $this->reply_body = stream_get_contents($this->connection,$content_length); - return true; - } + public function ReadReplyBody (&$body, $chunk_size) + { + $body = substr ($this->reply_body, $this->last_limit, $chunk_size); + $this->last_limit += $chunk_size; + } - private function _BuildDigest () - { - $auth = $this->reply_headers["www-authenticate"]; - #list ($head, $auth) = split (" ", $auth, 2); - list ($head, $auth) = preg_split ("# #", $auth, 2); - #$auth = split (", ", $auth); - $auth = preg_split ("#, #", $auth); - foreach ($auth as $sheme) - { - #list ($sheme, $value) = split ('=', $sheme); - list ($sheme, $value) = preg_split ('#=#', $sheme); - $fields[$sheme] = trim (trim ($value), '"'); - } - $nc = sprintf ('%x', $this->nc); - $prepend = ""; - while ((strlen ($nc) + strlen ($prepend)) < 8) - $prependi .= "0"; - $nc = $prepend.$nc; - $cnonce = "printipp"; - $username = $this->user; - $password = $this->password; - $A1 = $username.":".$fields["realm"].":".$password; - if (array_key_exists ("algorithm", $fields)) - { - $algorithm = strtolower ($fields["algorithm"]); - switch ($algorithm) - { - case "md5": - break; + public function Close () + { + if (!$this->connected) + { + return; + } + fclose ($this->connection); + } - case "md5-sess": - $A1 = - $username.":".$fields["realm"].":".$password.":". - $fields['nonce'].":".$cnonce; - break; + /********************* + * + * Private functions + * + *********************/ - default: - return _HttpError( - sprintf (_("digest Authorization: algorithm '%s' not implemented"), - $algorithm), - E_USER_WARNING); - return false; - break; - } - } - $A2 = "POST:".$this->arguments["RequestURI"]; - if (array_key_exists ("qop", $fields)) - { - $qop = strtolower ($fields["qop"]); - #$qop = split (" ", $qop); - $qop = preg_split ("# #", $qop); - if (in_array ("auth", $qop)) - $qop = "auth"; - else - { - self::_HttpError( - sprintf (_("digest Authorization: algorithm '%s' not implemented"), - $qop), - E_USER_WARNING); - return false; - } - } - $response = md5 (md5 ($A1).":".$fields["nonce"].":".md5 ($A2)); - if (isset ($qop) && ($qop == "auth")) - { - $response = - md5 (md5 ($A1).":".$fields["nonce"].":".$nc.":".$cnonce.":".$qop. - ":".$A2); - } - $auth_scheme = - sprintf - ('Digest username="%s", realm="%s", nonce="%s", uri="%s", response="%s"', - $username, $fields["realm"], $fields['nonce'], - $this->arguments["RequestURI"], $response); - if (isset ($algorithm)) - $auth_scheme .= sprintf (', algorithm="%s"', $algorithm); - if (isset ($qop)) - $auth_scheme .= sprintf (', cnonce="%s"', $cnonce); - if (array_key_exists ("opaque", $fields)) - $auth_scheme .= sprintf (', opaque="%s"', $fields['opaque']); - if (isset ($qop)) - $auth_scheme .= sprintf (', qop="%s"', $qop); - $auth_scheme .= sprintf (', nc=%s', $nc); - $this->nc++; - return $auth_scheme; - } + private function _HttpError ($msg, $level, $errno = null) + { + $trace = ''; + $backtrace = debug_backtrace(); + foreach ($backtrace as $trace) + { + $trace .= sprintf ("in [file: '%s'][function: '%s'][line: %s];\n", $trace['file'], $trace['function'],$trace['line']); + } + $msg = sprintf ( '%s\n%s: [errno: %s]: %s', + $trace, error2string ($level), $errno, $msg); + if ($this->with_exceptions) + { + throw new httpException ($msg, $errno); + } + else + { + trigger_error ($msg, $level); + return array (false, $msg); + } + } -}; + private function _streamString ($string) + { + $success = fwrite ($this->connection, $string); + if (!$success) + { + return false; + } + return true; + } -/* - * Local variables: - * mode: php - * tab-width: 2 - * c-basic-offset: 2 - * End: - */ -?> + private function _StreamRequest ($arguments) + { + $this->status = false; + $this->reply_headers = array (); + $this->reply_body = ""; + if (!$this->connected) + { + return $this->_HttpError (_("not connected"), E_USER_WARNING); + } + $this->arguments = $arguments; + $content_length = 0; + foreach ($this->arguments["BodyStream"] as $argument) + { + list ($type, $value) = each ($argument); + reset ($argument); + if ($type == "Data") + { + $length = strlen ($value); + } + elseif ($type == "File") + { + if (is_readable ($value)) + { + $length = filesize ($value); + } + else + { + $length = 0; + return $this->_HttpError (sprintf (_("%s: file is not readable"), $value), E_USER_WARNING); + } + } + else + { + $length = 0; + return $this->_HttpError (sprintf(_("%s: not a valid argument for content"), $type), E_USER_WARNING); + } + $content_length += $length; + } + $this->request_body = sprintf (_("%s Bytes"), $content_length); + $this->headers["Content-Length"] = $content_length; + $this->arguments["Headers"] = array_merge ($this->headers, $this->arguments["Headers"]); + if ($this->arguments["RequestMethod"] != "POST") + { + return $this->_HttpError (sprintf(_("%s: method not implemented"), $arguments["RequestMethod"]), E_USER_WARNING); + } + $string = sprintf ("POST %s HTTP/1.1\r\n", $this->arguments["RequestURI"]); + $this->request_headers[$string] = ''; + if (!$this->_streamString ($string)) + { + return $this->_HttpError (_("Error while puts POST operation"), E_USER_WARNING); + } + foreach ($this->arguments["Headers"] as $header => $value) + { + $string = sprintf ("%s: %s\r\n", $header, $value); + $this->request_headers[$header] = $value; + if (!$this->_streamString ($string)) + { + return $this->_HttpError (_("Error while puts HTTP headers"), E_USER_WARNING); + } + } + $string = "\r\n"; + if (!$this->_streamString ($string)) + { + return $this->_HttpError (_("Error while ends HTTP headers"), E_USER_WARNING); + } + foreach ($this->arguments["BodyStream"] as $argument) + { + list ($type, $value) = each ($argument); + reset ($argument); + if ($type == "Data") + { + $streamed_length = 0; + while ($streamed_length < strlen ($value)) + { + $string = substr ($value, $streamed_length, $this->window_size); + if (!$this->_streamString ($string)) + { + return $this->_HttpError (_("error while sending body data"), E_USER_WARNING); + } + $streamed_length += $this->window_size; + } + } + elseif ($type == "File") + { + if (is_readable ($value)) + { + $file = fopen ($value, 'rb'); + while (!feof ($file)) + { + if (gettype ($block = @fread ($file, $this->window_size)) != "string") + { + return $this->_HttpError (_("cannot read file to upload"), E_USER_WARNING); + } + if (!$this->_streamString ($block)) + { + return $this->_HttpError (_("error while sending body data"), E_USER_WARNING); + } + } + } + } + } + return array (true, "success"); + } + + private function _ReadReply () + { + if (!$this->connected) + { + return array (false, _("not connected")); + } + $this->reply_headers = array (); + $this->reply_body = ""; + $headers = array (); + $body = ""; + while (!feof ($this->connection)) + { + $line = fgets ($this->connection, 1024); + if (strlen (trim($line)) == 0) + { + break; + } // \r\n => end of headers + if (preg_match ('#^[[:space:]]#', $line)) + { + $headers[-1] .= sprintf(' %s', trim ($line)); + continue; + } + $headers[] = trim ($line); + } + $this->status = isset ($headers[0]) ? strtolower ($headers[0]) : false; + foreach ($headers as $header) + { + $header = preg_split ("#: #", $header); + $header[0] = strtolower ($header[0]); + if ($header[0] !== "www-authenticate") + { + $header[1] = isset ($header[1]) ? strtolower ($header[1]) : ""; + } + if (!isset ($this->reply_headers[$header[0]])) + { + $this->reply_headers[$header[0]] = $header[1]; + } + } + self::_ReadStream (); + return true; + } + + private function _ReadStream () + { + if (! array_key_exists ("content-length", $this->reply_headers)) + { + stream_set_blocking($this->connection, 0); + $this->reply_body = stream_get_contents($this->connection); + return true; + } + stream_set_blocking($this->connection, 1); + $content_length = $this->reply_headers["content-length"]; + $this->reply_body = stream_get_contents($this->connection,$content_length); + return true; + } + + private function _BuildDigest () + { + $auth = $this->reply_headers["www-authenticate"]; + #list ($head, $auth) = split (" ", $auth, 2); + list ($head, $auth) = preg_split ("# #", $auth, 2); + #$auth = split (", ", $auth); + $auth = preg_split ("#, #", $auth); + foreach ($auth as $sheme) + { + #list ($sheme, $value) = split ('=', $sheme); + list ($sheme, $value) = preg_split ('#=#', $sheme); + $fields[$sheme] = trim (trim ($value), '"'); + } + $nc = sprintf ('%x', $this->nc); + $prepend = ""; + while ((strlen ($nc) + strlen ($prepend)) < 8) + $prependi .= "0"; + $nc = $prepend.$nc; + $cnonce = "printipp"; + $username = $this->user; + $password = $this->password; + $A1 = $username.":".$fields["realm"].":".$password; + if (array_key_exists ("algorithm", $fields)) + { + $algorithm = strtolower ($fields["algorithm"]); + switch ($algorithm) + { + case "md5": + break; + + case "md5-sess": + $A1 = + $username.":".$fields["realm"].":".$password.":". + $fields['nonce'].":".$cnonce; + break; + + default: + return $this->_HttpError( + sprintf (_("digest Authorization: algorithm '%s' not implemented"), + $algorithm), + E_USER_WARNING); + return false; + break; + } + } + $A2 = "POST:".$this->arguments["RequestURI"]; + if (array_key_exists ("qop", $fields)) + { + $qop = strtolower ($fields["qop"]); + #$qop = split (" ", $qop); + $qop = preg_split ("# #", $qop); + if (in_array ("auth", $qop)) + { + $qop = "auth"; + } + else + { + self::_HttpError( + sprintf (_("digest Authorization: algorithm '%s' not implemented"), + $qop), + E_USER_WARNING); + return false; + } + } + $response = md5 (md5 ($A1).":".$fields["nonce"].":".md5 ($A2)); + if (isset ($qop) && ($qop == "auth")) + { + $response = + md5 (md5 ($A1).":".$fields["nonce"].":".$nc.":".$cnonce.":".$qop. + ":".$A2); + } + $auth_scheme = + sprintf + ('Digest username="%s", realm="%s", nonce="%s", uri="%s", response="%s"', + $username, $fields["realm"], $fields['nonce'], + $this->arguments["RequestURI"], $response); + if (isset ($algorithm)) + { + $auth_scheme .= sprintf (', algorithm="%s"', $algorithm); + } + if (isset ($qop)) + { + $auth_scheme .= sprintf (', cnonce="%s"', $cnonce); + } + if (array_key_exists ("opaque", $fields)) + { + $auth_scheme .= sprintf (', opaque="%s"', $fields['opaque']); + } + if (isset ($qop)) + { + $auth_scheme .= sprintf (', qop="%s"', $qop); + } + $auth_scheme .= sprintf (', nc=%s', $nc); + $this->nc++; + return $auth_scheme; + } +} From 9c2c338dc09e4a6b48ae1f02a9a04a9f856f39a1 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sun, 28 Dec 2014 14:21:54 +0100 Subject: [PATCH 042/152] Typo on variable --- htdocs/core/modules/printing/printgcp.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 2091c1a89eb..2d4cb8a2c98 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -186,9 +186,9 @@ class printing_printgcp extends PrintingDriver } else { - if (! empty($conf->global->PRINTIPP_GCP_DEFAULT)) + if (! empty($conf->global->PRINTING_GCP_DEFAULT)) { - $printer_id=$conf->global->PRINTIPP_GCP_DEFAULT; + $printer_id=$conf->global->PRINTING_GCP_DEFAULT; } else { From f738863e51fdd35d4aeedcbbaa3c76ea31a8b0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 28 Dec 2014 17:14:11 +0100 Subject: [PATCH 043/152] Revert previous commit --- htdocs/contrat/class/contrat.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f0ddc71aee0..5265f7025c5 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -51,6 +51,7 @@ class Contrat extends CommonObject var $id; var $ref; + var $ref_ext; var $ref_supplier; var $socid; var $societe; // Objet societe @@ -417,6 +418,7 @@ class Contrat extends CommonObject $sql.= " fk_commercial_signature, fk_commercial_suivi,"; $sql.= " note_private, note_public, model_pdf, extraparams"; $sql.= " ,ref_supplier"; + $sql.= " ,ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; if ($ref) { @@ -436,6 +438,7 @@ class Contrat extends CommonObject $this->id = $result["rowid"]; $this->ref = (!isset($result["ref"]) || !$result["ref"]) ? $result["rowid"] : $result["ref"]; $this->ref_supplier = $result["ref_supplier"]; + $this->ref_ext = $result["ref_ext"]; $this->statut = $result["statut"]; $this->mise_en_service = $this->db->jdate($result["datemise"]); $this->date_contrat = $this->db->jdate($result["datecontrat"]); @@ -737,7 +740,7 @@ class Contrat extends CommonObject // Insert contract $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat,"; $sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; - $sql.= " ref, entity, note_private, note_public, ref_supplier)"; + $sql.= " ref, entity, note_private, note_public, ref_supplier, ref_ext)"; $sql.= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id; $sql.= ", '".$this->db->idate($this->date_contrat)."'"; $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); @@ -748,6 +751,7 @@ class Contrat extends CommonObject $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->ref_supplier)?("'".$this->db->escape($this->ref_supplier)."'"):"NULL"); + $sql.= ", ".(!empty($this->ref_ext)?("'".$this->db->escape($this->ref_ext)."'"):"NULL"); $sql.= ")"; $resql=$this->db->query($sql); if ($resql) @@ -999,6 +1003,7 @@ class Contrat extends CommonObject if (isset($this->ref)) $this->ref=trim($this->ref); if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); + if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext); if (isset($this->entity)) $this->entity=trim($this->entity); if (isset($this->statut)) $this->statut=trim($this->statut); if (isset($this->fk_soc)) $this->fk_soc=trim($this->fk_soc); @@ -1022,6 +1027,7 @@ class Contrat extends CommonObject $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; $sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").","; + $sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").","; $sql.= " entity=".$conf->entity.","; $sql.= " date_contrat=".(dol_strlen($this->date_contrat)!=0 ? "'".$this->db->idate($this->date_contrat)."'" : 'null').","; $sql.= " statut=".(isset($this->statut)?$this->statut:"null").","; From 98ed7476719459f5a829db0700936a3e488f5403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 28 Dec 2014 17:17:08 +0100 Subject: [PATCH 044/152] Fix: [ bug #1765 ] Unable to create a contract --- htdocs/install/mysql/tables/llx_contrat.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_contrat.sql b/htdocs/install/mysql/tables/llx_contrat.sql index 5efbcdfe1fa..0e75c50305b 100644 --- a/htdocs/install/mysql/tables/llx_contrat.sql +++ b/htdocs/install/mysql/tables/llx_contrat.sql @@ -23,6 +23,7 @@ create table llx_contrat rowid integer AUTO_INCREMENT PRIMARY KEY, ref varchar(30), -- contrat reference ref_supplier varchar(30), -- suplier contract ref + ref_ext varchar(30), -- external contract ref entity integer DEFAULT 1 NOT NULL, -- multi company id tms timestamp, datec datetime, -- creation date From 50c2b75ef89a36c6d2c9335e548f13da1f94f043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Fri, 14 Nov 2014 16:43:49 +0100 Subject: [PATCH 045/152] Invoices: added situation (or interim) invoices support --- htdocs/accountancy/journal/sellsjournal.php | 23 +- htdocs/compta/facture.php | 232 +++++++++++++- htdocs/compta/facture/class/facture.class.php | 294 +++++++++++++++++- htdocs/compta/facture/impayees.php | 4 +- htdocs/compta/journal/sellsjournal.php | 24 +- htdocs/compta/paiement.php | 4 +- .../compta/paiement/class/paiement.class.php | 13 +- htdocs/compta/resultat/clientfourn.php | 10 +- htdocs/compta/resultat/index.php | 8 +- htdocs/compta/stats/cabyprodserv.php | 4 +- htdocs/compta/stats/cabyuser.php | 4 +- htdocs/compta/stats/casoc.php | 4 +- htdocs/compta/stats/index.php | 4 +- htdocs/core/class/commoninvoice.class.php | 15 +- htdocs/core/class/commonobject.class.php | 18 ++ htdocs/core/class/html.form.class.php | 54 +++- htdocs/core/lib/pdf.lib.php | 27 ++ htdocs/core/lib/price.lib.php | 7 +- htdocs/core/lib/tax.lib.php | 26 +- .../modules/facture/doc/pdf_crabe.modules.php | 101 +++++- htdocs/core/tpl/objectline_create.tpl.php | 11 +- htdocs/core/tpl/objectline_edit.tpl.php | 72 +++-- htdocs/core/tpl/objectline_view.tpl.php | 19 +- .../install/mysql/migration/3.7.0-3.8.0.sql | 7 + htdocs/install/mysql/tables/llx_facture.sql | 8 +- .../install/mysql/tables/llx_facturedet.sql | 9 +- htdocs/langs/en_US/bills.lang | 19 +- htdocs/langs/fr_FR/bills.lang | 18 ++ 28 files changed, 914 insertions(+), 125 deletions(-) diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 5bb1f989a92..8a0318473c9 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -7,6 +7,7 @@ * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2014 Raphaël Doursenaud * * 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 @@ -100,9 +101,9 @@ if (! empty($conf->multicompany->enabled)) { } $sql .= " AND f.fk_statut > 0"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) - $sql .= " AND f.type IN (0,1,2)"; + $sql .= " AND f.type IN (0,1,2,5)"; else - $sql .= " AND f.type IN (0,1,2,3)"; + $sql .= " AND f.type IN (0,1,2,3,5)"; $sql .= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; @@ -136,6 +137,16 @@ if ($result) { $cpttva = (! empty($conf->global->ACCOUNTING_VAT_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_ACCOUNT : $langs->trans("CodeNotDef"); $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + // Situation invoices handling + $line = new FactureLigne($db); + $line->fetch($obj->id); + $prev_progress = $line->get_prev_progress(); + if ($obj->situation_percent == 0) { // Avoid divide by 0 + $situation_ratio = 0; + } else { + $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; + } + // Invoice lines $tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["ref"] = $obj->facnumber; @@ -148,9 +159,9 @@ if ($result) { $tabht[$obj->rowid][$compta_prod] = 0; if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; - $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; - $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; - $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; + $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; + $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; + $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, @@ -471,4 +482,4 @@ if ($action == 'export_csv') { // End of page llxFooter(); } -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 9f104180def..3feb30cdb27 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -7,9 +7,10 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012-2013 Christophe Battarel + * Copyright (C) 2012-2013 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Jean-Francois FERRY * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -802,7 +803,7 @@ else if ($action == 'add' && $user->rights->facture->creer) } // Standard or deposit or proforma invoice - if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT || $_POST['type'] == Facture::TYPE_PROFORMA) && $_POST['fac_rec'] <= 0) + if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT || $_POST['type'] == Facture::TYPE_PROFORMA || ($_POST['type'] == Facture::TYPE_SITUATION && empty($_POST['situations']))) && $_POST['fac_rec'] <= 0) { if (GETPOST('socid', 'int') < 1) { @@ -837,6 +838,12 @@ else if ($action == 'add' && $user->rights->facture->creer) $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; + if($_POST['type'] == Facture::TYPE_SITUATION) { + $object->situation_counter = 1; + $object->situation_final = 0; + $object->situation_cycle_ref = $object->newCycle(); + } + $object->fetch_thirdparty(); // If creation from another object of another module (Example: origin=propal, originid=1) @@ -987,6 +994,7 @@ else if ($action == 'add' && $user->rights->facture->creer) $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + if ($object->situation_counter == 1) $lines[$i]->situation_percent = 0; if ($lines[$i]->subprice < 0) { @@ -1040,7 +1048,7 @@ else if ($action == 'add' && $user->rights->facture->creer) $array_option = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_option); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_option, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id); if ($result > 0) { $lineid = $result; @@ -1089,6 +1097,44 @@ else if ($action == 'add' && $user->rights->facture->creer) } } + if ($_POST['type'] == Facture::TYPE_SITUATION && (!empty($_POST['situations']))) { + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($datefacture)) { + $error++; + $mesg = '
' . $langs->trans("ErrorFieldRequired", $langs->trans("Date")) . '
'; + } + + if (!($_POST['situations'] > 0)) { + $error++; + $mesg = '
' . $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceSituation")) . '
'; + } + + if (!$error) { + $result = $object->fetch($_POST['situations']); + $object->fk_facture_source = $_POST['situations']; + $object->type = Facture::TYPE_SITUATION; + + $object->fetch_thirdparty(); + $object->date = $datefacture; + $object->note_public = trim($_POST['note_public']); + $object->note = trim($_POST['note']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = $_POST['cond_reglement_id']; + $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->remise_absolue = $_POST['remise_absolue']; + $object->remise_percent = $_POST['remise_percent']; + + // Proprietes particulieres a facture de remplacement + + $object->situation_counter = $object->situation_counter + 1; + $id = $object->createFromCurrent($user); + if ($id <= 0) $mesg = $object->error; + } + } + // End of object creation, we show it if ($id > 0 && ! $error) { @@ -1312,7 +1358,7 @@ else if ($action == 'addline' && $user->rights->facture->creer) setEventMessage($mesg, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option, $_POST['progress']); if ($result > 0) { @@ -1363,6 +1409,9 @@ else if ($action == 'addline' && $user->rights->facture->creer) unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); + + unset($_POST['situations']); + unset($_POST['progress']); } else { setEventMessage($object->error, 'errors'); } @@ -1413,6 +1462,17 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' } } + $line = new FactureLigne($db); + $line->fetch(GETPOST('lineid')); + $percent = $line->get_prev_progress(); + + if (GETPOST('progress') < $percent) { + $mesg = '
' . $langs->trans("CantBeLessThanMinPercent") . '
'; + setEventMessages($mesg, null, 'warnings'); + $error++; + $result = -1; + } + // Check minimum price $productid = GETPOST('productid', 'int'); if (! empty($productid)) { @@ -1450,7 +1510,7 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' // Update line if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option, GETPOST('progress')); if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -1484,12 +1544,28 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' unset($_POST['buying_price']); unset($_POST['np_marginRate']); unset($_POST['np_markRate']); + unset($_POST['situations']); + unset($_POST['progress']); } else { setEventMessage($object->error, 'errors'); } } } +else if ($action == 'updatealllines' && $user->rights->facture->creer && $_POST['all_percent'] == $langs->trans('Modifier')) { + if (!$object->fetch($id) > 0) dol_print_error($db); + if (!is_null(GETPOST('all_progress')) && GETPOST('all_progress') != "") { + foreach ($object->lines as $line) { + $percent = $line->get_prev_progress(); + if (GETPOST('all_progress') < $percent) { + $mesg = '
' . $langs->trans("CantBeLessThanMinPercent") . '
'; + $result = -1; + } else + $object->update_percent($line, $_POST['all_progress']); + } + } +} + else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition exit(); @@ -1800,6 +1876,8 @@ if ($action == 'create') require_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; print ajax_combobox('fac_replacement'); print ajax_combobox('fac_avoir'); + print ajax_combobox('situations'); + } print '
'; @@ -1961,6 +2039,29 @@ if ($action == 'create') if ($socid > 0) { + // First situation invoice + print ''; + print ''; + print ''; + $desc = $form->textwithpicto($langs->trans("InvoiceFirstSituationAsk"), $langs->transnoentities("InvoiceFirstSituationDesc"), 1); + print $desc; + print '' . "\n"; + + // Next situation invoice + $opt = $form->load_situation_invoices(GETPOST('originid'), $socid); + print ''; + print '' . $langs->trans('NoSituations') . '' || (GETPOST('origin') && GETPOST('origin') != 'facture')) print 'disabled="disabled"'; + print '>'; + print ''; + $text = $langs->trans("InvoiceSituationAsk") . ' '; + $text .= ''; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1); + print $desc; + print '' . "\n"; + // Replacement print ''; print '"; print ''; + // Situations + if ($object->type == 5 && ($object->situation_counter > 1)) { + $prevsits = $object->get_prev_sits(); + print ''; + print $langs->trans('SituationAmount'); + print ' '; + + print $prevsits[0]->situation_counter; + for ($i = 1; $i < count($prevsits); $i++) { + print ' + '; + print $prevsits[$i]->situation_counter; + } + print ' + '; + print $object->situation_counter; + + print ''; + print ''; + + $prevsits_total_amount = 0; + foreach ($prevsits as $situation) { + $prevsits_total_amount += $situation->total_ht; + } + $prevsits_total_amount += $object->total_ht; + + print price($prevsits_total_amount); + print ''; + print '' . $langs->trans('Currency' . $conf->currency) . ''; + + // Previous situation(s) deduction(s) + for ($i = 0; $i < count($prevsits); $i++) { + print ''; + print ''; + print $langs->trans('SituationDeduction'); + print ' '; + print $prevsits[$i]->situation_counter; + print ''; + + print ''; + print '- ' . price($prevsits[$i]->total_ht); + print ''; + print '' . $langs->trans('Currency' . $conf->currency) . ''; + } + } + // Amount print '' . $langs->trans('AmountHT') . ''; print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ''; @@ -3190,6 +3335,58 @@ if ($action == 'create') // Lines $result = $object->getLinesArray(); + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print ''; + + // Show global modifiers + if ($object->situation_cycle_ref && $object->statut == 0) { + print ''; + print ''; + print ''; + print ''; + print ''; + + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + print ''; + print ''; + print ''; + if ($inputalsopricewithtax) print ''; + print ''; + print ''; + print ''; + if (! empty($conf->margin->enabled) && empty($user->societe_id)) + { + print ''; + if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $user->rights->margins->liretous) { + print ''; + } + } + print ''; + print ''; + print ''; + print ''; + print "\n"; + + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + print ' @@ -3197,18 +3394,12 @@ if ($action == 'create') '; - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; - } - - print '
 ' . $langs->trans('ModifyAllLines') . '     ' . $langs->trans('Progress') . '      
 
     %
'; - // Show object lines if (! empty($object->lines)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); // Form to add new line - if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') + if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline' && ($object->is_first() || !$object->situation_cycle_ref)) { if ($action != 'editline') { @@ -3245,12 +3436,14 @@ if ($action == 'create') $ventilExportCompta = $object->getVentilExportCompta(); if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) { - if (! $objectidnext) { + if (! $objectidnext && $object->is_last_in_cycle()) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate) { print ''; } else { print '
' . $langs->trans('Modify') . '
'; } + } else if (!$object->is_last_in_cycle()) { + print '
' . $langs->trans('Modify') . '
'; } else { print '
' . $langs->trans('Modify') . '
'; } @@ -3273,7 +3466,7 @@ if ($action == 'create') } // Validate - if ($object->statut == 0 && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { + if ($object->statut == 0 && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA|| $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ($user->rights->facture->valider) { print ''; } @@ -3385,6 +3578,17 @@ if ($action == 'create') } } + //Create next situation invoice + if ($user->rights->facture->creer && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { + if ($object->is_last_in_cycle() && $object->situation_final != 1) { + print ''; + } else if (!$object->is_last_in_cycle()) { + print ''; + } else { + print ''; + } + } + // Delete if ($user->rights->facture->supprimer) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f81fb37849f..f28f068c255 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -10,6 +10,8 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012-2014 Marcos García + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Cedric Gross * Copyright (C) 2013 Florian Henry * @@ -122,6 +124,21 @@ class Facture extends CommonInvoice var $fac_rec; + /** + * @var int Situation cycle reference number + */ + public $situation_cycle_ref; + + /** + * @var int Situation counter inside the cycle + */ + public $situation_counter; + + /** + * @var bool Final situation flag + */ + public $situation_final; + /** * Standard invoice */ @@ -147,6 +164,11 @@ class Facture extends CommonInvoice */ const TYPE_PROFORMA = 4; + /** + * Situation invoice + */ + const TYPE_SITUATION = 5; + /** * Constructor * @@ -180,6 +202,17 @@ class Facture extends CommonInvoice if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; + if (empty($this->situation_cycle_ref)) { + $this->situation_cycle_ref = 'null'; + } + + if (empty($this->situation_counter)) { + $this->situation_counter = 'null'; + } + + if (empty($this->situation_final)) { + $this->situation_final = '0'; + } dol_syslog(get_class($this)."::create user=".$user->id); @@ -248,6 +281,7 @@ class Facture extends CommonInvoice $sql.= ", fk_account"; $sql.= ", fk_facture_source, fk_user_author, fk_projet"; $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; + $sql.= ", situation_cycle_ref, situation_counter, situation_final"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -269,7 +303,11 @@ class Facture extends CommonInvoice $sql.= ",".($this->fk_project?$this->fk_project:"null"); $sql.= ','.$this->cond_reglement_id; $sql.= ",".$this->mode_reglement_id; - $sql.= ", '".$this->db->idate($datelim)."', '".$this->modelpdf."')"; + $sql.= ", '".$this->db->idate($datelim)."', '".$this->modelpdf."'"; + $sql.= ", ".$this->situation_cycle_ref; + $sql.= ", ".$this->situation_counter; + $sql.= ", ".$this->situation_final; + $sql.=")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); @@ -399,7 +437,9 @@ class Facture extends CommonInvoice $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, $this->lines[$i]->label, - $this->lines[$i]->array_options + $this->lines[$i]->array_options, + $this->lines[$i]->situation_percent, + $this->lines[$i]->fk_prev_id ); if ($result < 0) { @@ -451,7 +491,9 @@ class Facture extends CommonInvoice 0, null, 0, - $_facrec->lines[$i]->label + $_facrec->lines[$i]->label, + null, + $_facrec->lines[$i]->situation_percent ); if ( $result_insert < 0) @@ -556,10 +598,14 @@ class Facture extends CommonInvoice $facture->lines = $this->lines; // Tableau des lignes de factures $facture->products = $this->lines; // Tant que products encore utilise + $facture->situation_counter = $this->situation_counter; + $facture->situation_cycle_ref=$this->situation_cycle_ref; + $facture->situation_final = $this->situation_final; // Loop on each line of new invoice foreach($facture->lines as $i => $line) { + $facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid; if ($invertdetail) { $facture->lines[$i]->subprice = -$facture->lines[$i]->subprice; @@ -827,6 +873,7 @@ class Facture extends CommonInvoice if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; + if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; if ($moretitle) $label.=' - '.$moretitle; $linkstart=''; @@ -863,6 +910,7 @@ class Facture extends CommonInvoice $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf'; $sql.= ', f.fk_facture_source'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; + $sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; $sql.= ', f.fk_account'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; @@ -923,7 +971,9 @@ class Facture extends CommonInvoice $this->user_author = $obj->fk_user_author; $this->user_valid = $obj->fk_user_valid; $this->modelpdf = $obj->model_pdf; - + $this->situation_cycle_ref = $obj->situation_cycle_ref; + $this->situation_counter = $obj->situation_counter; + $this->situation_final = $obj->situation_final; $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; @@ -974,6 +1024,7 @@ class Facture extends CommonInvoice $this->lines=array(); $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, '; + $sql .= ' l.situation_percent, l.fk_prev_id,'; $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' l.rang, l.special_code,'; $sql.= ' l.date_start as date_start, l.date_end as date_end,'; @@ -1033,6 +1084,8 @@ class Facture extends CommonInvoice $line->rang = $objp->rang; $line->special_code = $objp->special_code; $line->fk_parent_line = $objp->fk_parent_line; + $line->situation_percent= $objp->situation_percent; + $line->fk_prev_id = $objp->fk_prev_id; $this->lines[$i] = $line; @@ -1073,6 +1126,17 @@ class Facture extends CommonInvoice if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->import_key)) $this->import_key=trim($this->import_key); + if (empty($this->situation_cycle_ref)) { + $this->situation_cycle_ref = 'null'; + } + + if (empty($this->situation_counter)) { + $this->situation_counter = 'null'; + } + + if (empty($this->situation_final)) { + $this->situation_final = '0'; + } // Check parameters // Put here code to add control on parameters values @@ -1110,7 +1174,10 @@ class Facture extends CommonInvoice $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").""; + $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); + $sql.= ", situation_cycle_ref=".$this->situation_cycle_ref; + $sql.= ", situation_counter=".$this->situation_counter; + $sql.= ", situation_final=".$this->situation_final; $sql.= " WHERE rowid=".$this->id; @@ -1808,6 +1875,15 @@ class Facture extends CommonInvoice $this->statut=1; $this->brouillon=0; $this->date_validation=$now; + $i = 0; + $final = True; + while ($i < count($this->lines) && $final == True) { + $final = ($this->lines[$i]->situation_percent == 100); + $i++; + } + if ($final) { + $this->setFinal(); + } } } else @@ -1947,9 +2023,11 @@ class Facture extends CommonInvoice * @param int $pa_ht Buying price of line (to calculate margin) or '' * @param string $label Label of the line (deprecated, do not use) * @param array $array_option extrafields array + * @param int $situation_percent Situation advance percentage + * @param int $fk_prev_id Previous situation line id reference * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=0, $fk_prev_id='') { global $mysoc, $conf, $langs; @@ -1966,6 +2044,8 @@ class Facture extends CommonInvoice if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; + if (empty($fk_prev_id)) $fk_prev_id = 'null'; + if (is_null($situation_percent) || $situation_percent > 100) $situation_percent = 100; $remise_percent=price2num($remise_percent); $qty=price2num($qty); @@ -1999,7 +2079,7 @@ class Facture extends CommonInvoice $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2060,6 +2140,8 @@ class Facture extends CommonInvoice $this->line->fk_parent_line=$fk_parent_line; $this->line->origin=$origin; $this->line->origin_id=$origin_id; + $this->line->situation_percent = $situation_percent; + $this->line->fk_prev_id = $fk_prev_id; // infos marge $this->line->fk_fournprice = $fk_fournprice; @@ -2121,9 +2203,10 @@ class Facture extends CommonInvoice * @param string $label Label of the line (deprecated, do not use) * @param int $special_code Special code (also used by externals modules!) * @param array $array_option extrafields array + * @param int $situation_percent Situation advance percentage * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0, $situation_percent=0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2139,6 +2222,8 @@ class Facture extends CommonInvoice if (empty($qty)) $qty=0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; if (empty($special_code) || $special_code == 3) $special_code=0; + if ($situation_percent > 100 || is_null($situation_percent) || $situation_percent == "") $situation_percent = 100; + $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -2157,7 +2242,7 @@ class Facture extends CommonInvoice $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type,'',$localtaxes_type); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type,'',$localtaxes_type, $situation_percent); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -2205,6 +2290,8 @@ class Facture extends CommonInvoice $this->line->product_type = $type; $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; + $this->line->situation_percent = $situation_percent; + // infos marge if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { @@ -2247,6 +2334,28 @@ class Facture extends CommonInvoice } } + /** + * @param FactureLigne $line Invoice line + * @param int $percent + */ + function update_percent($line, $percent) + { + include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'); + + // Cap percentages to 100 + if ($percent > 100) $percent = 100; + $line->situation_percent = $percent; + $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->product_type, 'HT', 0, 0, '', '', $percent); + $line->total_ht = $tabprice[0]; + $line->total_tva = $tabprice[1]; + $line->total_ttc = $tabprice[2]; + $line->total_localtax1 = $tabprice[9]; + $line->total_localtax2 = $tabprice[10]; + $line->update(); + $this->update_price(1); + $this->db->commit(); + } + /** * Delete line in database * @@ -2647,6 +2756,10 @@ class Facture extends CommonInvoice if ($maxfacnumber == '' && $ventilExportCompta == 0) return 1; // If invoice to delete is last one and not already dispatched, we can delete if ($maxfacnumber == $this->ref && $ventilExportCompta == 0) return 1; + if ($this->situation_cycle_ref) { + $last = $this->is_last_in_cycle(); + return $last; + } } else if ($this->statut == 0 && $facref == 'PROV') // Si facture brouillon et provisoire { @@ -3206,6 +3319,7 @@ class Facture extends CommonInvoice { $sql = 'SELECT l.rowid, l.label as custom_label, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,'; $sql.= ' l.fk_remise_except, l.localtax1_tx, l.localtax2_tx,'; + $sql .= ' l.situation_percent, l.fk_prev_id,'; $sql.= ' l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code, l.fk_parent_line,'; $sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' l.date_start, l.date_end,'; @@ -3247,6 +3361,8 @@ class Facture extends CommonInvoice $this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_ttc = $obj->total_ttc; $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; + $this->lines[$i]->situation_percent = $obj->situation_percent; + $this->lines[$i]->fk_prev_id = $obj->fk_prev_id; $this->lines[$i]->special_code = $obj->special_code; $this->lines[$i]->rang = $obj->rang; $this->lines[$i]->date_start = $this->db->jdate($obj->date_start); @@ -3304,12 +3420,119 @@ class Facture extends CommonInvoice return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } + /** + * Gets the smallest reference available for a new cycle + * + * @return int >= 1 if OK, -1 if error + * + * + */ + function newCycle() + { + $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture'; + $resql = $this->db->query($sql); + if ($resql) { + if ($resql->num_rows > 0) { + $res = $this->db->fetch_array($resql); + $ref = $res['max(situation_cycle_ref)']; + $ref++; + } else { + $ref = 1; + } + $this->db->free($resql); + return $ref; + } else { + $this->error = $this->db->error(); + dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + return -1; + } + } + /** + * Checks if the invoice is the first of a cycle + * + */ + function is_first() + { + return ($this->situation_counter == 1); + } + /** + * Returns an array containing the previous situations as Facture objects + * + */ + function get_prev_sits() + { + + $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; + $sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref; + $sql .= ' and situation_counter < ' . $this->situation_counter; + $resql = $this->db->query($sql); + $res = array(); + if ($resql && $resql->num_rows > 0) { + while ($row = $this->db->fetch_object($resql)) { + $id = $row->rowid; + $situation = new Facture($this->db); + $situation->fetch($id); + $res[] = $situation; + } + } else { + $this->error = $this->db->error(); + dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + return -1; + } + + return $res; + } + + /** + * Sets the invoice as a final situation + * + * @return int 1 if ok, -1 if error + */ + function setFinal() + { + global $conf, $langs, $user; + $this->situation_final = 1; + $sql = 'update ' . MAIN_DB_PREFIX . 'facture set situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; + $resql = $this->db->query($sql); + if ($resql) { + // FIXME: call triggers? + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->error(); + dol_syslog(get_class($this) . "::update Error setFinal " . $sql, LOG_ERR); + $this->db->rollback(); + return -1; + } + } + + /** + * Checks if the invoice is the last in its cycle + * + * @return int 0 or 1 if OK, -1 if error + * + */ + + function is_last_in_cycle() + { + $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; + $resql = $this->db->query($sql); + + if ($resql && $resql->num_rows > 0) { + $res = $this->db->fetch_array($resql); + $last = $res['max(situation_counter)']; + return ($last == $this->situation_counter); + } else { + $this->error = $this->db->error(); + dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + } } - - /** * Class to manage invoice lines. * Saved into database table llx_facturedet @@ -3391,6 +3614,16 @@ class FactureLigne extends CommonInvoiceLine var $skip_update_total; // Skip update price total for special lines + /** + * @var int Situation advance percentage + */ + public $situation_percent; + + /** + * @var int Previous situation line id reference + */ + public $fk_prev_id; + /** * Constructor * @@ -3414,6 +3647,7 @@ class FactureLigne extends CommonInvoiceLine $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; $sql.= ' fd.fk_code_ventilation,'; + $sql.= ' fd.situation_percent, fd.fk_prev_id,'; $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; @@ -3461,6 +3695,9 @@ class FactureLigne extends CommonInvoiceLine $this->product_label = $objp->product_libelle; $this->product_desc = $objp->product_desc; + $this->situation_percent = $objp->situation_percent; + $this->fk_prev_id = $objp->fk_prev_id; + $this->db->free($result); } else @@ -3498,6 +3735,8 @@ class FactureLigne extends CommonInvoiceLine if (empty($this->subprice)) $this->subprice=0; if (empty($this->special_code)) $this->special_code=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + if (empty($this->fk_prev_id)) $this->fk_prev_id = 'null'; + if (empty($this->situation_percent)) $this->situation_percent = 0; if (empty($this->pa_ht)) $this->pa_ht=0; @@ -3541,7 +3780,8 @@ class FactureLigne extends CommonInvoiceLine $sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; $sql.= ' date_start, date_end, fk_code_ventilation, '; $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; - $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2)'; + $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; + $sql.= ' situation_percent, fk_prev_id)'; $sql.= " VALUES (".$this->fk_facture.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -3570,6 +3810,8 @@ class FactureLigne extends CommonInvoiceLine $sql.= " ".price2num($this->total_ttc).","; $sql.= " ".price2num($this->total_localtax1).","; $sql.= " ".price2num($this->total_localtax2); + $sql .= ", " . $this->situation_percent; + $sql .= ", " . $this->fk_prev_id; $sql.= ')'; dol_syslog(get_class($this)."::insert", LOG_DEBUG); @@ -3687,6 +3929,7 @@ class FactureLigne extends CommonInvoiceLine if (empty($this->special_code)) $this->special_code=0; if (empty($this->product_type)) $this->product_type=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + if (is_null($this->situation_percent)) $this->situation_percent=100; // Check parameters if ($this->product_type < 0) return -1; @@ -3732,6 +3975,7 @@ class FactureLigne extends CommonInvoiceLine $sql.= " , buy_price_ht='".price2num($this->pa_ht)."'"; $sql.= ",fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); if (! empty($this->rang)) $sql.= ", rang=".$this->rang; + $sql .= ", situation_percent=" . $this->situation_percent; $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -3846,5 +4090,29 @@ class FactureLigne extends CommonInvoiceLine return -2; } } -} + /** + * Returns situation_percent of the previous line + * + * @return int >= 0 + */ + + function get_prev_progress() + { + if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { + return 0; + } else { + $sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id; + $resql = $this->db->query($sql); + if ($resql && $resql->num_rows > 0) { + $res = $this->db->fetch_array($resql); + return $res['situation_percent']; + } else { + $this->error = $this->db->error(); + dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + } + } +} diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index a010e7d7401..0c6b2af84f0 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -3,6 +3,8 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2014 Raphaël Doursenaud * * 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 @@ -408,7 +410,7 @@ $sql.= ",".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; -$sql.= " AND f.type IN (0,1,3) AND f.fk_statut = 1"; +$sql.= " AND f.type IN (0,1,3,5) AND f.fk_statut = 1"; $sql.= " AND f.paye = 0"; if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index e249d3fe554..9fd0d411d8e 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -4,7 +4,9 @@ * Copyright (C) 2011-2014 Juanjo Menent * Copyright (C) 2012 Regis Houssin * Copyright (C) 2011-2012 Alexandre Spangaro + * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2013 Marcos García + * Copyright (C) 2014 Raphaël Doursenaud * * 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 @@ -101,7 +103,7 @@ $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $p[0]; $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client,"; -$sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,"; +$sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2, fd.rowid as id, fd.situation_percent,"; $sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.client,"; $sql.= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell,"; $sql.= " ct.accountancy_code_sell as account_tva, ct.recuperableonly"; @@ -112,8 +114,8 @@ $sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.fk_statut > 0"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; -else $sql.= " AND f.type IN (0,1,2,3)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; +else $sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " ORDER BY f.rowid"; @@ -157,6 +159,16 @@ if ($result) $account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $obj->thirdparty, $mysoc); $compta_localtax2= (! empty($account_localtax2[3])?$account_localtax2[3]:$langs->trans("CodeNotDef")); + // Situation invoices handling + $line = new FactureLigne($db); + $line->fetch($obj->id); + $prev_progress = $line->get_prev_progress(); + if ($obj->situation_percent == 0) { // Avoid divide by 0 + $situation_ratio = 0; + } else { + $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; + } + //la ligne facture $tabfac[$obj->rowid]["date"] = $obj->datef; $tabfac[$obj->rowid]["ref"] = $obj->facnumber; @@ -166,9 +178,9 @@ if ($result) if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva]=0; if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1]=0; if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2]=0; - $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; - $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; - if($obj->recuperableonly != 1) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; + $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; + $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; + if($obj->recuperableonly != 1) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; $tabcompany[$obj->rowid]=array('id'=>$obj->socid, 'name'=>$obj->name, 'client'=>$obj->client); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 0ccf0dee6bf..fabf656c895 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -4,6 +4,8 @@ * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * * This program is free software; you can redistribute it and/or modify @@ -469,7 +471,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled if ($facture->type != 2) { - $sql .= ' AND type IN (0,1,3)'; // Standard invoice, replacement, deposit + $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation } else { diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 95503db6ff9..6c3743f70a6 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -2,6 +2,8 @@ /* Copyright (C) 2002-2004 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2014 Marcos García * * This program is free software; you can redistribute it and/or modify @@ -212,13 +214,14 @@ class Paiement extends CommonObject //Invoice types that are eligible for changing status to paid $affected_types = array( - 0, - 1, - 2, - 3 + Facture::TYPE_STANDARD, + Facture::TYPE_REPLACEMENT, + Facture::TYPE_CREDIT_NOTE, + Facture::TYPE_DEPOSIT, + Facture::TYPE_SITUATION ); - if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice. We do nothing more."); + if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more."); else if ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more."); else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more."); else diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 9122ece2ed9..8c522df75d4 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -2,6 +2,8 @@ /* Copyright (C) 2002-2006 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Dourseanud * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry @@ -166,9 +168,9 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut IN (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) - $sql.= " AND f.type IN (0,1,2)"; + $sql.= " AND f.type IN (0,1,2,5)"; else - $sql.= " AND f.type IN (0,1,2,3)"; + $sql.= " AND f.type IN (0,1,2,3,5)"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } @@ -693,9 +695,9 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_statut IN (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) - $sql.= " AND f.type IN (0,1,2)"; + $sql.= " AND f.type IN (0,1,2,5)"; else - $sql.= " AND f.type IN (0,1,2,3)"; + $sql.= " AND f.type IN (0,1,2,3,5)"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.entity = ".$conf->entity; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index b586241c11e..ec29d25a76e 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -103,8 +103,8 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut IN (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; } else { @@ -246,8 +246,8 @@ if ($modecompta == 'CREANCES-DETTES') $sql = "SELECT sum(f.tva) as amount, date_format(f.datef,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_statut IN (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " GROUP BY dm"; diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 8263dc76cb8..61f0bbb590d 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -193,9 +193,9 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " AND l.fk_facture = f.rowid"; $sql.= " AND f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (0,1,2)"; + $sql.= " AND f.type IN (0,1,2,5)"; } else { - $sql.= " AND f.type IN (0,1,2,3)"; + $sql.= " AND f.type IN (0,1,2,3,5)"; } if ($date_start && $date_end) { $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index e88d370a0c6..066967cc2c3 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -178,9 +178,9 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid"; $sql.= " WHERE f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (0,1,2)"; + $sql.= " AND f.type IN (0,1,2,5)"; } else { - $sql.= " AND f.type IN (0,1,2,3)"; + $sql.= " AND f.type IN (0,1,2,3,5)"; } if ($date_start && $date_end) { $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 1d34f78a181..a4c4663dc40 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -191,9 +191,9 @@ if ($modecompta == 'CREANCES-DETTES') { } $sql.= " WHERE f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (0,1,2)"; + $sql.= " AND f.type IN (0,1,2,5)"; } else { - $sql.= " AND f.type IN (0,1,2,3)"; + $sql.= " AND f.type IN (0,1,2,3,5)"; } $sql.= " AND f.fk_soc = s.rowid"; if ($date_start && $date_end) { diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index cfd816c29b6..f704ca90f73 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -91,8 +91,8 @@ if ($modecompta == 'CREANCES-DETTES') $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_statut in (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; } else { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 90ad3e196e3..991601a4fbd 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1,5 +1,7 @@ +/* Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * * 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 @@ -143,11 +145,12 @@ abstract class CommonInvoice extends CommonObject function getLibType() { global $langs; - if ($this->type == 0) return $langs->trans("InvoiceStandard"); - if ($this->type == 1) return $langs->trans("InvoiceReplacement"); - if ($this->type == 2) return $langs->trans("InvoiceAvoir"); - if ($this->type == 3) return $langs->trans("InvoiceDeposit"); - if ($this->type == 4) return $langs->trans("InvoiceProForma"); + if ($this->type == Facture::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); + if ($this->type == Facture::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); + if ($this->type == Facture::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); + if ($this->type == Facture::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); + if ($this->type == Facture::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); + if ($this->type == Facture::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); return $langs->trans("Unknown"); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0dedb135298..81a4946208a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2011-2014 Philippe Grand * Copyright (C) 2012-2014 Marcos García + * Copyright (C) 2012-2014 Raphaël Doursenaud * * 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 @@ -1740,6 +1741,19 @@ abstract class CommonObject // Add revenue stamp to total $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + // Situations totals + if ($this->situation_cycle_ref && $this->situation_counter > 1) { + $prev_sits = $this->get_prev_sits(); + + foreach ($prev_sits as $sit) { + $this->total_ht -= $sit->total_ht; + $this->total_tva -= $sit->total_tva; + $this->total_localtax1 -= $sit->total_localtax1; + $this->total_localtax2 -= $sit->total_localtax2; + $this->total_ttc -= $sit->total_ttc; + } + } + $this->db->free($resql); // Now update global field total_ht, total_ttc and tva @@ -2568,6 +2582,10 @@ abstract class CommonObject // Reduction short print ''; + if ($this->situation_cycle_ref) { + print ''; + } + if (! empty($conf->margin->enabled) && empty($user->societe_id)) { if ($conf->global->MARGIN_TYPE == "1") diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 491e590403c..9ce830ac513 100755 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -13,7 +13,8 @@ * Copyright (C) 2010-2014 Philippe Grand * Copyright (C) 2011 Herve Prot * Copyright (C) 2012-2014 Marcos García - * Copyright (C) 2013 Raphaël Doursenaud + * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2014 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -2657,6 +2658,57 @@ class Form } } + /** + * Creates HTML last in cycle situation invoices selector + * + * @param string $selected Preselected ID + * @param int $socid Company ID + * + * @return string HTML select + */ + function load_situation_invoices($selected = '', $socid) + { + global $langs; + + $langs->load('bills'); + + $opt = ''; + $sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1'; + $sql .= ' order by situation_cycle_ref, situation_counter desc'; + $resql = $this->db->query($sql); + if ($resql && $this->db->num_rows($resql) > 0) { + // Last seen cycle + $ref = 0; + while ($res = $this->db->fetch_array($resql, MYSQL_NUM)) { + //Same company ? + if ($socid == $res[5]) { + //Same cycle ? + if ($res[2] != $ref) { + // Just seen this cycle + $ref = $res[2]; + //not final ? + if ($res[4] != 1) { + //Not prov? + if (substr($res[1], 1, 4) != 'PROV') { + if ($selected == $res[0]) { + $opt .= ''; + } else { + $opt .= ''; + } + } + } + } + } + } + } else { + dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); + } + if ($opt == '') { + $opt = ''; + } + return $opt; + } + /** * Return a HTML select list of bank accounts * diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 129d32fc7d9..4f1c8f71c5a 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -5,6 +5,8 @@ * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * @@ -1448,6 +1450,31 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0) } } +/** + * Return line percent + * + * @param Object $object Object + * @param int $i Current line number + * @param Translate $outputlangs Object langs for output + * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) + * @param HookManager $hookmanager Hook manager instance + * @return void + */ +function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null) +{ + if ($object->lines[$i]->special_code != 3) { + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) { + $special_code = $object->lines[$i]->special_code; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); + $action = ''; + return $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + } else { + if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->situation_percent . '%'; + } + } +} + /** * Return line total excluding tax * diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 00144db74e5..aa3a1e11a46 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -3,6 +3,8 @@ * Copyright (C) 2006-2008 Laurent Destailleur * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * * 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 @@ -47,6 +49,7 @@ * @param int $type 0/1=Product/service * @param Societe $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc. * @param array $localtaxes_array Array with localtaxes info (loaded by getLocalTaxesFromRate function). + * @param float $progress Situation invoices progress * @return result[ 0=total_ht, * 1=total_vat, * 2=total_ttc, @@ -64,7 +67,7 @@ * 14=amount tax1 for total_ht_without_discount, * 15=amount tax2 for total_ht_without_discount] */ -function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '',$localtaxes_array='') +function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100) { global $conf,$mysoc,$db; @@ -128,7 +131,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt else dol_print_error($db); } // initialize total (may be HT or TTC depending on price_base_type) - $tot_sans_remise = $pu * $qty; + $tot_sans_remise = $pu * $qty * $progress / 100; $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); $tot_avec_remise = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100)); diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index cc9478f5d61..1c048c7d6f5 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -3,6 +3,8 @@ * Copyright (C) 2006-2007 Yannick Warnier * Copyright (C) 2011 Regis Houssin * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * * 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 @@ -133,8 +135,8 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction $sql.= " ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; if ($y && $m) { $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; @@ -170,8 +172,8 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE "; $sql.= " f.fk_statut in (2)"; // Paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; if ($y && $m) { $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; @@ -294,8 +296,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND f.rowid = d.".$fk_facture; if ($y && $m) { @@ -339,8 +341,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND f.rowid = d.".$fk_facture; if ($y && $m) { @@ -452,8 +454,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND f.rowid = d.".$fk_facture; if ($y && $m) { @@ -500,8 +502,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; - else $sql.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND f.rowid = d.".$fk_facture;; $sql.= " AND pf.".$fk_facture2." = f.rowid"; $sql.= " AND pa.rowid = pf.".$fk_payment; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 6d1f5636b85..06c3df85f4d 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -4,6 +4,8 @@ * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * * 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 @@ -56,6 +58,16 @@ class pdf_crabe extends ModelePDFFactures var $emetteur; // Objet societe qui emet + /** + * @var bool Situation invoice type + */ + public $situationinvoice; + + /** + * @var float X position for the situation progress column + */ + public $posxprogress; + /** * Constructor @@ -107,6 +119,7 @@ class pdf_crabe extends ModelePDFFactures $this->posxup=126; $this->posxqty=145; $this->posxdiscount=162; + $this->posxprogress=174; // Only displayed for situation invoices $this->postotalht=174; if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images @@ -125,6 +138,7 @@ class pdf_crabe extends ModelePDFFactures $this->localtax2=array(); $this->atleastoneratenotnull=0; $this->atleastonediscount=0; + $this->situationinvoice=False; } @@ -278,6 +292,17 @@ class pdf_crabe extends ModelePDFFactures //$this->postotalht; } + // Situation invoice handling + if ($object->situation_cycle_ref) { + $this->situationinvoice = True; + $progress_width = 14; + $this->posxtva -= $progress_width; + $this->posxup -= $progress_width; + $this->posxqty -= $progress_width; + $this->posxdiscount -= $progress_width; + $this->posxprogress -= $progress_width; + } + // New page $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); @@ -444,16 +469,27 @@ class pdf_crabe extends ModelePDFFactures { $pdf->SetXY($this->posxdiscount-2, $curY); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); - $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); + $pdf->MultiCell($this->posxprogress-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); } + // Situation progress + $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxprogress, $curY); + $pdf->MultiCell($this->postotalht-$this->posxprogress, 3, $progress, 0, 'R'); // Enough for 6 chars + // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $tvaligne=$object->lines[$i]->total_tva; + $prev_progress = $object->lines[$i]->get_prev_progress(); + if ($prev_progress > 0) // Compute progress from previous situation + { + $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + } else { + $tvaligne = $object->lines[$i]->total_tva; + } $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; @@ -912,7 +948,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('','', $default_font_size - 1); // Tableau total - $col1x = 120; $col2x = 170; + $col1x = 120; $col2x = $this->postotalht; if ($this->page_largeur < 210) // To work with US executive format { $col2x-=20; @@ -922,11 +958,44 @@ class pdf_crabe extends ModelePDFFactures $useborder=0; $index = 0; + // Previous situations summary + if ($object->situation_cycle_ref && $object->situation_counter > 1) { + // Situations total w/out VAT + $counter = ' 1'; + for ($i = 2; $i <= $object->situation_counter; $i++) { + $counter .= ' + ' . $i; + } + + $prevsits = $object->get_prev_sits(); + $prevsits_total_amount = 0; + foreach ($prevsits as $situation) { + $prevsits_total_amount += $situation->total_ht; + } + $prevsits_total_amount += $object->total_ht; + + $pdf->SetFillColor(255, 255, 255); + $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationAmount") . $counter, 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + 0); + $pdf->MultiCell($largcol2, $tab2_hl, price($prevsits_total_amount), 0, 'R', 1); + + // Previous situations deduction + $pdf->Line($col2x, 0, $col2x, 100000); + for ($i = 0; $i < count($prevsits); $i++) { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationDeduction") . ' ' . ($i + 1) . ' (' . $prevsits[$i]->ref . ')', 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, ' - ' . price($prevsits[$i]->total_ht), 0, 'R', 1); + } + $index++; + } + // Total HT $pdf->SetFillColor(255,255,255); - $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + 0); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total @@ -1265,19 +1334,21 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($this->posxqty-1, $tab_top+1); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); } - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); - if (empty($hidetop)) - { - if ($this->atleastonediscount) - { - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); + if ($this->atleastonediscount) { + $pdf->line($this->posxprogress, $tab_top, $this->posxprogress, $tab_top + $tab_height); + if (empty($hidetop)) { + $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); + $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); } } - if ($this->atleastonediscount) - { + + if ($this->situationinvoice) { $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + if (empty($hidetop)) { + $pdf->SetXY($this->posxprogress - 1, $tab_top + 1); + $pdf->MultiCell($this->postotalht - $this->posxprogress - 1, 2, $outputlangs->transnoentities("Progress"), '', 'C'); + } } if (empty($hidetop)) { @@ -1353,6 +1424,8 @@ class pdf_crabe extends ModelePDFFactures if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit"); if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat"); + if ($object->type == 5 && $object->situation_final == 0) $title = $outputlangs->transnoentities("InvoiceSituation").' n°'.$object->situation_counter; + if ($object->type == 5 && $object->situation_final == 1) $title = 'Situation n°'.$object->situation_counter.' : '.$outputlangs->transnoentities("InvoiceSituationLast"); $pdf->MultiCell(100, 3, $title, '', 'R'); $pdf->SetFont('','B',$default_font_size); diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 6037f6c77c9..d90526aba06 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -2,7 +2,9 @@ /* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2012-2013 Christophe Battarel + * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2013 Florian Henry + * Copyright (C) 2014 Raphaël Doursenaud * * 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 @@ -58,6 +60,9 @@ if (in_array($object->element,array('propal','facture','invoice','commande','ord situation_cycle_ref) { + print ''; + } if (! empty($usemargins)) { ?> @@ -214,8 +219,11 @@ else { - situation_cycle_ref) { + $coldisplay++; + print ''; + } if (! empty($usemargins)) { ?> @@ -277,6 +285,7 @@ if (! empty($conf->service->enabled) && $dateSelector && GETPOST('type') != '0') { if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; else $colspan = 9; + if($this->situation_cycle_ref) $colspan++; if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index fbe2870a6a4..fd2e3e0d469 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -2,6 +2,8 @@ /* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -83,22 +85,44 @@ $coldisplay=-1; // We remove first td $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action); } - // editeur wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); - $doleditor=new DolEditor('product_desc',$line->description,'',164,'dolibarr_details','',false,true,$enable,$nbrows,'98%'); - $doleditor->Create(); + // Do not allow editing during a situation cycle + if ($this->situation_counter == 1 || !$this->situation_cycle_ref) { + // editeur wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); + $doleditor=new DolEditor('product_desc',$line->description,'',164,'dolibarr_details','',false,true,$enable,$nbrows,'98%'); + $doleditor->Create(); + } else { + print ''; + } ?> - + situation_counter == 1 || !$this->situation_cycle_ref) { + print ''; + } else { + print ''; + } - - - - + $coldisplay++; + print ''; + + if ($inputalsopricewithtax) { + $coldisplay++; + print ''; + } ?> - situation_cycle_ref) { + $coldisplay++; + print ''; + } if (! empty($usemargins)) { ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 3d2ea127b85..2e1cc0f3678 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -2,6 +2,8 @@ /* Copyright (C) 2010-2013 Regis Houssin * Copyright (C) 2010-2011 Laurent Destailleur * Copyright (C) 2012-2013 Christophe Battarel + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -138,6 +140,11 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; situation_cycle_ref) { + $coldisplay++; + print ''; + } + if (! empty($conf->margin->enabled) && empty($user->societe_id)) { $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?> @@ -167,12 +174,16 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; - 1 && empty($conf->browser->phone)) { ?> + 1 && empty($conf->browser->phone) && ($this->situation_counter == 1 || !$this->situation_cycle_ref)) { ?> '; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index b591aa79c08..69f5d30b09a 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -309,15 +309,13 @@ foreach ($dirmodels as $reldir) $htmltooltip=''; $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval=$module->getNextValue($mysoc,$livraison); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) - { + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); $htmltooltip.=$nextval.'
'; - } - else - { + } else { $htmltooltip.=$langs->trans($module->error).'
'; } } diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 01f32740036..30ae7e71ab3 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -344,18 +344,16 @@ foreach ($dirmodels as $reldir) $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $propal->type=0; $nextval=$module->getNextValue($mysoc,$propal); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) - { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } print '
"; print "'; // Date end print ''; print '
trans('Qty'); ?> trans('ReductionShort'); ?> ' . $langs->trans('Progress') . '"> remise_percent); ?>">%%load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?>' . $form->load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type) . '%situation_counter > 1) { + print 'readonly="readonly" '; + } + print '>situation_counter > 1) { + print 'readonly="readonly" '; + } + print '> info_bits & 2) != 2) { @@ -106,22 +130,32 @@ $coldisplay=-1; // We remove first td // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated // must also not be output for most entities (proposal, intervention, ...) //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; - ?> - - + print 'situation_counter > 1) { + print 'readonly="readonly" '; + } + print '/>'; + } else { ?>   - info_bits & 2) != 2) { ?> - % - + info_bits & 2) != 2) { + print 'situation_counter > 1) { + print 'readonly="readonly" '; + } + print '/>%'; + } else { ?>   %  ' . $line->situation_percent . '% - id; ?>"> - - + situation_counter == 1 || !$this->situation_cycle_ref) { + print 'id . '">'; + print img_delete(); + print ''; + } + ?> 0) { ?> id; ?>"> diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 755195c2a61..02265ff86c8 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -30,3 +30,10 @@ ALTER TABLE llx_product_fournisseur_price ADD fk_price_expression integer DEFAUL -- Taiwan VAT Rates insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 2131, 213, '5', '0', 'VAT 5%', 1); + +-- Add situation invoices +ALTER TABLE llx_facture ADD situation_cycle_ref smallint UNSIGNED; +ALTER TABLE llx_facture ADD situation_counter tinyint UNSIGNED; +ALTER TABLE llx_facture ADD situation_final boolean; +ALTER TABLE llx_facturedet ADD situation_percent real; +ALTER TABLE llx_facturedet ADD fk_prev_id integer; diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 9757f749cd0..144cd349dd6 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -3,6 +3,8 @@ -- Copyright (C) 2004-2012 Laurent Destailleur -- Copyright (C) 2005-2012 Regis Houssin -- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2012 Cédric Salvador +-- Copyright (C) 2014 Raphaël Doursenaud -- -- 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 @@ -74,6 +76,10 @@ create table llx_facture note_public text, model_pdf varchar(255), import_key varchar(14), - extraparams varchar(255) -- for stock other parameters with json format + extraparams varchar(255), -- for stock other parameters with json format + + situation_cycle_ref smallint UNSIGNED, -- situation cycle reference + situation_counter tinyint UNSIGNED, -- situation counter + situation_final boolean -- is the situation final ? )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index 6a328d4688e..2c01234f4b9 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -3,6 +3,8 @@ -- Copyright (C) 2004-2005 Laurent Destailleur -- Copyright (C) 2005-2012 Regis Houssin -- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2012 Cédric Salvador +-- Copyright (C) 2014 Raphaël Doursenaud -- -- 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 @@ -55,8 +57,11 @@ create table llx_facturedet fk_code_ventilation integer DEFAULT 0 NOT NULL, special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- ordre d'affichage - import_key varchar(14) - + import_key varchar(14), + + situation_percent real, -- % progression of lines invoicing + fk_prev_id integer -- id of the line in the previous situation + )ENGINE=innodb; -- diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 12778d6b9ea..ccf994aff95 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -389,7 +389,7 @@ DisabledBecausePayments=Not possible since there are some payments CantRemovePaymentWithOneInvoicePaid=Can't remove payment since there is at least one invoice classified paid ExpectedToPay=Expected payment PayedByThisPayment=Paid by this payment -ClosePaidInvoicesAutomatically=Classify "Paid" all standard or replacement invoices entirely paid. +ClosePaidInvoicesAutomatically=Classify "Paid" all standard, situation or replacement invoices entirely paid. ClosePaidCreditNotesAutomatically=Classify "Paid" all credit notes entirely paid back. AllCompletelyPayedInvoiceWillBeClosed=All invoice with no remain to pay will be automatically closed to status "Paid". ToMakePayment=Pay @@ -411,3 +411,20 @@ TypeContact_invoice_supplier_internal_SALESREPFOLL=Representative following-up s TypeContact_invoice_supplier_external_BILLING=Supplier invoice contact TypeContact_invoice_supplier_external_SHIPPING=Supplier shipping contact TypeContact_invoice_supplier_external_SERVICE=Supplier service contact +# Situation invoices +InvoiceFirstSituationAsk=First situation invoice +InvoiceFirstSituationDesc=The situation invoices are tied to situations related to a progression, for example the progression of a construction. Each situation is tied to an invoice. +InvoiceSituation=Situation invoice +InvoiceSituationAsk=Invoice following the situation +InvoiceSituationDesc=Create a new situation following an already existing one +SituationAmount=Situation invoice amount(net) +SituationDeduction=Situation subtraction +Progress=Progress +ModifyAllLines=Modify all lines +CreateNextSituationInvoice=Create next situation +NotLastInCycle=This invoice in not the last in cycle and must not be modified. +DisabledBecauseNotLastInCycle=The next situation already exists. +DisabledBecauseFinal=This situation is final. +CantBeLessThanMinPercent=The progress can't be smaller than its value in the previous situation. +NoSituations=No opened situations +InvoiceSituationLast=Final and general invoice diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 24ebe5ff923..22c80d41300 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -410,3 +410,21 @@ TypeContact_invoice_supplier_internal_SALESREPFOLL=Responsable suivi facture fou TypeContact_invoice_supplier_external_BILLING=Contact fournisseur facturation TypeContact_invoice_supplier_external_SHIPPING=Contact fournisseur livraison TypeContact_invoice_supplier_external_SERVICE=Contact fournisseur prestation +# Factures de situation +InvoiceFirstSituationAsk=Facture de première situation +InvoiceFirstSituationDesc=Les factures de situation correspondent aux situations liées à un avancement, par exemple l'avancement des travaux dans le cadre d’un chantier (BTP). Chaque situation correspond à une facture. +InvoiceFirstSituation=Facture de première situation +InvoiceSituationAsk=Facture suivant la situation +InvoiceSituationDesc=Création d'une nouvelle situation qui fera suite à une situation déjà ouverte. +InvoiceSituation=Facture de situation +SituationAmount=Montant HT situation +SituationDeduction=Déduction situation +Progress=Avanct. +ModifyAllLines=Modifier toutes les lignes +CreateNextSituationInvoice=Créer situation suivante +NotLastInCycle=Cette facture n'est pas la dernière du cycle, il ne faut pas la modifier. +DisabledBecauseNotLastInCycle=La situation suivante existe déjà. +DisabledBecauseFinal=Cette situation est finale. +CantBeLessThanMinPercent=L'avancement d'une ligne ne peut pas être inférieur à sa valeur à la situation précédente. +NoSituations=Pas de situations en cours +InvoiceSituationLast=Décompte général et définitif From 90add2fa9636695eb4f7420f7153f8d14aae5649 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jan 2015 17:23:52 +0100 Subject: [PATCH 046/152] Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. --- ChangeLog | 1 + htdocs/main.inc.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0a849cce895..5b621467312 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.6.3 compared to 3.6.2 ***** - Fix: ref_ext was not saved when recording a customer order from web service +- Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 419c737b270..b17bc913752 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -725,7 +725,7 @@ if (! empty($conf->browser->phone)) // If we force to use jmobile, then we reenable javascript if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; // Disabled bugged themes -if (! empty($conf->dol_use_jmobile) && in_array($conf->theme,array('bureau2crea','cameleo'))) +if (! empty($conf->dol_use_jmobile) && in_array($conf->theme,array('bureau2crea','cameleo','amarok'))) { $conf->theme='eldy'; $conf->css = "/theme/".$conf->theme."/style.css.php"; From c441aa89db3876758277ca3f272f64c8c007219b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jan 2015 18:19:44 +0100 Subject: [PATCH 047/152] Fixed: Avoid warning --- htdocs/core/modules/DolibarrModules.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index e25f4d0c715..8b636fd247f 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -748,6 +748,8 @@ abstract class DolibarrModules $err=0; + if (empty($this->const)) return 0; + foreach ($this->const as $key => $value) { $name = $this->const[$key][0]; @@ -816,6 +818,8 @@ abstract class DolibarrModules $err=0; + if (empty($this->const)) return 0; + foreach ($this->const as $key => $value) { $name = $this->const[$key][0]; From 173d3aaa90c6161d1ff6737aa890aa2437b8cf66 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sun, 11 Jan 2015 11:31:53 +0100 Subject: [PATCH 048/152] Translation error messages numbering modules --- htdocs/admin/commande.php | 22 ++++++------ htdocs/admin/contract.php | 22 ++++++------ htdocs/admin/expedition.php | 22 ++++++------ htdocs/admin/facture.php | 56 +++++++++++++----------------- htdocs/admin/fichinter.php | 16 ++++++--- htdocs/admin/livraison.php | 12 +++---- htdocs/admin/propal.php | 22 ++++++------ htdocs/admin/supplier_invoice.php | 12 +++---- htdocs/admin/supplier_order.php | 12 +++---- htdocs/core/lib/functions2.lib.php | 25 +++++++------ htdocs/langs/en_US/errors.lang | 2 ++ htdocs/langs/fr_FR/errors.lang | 2 ++ 12 files changed, 106 insertions(+), 119 deletions(-) diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index aaa1949d7dd..7c0d7fdbf9c 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -348,18 +348,16 @@ foreach ($dirmodels as $reldir) $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $commande->type=0; $nextval=$module->getNextValue($mysoc,$commande); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) - { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } print '
'; print $form->textwithpicto('',$htmltooltip,1,0); diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 817ac84d768..45d79f01ae5 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -299,18 +299,16 @@ foreach ($dirmodels as $reldir) $htmltooltip=''; $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval=$module->getNextValue($mysoc,$contract); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) - { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } print '
'; print $form->textwithpicto('',$htmltooltip,1,0); diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 2efdfdd56ba..933f9a87d18 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -324,18 +324,16 @@ foreach ($dirmodels as $reldir) $htmltooltip=''; $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval=$module->getNextValue($mysoc,$expedition); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) - { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } print '
'; print $form->textwithpicto('',$htmltooltip,1,0); diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index a7692655a0a..298c0beddf5 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -393,61 +393,53 @@ foreach ($dirmodels as $reldir) $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $facture->type=0; $nextval=$module->getNextValue($mysoc,$facture); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip.=$langs->trans("NextValueForInvoices").': '; - if ($nextval) - { + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); $htmltooltip.=$nextval.'
'; - } - else - { + } else { $htmltooltip.=$langs->trans($module->error).'
'; } } // Example for remplacement $facture->type=1; $nextval=$module->getNextValue($mysoc,$facture); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=$langs->trans("NextValueForReplacements").': '; - if ($nextval) - { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=$langs->trans("NextValueForReplacements").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } } // Example for credit invoice $facture->type=2; $nextval=$module->getNextValue($mysoc,$facture); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip.=$langs->trans("NextValueForCreditNotes").': '; - if ($nextval) - { + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); $htmltooltip.=$nextval.'
'; - } - else - { + } else { $htmltooltip.=$langs->trans($module->error).'
'; } } // Example for deposit invoice $facture->type=3; $nextval=$module->getNextValue($mysoc,$facture); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip.=$langs->trans("NextValueForDeposit").': '; - if ($nextval) - { + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); $htmltooltip.=$nextval; - } - else - { + } else { $htmltooltip.=$langs->trans($module->error); } } diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index dad5f484a4d..8965b225cfb 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2014 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2011-2013 Philippe Grand * @@ -328,10 +328,16 @@ foreach ($dirmodels as $reldir) $htmltooltip=''; $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval=$module->getNextValue($mysoc,$ficheinter); - if ($nextval != $langs->trans("NotAvailable")) - { - $htmltooltip.=''.$langs->trans("NextValue").': '.$nextval; - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } print '
'; print $form->textwithpicto('',$htmltooltip,1,0); print ''; print $form->textwithpicto('',$htmltooltip,1,0); diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 2f48eb2be79..19b5e89b0dd 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -278,15 +278,13 @@ foreach ($dirmodels as $reldir) $htmltooltip=''; $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval=$module->getNextValue($mysoc,$invoice); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) - { + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); $htmltooltip.=$nextval.'
'; - } - else - { + } else { $htmltooltip.=$langs->trans($module->error).'
'; } } diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 2d4be98f34a..24e1682eb18 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -279,15 +279,13 @@ foreach ($dirmodels as $reldir) $htmltooltip=''; $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval=$module->getNextValue($mysoc,$commande); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) - { + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); $htmltooltip.=$nextval.'
'; - } - else - { + } else { $htmltooltip.=$langs->trans($module->error).'
'; } } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 7517fac7d20..602e308df41 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -608,7 +608,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskraz=-1; $maskoffset=0; $resetEveryMonth=false; - if (dol_strlen($maskcounter) < 3) return 'CounterMustHaveMoreThan3Digits'; + if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; // Extract value for third party mask counter if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef)) @@ -620,7 +620,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskrefclient_clientcode=substr($valueforccc,0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code where n is length in mask $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'CounterMustHaveMoreThan3Digits'; + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; } else $maskrefclient=''; @@ -650,7 +650,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m // Now maskwithnocode = 0000ddmmyyyyccc for example // and maskcounter = 0000 for example //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
"; - //var_dump($reg); + //var_dump($reg); // If an offset is asked if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]); @@ -667,17 +667,16 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) - $maskraz=$yearoffsettype; // For backward compatibility + $maskraz=$yearoffsettype; // For backward compatibility else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) - $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; + $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; //print "maskraz=".$maskraz; // -1=no reset - if ($maskraz > 0) // A reset is required - { - if ($maskraz == 99) { - $maskraz = date('m', $date); - $resetEveryMonth = true; - } + if ($maskraz > 0) { // A reset is required + if ($maskraz == 99) { + $maskraz = date('m', $date); + $resetEveryMonth = true; + } if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; // Define posy, posm and reg @@ -964,7 +963,7 @@ function check_value($mask,$value) $maskcounter=$reg[1]; $maskraz=-1; $maskoffset=0; - if (dol_strlen($maskcounter) < 3) return 'CounterMustHaveMoreThan3Digits'; + if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; // Extract value for third party mask counter if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef)) @@ -976,7 +975,7 @@ function check_value($mask,$value) $maskrefclient_clientcode=substr('',0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'CounterMustHaveMoreThan3Digits'; + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; } else $maskrefclient=''; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 35b7da13728..08b031690b4 100755 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -91,6 +91,8 @@ ErrorModuleSetupNotComplete=Setup of module looks to be uncomplete. Go on Setup ErrorBadMask=Error on mask ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number ErrorBadMaskBadRazMonth=Error, bad reset value +ErrorMaxNumberReachForThisMask=Max number reach for this mask +ErrorCounterMustHaveMoreThan3Digits=Counter must have more than 3 digits ErrorSelectAtLeastOne=Error. Select at least one entry. ErrorProductWithRefNotExist=Product with reference '%s' don't exist ErrorDeleteNotPossibleLineIsConsolidated=Delete not possible because record is linked to a bank transation that is conciliated diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index e880dbdac8d..4f82ea72bca 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -91,6 +91,8 @@ ErrorModuleSetupNotComplete=La configuration du module semble incomplète. Aller ErrorBadMask=Erreur sur le masque ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro +ErrorMaxNumberReachForThisMask=Valeur maximale atteinte pour ce masque +ErrorCounterMustHaveMoreThan3Digits=Le compteur doit avoir plus de 3 chiffres ErrorSelectAtLeastOne=Erreur. Sélectionnez au moins une entrée. ErrorProductWithRefNotExist=La référence produit '%s' n'existe pas ErrorDeleteNotPossibleLineIsConsolidated=Suppression impossible car l'enregistrement porte sur au moins une transaction bancaire rapprochée From b6b84e235c5466fe009c5cbd1c3797c735c60219 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Mon, 12 Jan 2015 10:16:34 +0100 Subject: [PATCH 049/152] Update card.php hide line with empty duration if FICHINTER_HIDE_EMPTY_DURATION is activate --- htdocs/fichinter/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 4ffc31c9cab..ed4ceeb1cf1 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1373,6 +1373,8 @@ else if ($id > 0 || ! empty($ref)) $sql.= ' ft.date as date_intervention'; $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; $sql.= ' WHERE ft.fk_fichinter = '.$object->id; + if (!empty($conf->global->FICHINTER_HIDE_EMPTY_DURATION)) + $sql.= ' AND ft.duree <> 0'; $sql.= ' ORDER BY ft.rang ASC, ft.rowid'; $resql = $db->query($sql); From 26cad2400eea91656650f15169815c4663a7f6cd Mon Sep 17 00:00:00 2001 From: Cedric Date: Mon, 12 Jan 2015 13:18:50 +0100 Subject: [PATCH 050/152] Fix missing lang key --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 9b8f06f262e..bc962c41846 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -258,6 +258,7 @@ days=days Hours=Hours Minutes=Minutes Seconds=Seconds +Weeks=Weeks Today=Today Yesterday=Yesterday Tomorrow=Tomorrow From d2cd841573110cb5a57746ce077aea5cf7890103 Mon Sep 17 00:00:00 2001 From: Cedric Date: Mon, 12 Jan 2015 13:23:18 +0100 Subject: [PATCH 051/152] Fix divide by zero error --- htdocs/cron/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 0a68ca211b9..79306fb1d65 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -354,7 +354,7 @@ if (($action=="create") || ($action=="edit")) print $langs->trans('CronEvery')."
'.$langs->trans("Status").''.$project->getLibStatut(4).' // Date start print '
'.$langs->trans("DateStart").''; -print dol_print_date($object->date_start,'day'); +print dol_print_date($project->date_start,'day'); print '
'.$langs->trans("DateEnd").''; -print dol_print_date($object->date_end,'day'); +print dol_print_date($project->date_end,'day'); print '
'; From 85b1188593201dcfe6c6ca6ecc6e1ee31478c442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 13 Jan 2015 09:22:12 +0100 Subject: [PATCH 055/152] Fix: [ bug #1788 ] Duplicated doActions hook in product/fournisseurs.php --- ChangeLog | 1 + htdocs/product/fournisseurs.php | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b621467312..fd82ace0c20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.6.3 compared to 3.6.2 ***** - Fix: ref_ext was not saved when recording a customer order from web service - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. +- Fix: [ bug #1788 ] Duplicated doActions hook in product/fournisseurs.php ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 527615cc7c4..9999892469d 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -64,10 +64,6 @@ $hookmanager->initHooks(array('pricesuppliercard')); $product = new ProductFournisseur($db); $product->fetch($id,$ref); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks -$error=$hookmanager->error; $errors=$hookmanager->errors; - - $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -81,7 +77,10 @@ if (! $sortorder) $sortorder="ASC"; $parameters=array('socid'=>$socid, 'id_prod'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); + +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if ($action == 'remove_pf') { From 7b4cf976dfa14d08d145e351e204210d831fddeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 13 Jan 2015 09:42:46 +0100 Subject: [PATCH 056/152] Corrected translation typos --- htdocs/langs/en_US/admin.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6e67c9c8765..2aa09fd867d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1014,7 +1014,7 @@ SendingMailSetup=Setup of sendings by email SendmailOptionNotComplete=Warning, on some Linux systems, to send email from your email, sendmail execution setup must contains option -ba (parameter mail.force_extra_parameters into your php.ini file). If some recipients never receive emails, try to edit this PHP parameter with mail.force_extra_parameters = -ba). PathToDocuments=Path to documents PathDirectory=Directory -SendmailOptionMayHurtBuggedMTA=Feature to send mails using method "PHP mail direct" will generate a mail message that might be not correctly parsed by some receiving mail servers. Result is that some mails can't be read by people hosted by thoose bugged platforms. It's case for some Internet providers (Ex: Orange in France). This is not a problem into Dolibarr nor into PHP but onto receiving mail server. You can however add option MAIN_FIX_FOR_BUGGED_MTA to 1 into setup - other to modify Dolibarr to avoid this. However, you may experience problem with other servers that respect strictly the SMTP standard. The other solution (recommanded) is to use the method "SMTP socket library" that has no disadvantages. +SendmailOptionMayHurtBuggedMTA=Feature to send mails using method "PHP mail direct" will generate a mail message that might be not correctly parsed by some receiving mail servers. Result is that some mails can't be read by people hosted by those bugged platforms. It's case for some Internet providers (Ex: Orange in France). This is not a problem into Dolibarr nor into PHP but onto receiving mail server. You can however add option MAIN_FIX_FOR_BUGGED_MTA to 1 into setup - other to modify Dolibarr to avoid this. However, you may experience problem with other servers that respect strictly the SMTP standard. The other solution (recommended) is to use the method "SMTP socket library" that has no disadvantages. TranslationSetup=Configuration de la traduction TranslationDesc=Choice of language visible on screen can be modified:
* Globally from menu Home - Setup - Display
* For user only from tab User display of user card (click on login on top of screen). TotalNumberOfActivatedModules=Total number of activated feature modules: %s @@ -1387,7 +1387,7 @@ AdvancedEditor=Advanced editor ActivateFCKeditor=Activate advanced editor for: FCKeditorForCompany=WYSIWIG creation/edition of elements description and note (except products/services) FCKeditorForProduct=WYSIWIG creation/edition of products/services description and note -FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). Warning: Using this option for this case is seriously not recommanded as it can create problems with special characters and page formating when building PDF files. +FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formating when building PDF files. FCKeditorForMailing= WYSIWIG creation/edition for mass eMailings (Tools->eMailing) FCKeditorForUserSignature=WYSIWIG creation/edition of user signature FCKeditorForMail=WYSIWIG creation/edition for all mail (except Outils->eMailing) From 4da52cf733cdb40cf954195dcd7dacded9964982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 13 Jan 2015 11:11:37 +0100 Subject: [PATCH 057/152] Fix: [ bug #1797 ] Tulip Supplier invoice module takes creation date instead of invoice date --- ChangeLog | 1 + .../modules/supplier_invoice/mod_facture_fournisseur_tulip.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f27b039619a..0b8458a6640 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Fix: Paypal link were broken dur to SSL v3 closed. Fix: [ bug #1769 ] Error when installing to a PostgreSQL DB that contains numbers Fix: [ bug #1752 ] Date filter of margins module, filters since 12H instead of 00H Fix: [ bug #1757 ] Sorting breaks product/service statistics +Fix: [ bug #1797 ] Tulip supplier invoice module takes creation date instead of invoice date ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 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 de8e165b5d4..7d2101575db 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -125,7 +125,8 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices return 0; } - $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->datef); + //Supplier invoices take invoice date instead of creation date for the mask + $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->date); return $numFinal; } From a886136e67eaf0711674583919830aeb9368b3f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Jan 2015 22:13:15 +0100 Subject: [PATCH 058/152] More comment and add a unit test to check that {t} tag is correctly supported. --- htdocs/core/lib/functions2.lib.php | 4 ++-- test/phpunit/NumberingModulesTest.php | 31 ++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 54014d907b1..cd99afaf373 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -628,8 +628,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if (preg_match('/\{(t+)\}/i',$mask,$regType)) { $masktype=$regType[1]; - $masktype_value=substr(preg_replace('/^TE_/','',$objsoc->typent_code),0,dol_strlen($regType[1]));//get n first characters of client code where n is length in mask - $masktype_value=str_pad($masktype_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); + $masktype_value=substr(preg_replace('/^TE_/','',$objsoc->typent_code),0,dol_strlen($regType[1]));// get n first characters of thirdpaty typent_code (where n is length in mask) + $masktype_value=str_pad($masktype_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask } else { diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index a3788b309d1..48d26216268 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -500,7 +500,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $conf->global->SOCIETE_FISCAL_MONTH_START=6; $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}'; $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}'; - + $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year @@ -510,7 +510,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('198001-0001', $result); // counter must start to 1 - + $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year @@ -520,7 +520,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('198001-0002', $result); // counter must start to 2 - + $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); $localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year @@ -530,7 +530,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('198002-0001', $result); // counter must start to 1 - + $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year @@ -540,7 +540,28 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('198101-0001', $result); // counter must start to 1 - + + // Test with {t} tag + $conf->global->SOCIETE_FISCAL_MONTH_START=1; + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{t}{yyyy}{mm}-{0000}'; + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{t}{yyyy}{mm}-{0000}'; + + $tmpthirdparty=new Societe($this->savdb); + $tmpthirdparty->initAsSpecimen(); + $tmpthirdparty->typent_code = 'TE_ABC'; + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1980 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($tmpthirdparty, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('A198201-0001', $result); // counter must start to 1 + + + return $result; } From f92bc7986babac9f25924fca030cde916ece4bfe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jan 2015 10:46:50 +0100 Subject: [PATCH 059/152] Add Weighted average price as default price for buying price for margin calculation. Add option MARGIN_PMP_AS_DEFAULT_BUY_PRICE to replace with first supplier price. --- ChangeLog | 3 ++- htdocs/core/tpl/objectline_create.tpl.php | 3 ++- htdocs/fourn/ajax/getSupplierPrices.php | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7c373ebaaf..3e61b274398 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,7 +8,8 @@ For users: - New: Use new combobox. - New: Add hidden option MAXTABS_IN_CARD. - Fix / Improve : [ bug #1747 ] Remove creation of batch 'Undefined' - +- Add Weighted average price as default price for buying price for margin calculation. Add option + MARGIN_PMP_AS_DEFAULT_BUY_PRICE to replace with first supplier price. For translators: - Update language files. diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index a3cac080ab5..70ac13c79cd 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -483,7 +483,8 @@ jQuery(document).ready(function() { } if (this.id == 'pmpprice') { - if (this.price > 0 && 1 == 1) { defaultkey = this.id; defaultprice = this.price; } + var defaultbuyprice = global->MARGIN_PMP_AS_DEFAULT_BUY_PRICE)?int($conf->global->MARGIN_PMP_AS_DEFAULT_BUY_PRICE):1); ?>; + if (this.price > 0 && 1 == defaultbuyprice) { defaultkey = this.id; defaultprice = this.price; } options += ''; } }); diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 907e34f8d35..e14e872a24f 100755 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -28,6 +28,7 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $idprod=GETPOST('idprod','int'); @@ -43,8 +44,11 @@ top_httphead(); //print ''."\n"; -if (! empty($idprod)) +if ($idprod > 0) { + $producttmp=new ProductFournisseur($db); + $producttmp->fetch($idprod); + $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,"; $sql.= " pfp.ref_fourn,"; $sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice, pfp.charges, pfp.unitcharges,"; @@ -111,6 +115,7 @@ if (! empty($idprod)) if ($objp->duration) $label .= " - ".$objp->duration; $label = price($price,0,$langs,0,0,-1,$conf->currency)."/".$langs->trans("Unit"); + if ($objp->ref_fourn) $label.=' ('.$objp->ref_fourn.')'; $prices[] = array("id" => $objp->idprodfournprice, "price" => price($price,0,'',0), "label" => $label, "title" => $title); $i++; @@ -121,9 +126,8 @@ if (! empty($idprod)) } // Add price for pmp - $price=123; + $price=$producttmp->pmp; $prices[] = array("id" => 'pmpprice', "price" => $price, "label" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency)); - } echo json_encode($prices); From 806477977d0ccdf68723960fbdf5547d5f07edb3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jan 2015 13:51:21 +0100 Subject: [PATCH 060/152] Fix: css --- htdocs/comm/action/peruser.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/theme/eldy/img/menus/README.md | 12 +++++++++ htdocs/theme/eldy/img/menus/chart.png | Bin 0 -> 1792 bytes htdocs/theme/eldy/style.css.php | 34 ++++++------------------ 5 files changed, 22 insertions(+), 28 deletions(-) create mode 100644 htdocs/theme/eldy/img/menus/README.md create mode 100644 htdocs/theme/eldy/img/menus/chart.png diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 22cf8841c02..8379960f764 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -679,7 +679,7 @@ foreach ($usernames as $username) { $var = ! $var; echo ""; - echo '' . $username->getNomUrl(1). ''; + echo '' . $username->getNomUrl(1). ''; $tmpday = $sav; // Lopp on each day of week diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 74d6b95df73..8ae46c5d8da 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -354,7 +354,7 @@ function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, if ($showmode == 1) { print '
'; - print '
'; + print '
'; print '
'; print ''; print ''; diff --git a/htdocs/theme/eldy/img/menus/README.md b/htdocs/theme/eldy/img/menus/README.md new file mode 100644 index 00000000000..1b3942d1913 --- /dev/null +++ b/htdocs/theme/eldy/img/menus/README.md @@ -0,0 +1,12 @@ + +Tutorial to create a new image for menu: + +1) First find an image. +2) With Gimp, open image and check there is a alpha channel. If not add one. +3) Convert image into back and white. +4) Use the degrade tool with option: +* Erase color +* Opacity: 50 +/- +* Offset: 0 +* Shape: Linear +Il est possible aussi d'augmenter la transparence globale depuis le calque. diff --git a/htdocs/theme/eldy/img/menus/chart.png b/htdocs/theme/eldy/img/menus/chart.png new file mode 100644 index 0000000000000000000000000000000000000000..abd089a44bea64e7880045b878c0392e57802c59 GIT binary patch literal 1792 zcmV+b2mknqP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2j2k> z3M&R+hlf)D00w|bL_t(o!_ArBixk-v$G_*^s#{gV^r+DuXBZtB96K?Sbps&}8%$s^ zK_MC;2#fd!H2{l850Q|N7u}cmTkxW zRn_&Qt4&K2AV+?rEMiYv~qBS=+_r7i0KM8{1TbiapDFwqYpzAtxT?Y|; zYTNd2EX(>c0PnvocvM~cN_)i4Y+8Vy*M1u11xJR61qA;hWS;o(!wX7kH1 z3`Ym$d2NI9`qLdLclN#l2QTyEX(4(d-vv_J$q&V@ZJRR z;MGAygvrTC95`?Ql}ZJRi;HX+2AQS_r4*PsM$mgxJfAiM%#4wd5n^WYeILw>D2i4S zhzJ1Q9M5+eVHkqBdtTnSabv&ZIQv}J-4{jC6K4M6!i5W84y4*J^X^)$wgf<>&#kPi zpw()v`ArCcCr_U2o1dR=5Yc;46#bByf8_f#hP^hSw) z{P;0Fefo64ah!>EQbX5u)-;VYO@j~unx@@TN`1!6zc_vRG!Gn`PWI+s`a70o z!8A<>A;ySk48ZrLl&9|Az57tt^$$;;JUP4V%nKpb)%vVl==2wR_U!R92P&2DaBIC4O@=BRGUsHb;BkM!*aT8cXPk>*52fd%@AcZ^H^V%D zp118gK}6Wi^V@>WMuw%5bI&GnU}v{#)0c$JVme_!tJgJw zh-w=N?He{(tpNb5SHy@Y>V!xlam9Y`+BTQXGT_WcszH3RL zotnHgk?JP?=FOYCvgX7>ewk7fB&YdeUv&^{Z zI>r;88d`5FWf{Oi2q!UTjp!(f5Jk~k6h;4jorI-c6So}!Eh~4@87qXKmoHz2wOXw) zGBPsUjvzIgO{djreI}*+G>W2s+P3|#*C~~pWk7m$O^kAy(+uq(A~=qNa=H9Y5ClJt zqUdeMasCx#|o+qZQgM5`0C8Q3s@oUZH1Jm46MBtBsnLI^Q( z@ZiCRSFT+7rR%yMT)TGd*E@Iayw{8Ho*r_8APB|!I>+^To!Vk4>CM^MS&~vNO-xLT z=kxj1-3HHl^-|V#-Da!R`aOV8N~O}hqeqW!`CWc5%!_QARy~@=#xzYVEG!(iZTovm zOG{s$oSgh7fbR$)K4~_acZCptcO0j3MPfbmsP$*#6u3how*(=^X&vTji zqe`XnTL3cokkQXUUBpxS{UMZ6IU&S1i0G}Usi~R$`}hCAG|jL2zW=9cwR-*V;lsZx il}a==Ha5^*@c#pOvA2INX1v${0000 div#tmenu_tooltip { @@ -673,7 +673,7 @@ div.mainmenu { position : relative; background-repeat:no-repeat; background-position:center top; - height: px; + height: px; margin-left: 0px; min-width: 40px; } @@ -698,16 +698,10 @@ div.mainmenu.bank { background-image: url(); } -div.mainmenu.bookmark { -} - div.mainmenu.cashdesk { background-image: url(); } -div.mainmenu.click2dial { -} - div.mainmenu.companies { background-image: url(); } @@ -728,12 +722,6 @@ div.mainmenu.ftp { background-image: url(); } -div.mainmenu.gravatar { -} - -div.mainmenu.geopipmaxmind { -} - div.mainmenu.hrm { background-image: url(); } @@ -742,9 +730,6 @@ div.mainmenu.members { background-image: url(); } -div.mainmenu.paypal { -} - div.mainmenu.products { background-image: url(); margin-left: 10px; @@ -758,14 +743,6 @@ div.mainmenu.tools { background-image: url(); } -div.mainmenu.webservices { -} - -div.mainmenu.google { - background-image: url(); -} - - 'name of class for div') @@ -2423,6 +2400,11 @@ li.cal_event { border: none; list-style-type: none; } .cal_event a:active { color: #111111; font-size: 11px; font-weight: normal !important; } .cal_event a:hover { color: #111111; font-size: 11px; font-weight: normal !important; color:rgba(255,255,255,.75); } .cal_event_busy { } +.cal_peruserviewname { max-width: 100px; height: 22px; } + +.topmenuimage { + background-size: 28px auto; +} /* ============================================================================== */ /* Ajax - Liste deroulante de l'autocompletion */ From e10b5637d46012eb22730961eb816ad98536da9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jan 2015 18:54:56 +0100 Subject: [PATCH 061/152] Fixed: Avoid spaces into address string --- htdocs/core/lib/functions.lib.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 990c30c0f60..511cee34d62 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -749,10 +749,13 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p $displaytab=$i; } + $out.="
\n"; + if ($displaytab > $limittoshow) { - $out.='
Plus'; - $out.='
'.$outmore.'
'; + $out.='
'; + $out.=''.$langs->trans("More").'...'; + $out.='
'.$outmore.'
'; $out.="
\n"; $out.=""; } + $out.="
\n"; + if (! $notab) $out.="\n".'
'."\n"; return $out; From 1d1970b5a1c23fd3ac9003f31198c13803b29429 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jan 2015 19:10:48 +0100 Subject: [PATCH 063/152] Sec: Bad security test --- htdocs/public/test/test_arrays.php | 7 +++++-- htdocs/public/test/test_forms.php | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 6725c776cd4..5ff161f0b1a 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -4,11 +4,14 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site. require '../../main.inc.php'; -if ($_SERVER['HTTP_HOST'] != 'localhost') + +if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') { - print "Page available only with url http://localhost/..."; + print "Page available only frome remote address 127.0.0.1"; exit; } + + $usedolheader=0; // 1 = Test inside a dolibarr page, 0 = Use hard coded header diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index 55b8296e43a..ece0c218160 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -6,9 +6,9 @@ define('REQUIRE_JQUERY_MULTISELECT','select2'); require '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if ($_SERVER['HTTP_HOST'] != 'localhost') +if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') { - print "Page available only with url http://localhost/..."; + print "Page available only frome remote address 127.0.0.1"; exit; } From e3f3956bedaa6022773e168cd2f1fd87218af357 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jan 2015 19:10:48 +0100 Subject: [PATCH 064/152] Sec: Bad security test --- htdocs/public/test/test_arrays.php | 7 +++++-- htdocs/public/test/test_forms.php | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 6725c776cd4..5ff161f0b1a 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -4,11 +4,14 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site. require '../../main.inc.php'; -if ($_SERVER['HTTP_HOST'] != 'localhost') + +if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') { - print "Page available only with url http://localhost/..."; + print "Page available only frome remote address 127.0.0.1"; exit; } + + $usedolheader=0; // 1 = Test inside a dolibarr page, 0 = Use hard coded header diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index c600e9b0acd..deb3e2fe0c4 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -6,9 +6,9 @@ define('REQUIRE_JQUERY_MULTISELECT','select2'); require '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if ($_SERVER['HTTP_HOST'] != 'localhost') +if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') { - print "Page available only with url http://localhost/..."; + print "Page available only frome remote address 127.0.0.1"; exit; } From 4c64b8ceae276cee0f9953450de52a4d4ff67788 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jan 2015 19:12:22 +0100 Subject: [PATCH 065/152] Add menu image --- htdocs/theme/eldy/img/menus/chart.png | Bin 1792 -> 1321 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/htdocs/theme/eldy/img/menus/chart.png b/htdocs/theme/eldy/img/menus/chart.png index abd089a44bea64e7880045b878c0392e57802c59..6efce90a78859b6f4649304a8481fd193e6cb609 100644 GIT binary patch delta 1253 zcmV zzjdnePE0}&d;~#6j82@0MEnB|L_~1v#NXhbaW2lCWZ*zh6v2TKFc1uC3`QjnB8f?- z>)x{*WS`FNo7-KLPFV?<3q?WIsaxypz1G@$p9_z#$JhVs(xMA%twmA+j@y18ct?NI zMc`xGUrFjD)kh9|t@Vhcw}AJ67eL+N@0YTE(0y%e7{%1l;8o9UvImt@lW6WU!I_@%}RK25=IXO8T|d`UP;NlyYU2;QRF2 zZih(vtJeAv@H%h^IB46Fo|p6*@SE*#fm4#Mtcvq}66IFHuC~`Cy<+=VWMoZu1cRgl zzzN`0+dl)}{O8~$^}&13S=t3qheld9tj#_WKQDlfHmN4-~(Wfq&I;Jz**pH+vkAw z?KZJ6_yE(-snA*2-2iwQSg&nA9rQA=7kDXNCxP#5e+pcCV8Lz?c@1e3RB7UN`n|KT zV}omPU#ELW(v!f8k`6yG_!fWl5aK-AEq-!dXU*D4#} z$iODf4_b>^*yiB|G#9*ZsJR+jD)=VSq>m<2+g8p{qE8q1E+e&NIc~FsU`J__>q7H+ zpd=d9=v3Dmg(Q{KBaKmQ$3?0Rg|%JeBSUrI^G>wsY)_juA}A$ueqMi|c0wD^tHi%KgZHK6vEQ&Fcd6Y8>CFuqoo1^OGoOU3R8{BQ3S7tYh|-=@64t zA9Tppm)n~Tn8hag_?=QO#3GqqxG`%*YM#$GiX|F&q@eZTKE0&2wlv`JUYF_f^8~Bl z`tDfQCz`ZbH+P?tq>q0ZV$W{VFU4(!zC9d31`U@+8nYq2dfT@fZ6X62ak%AJWenD% zv`L>e7wHC@^?){A6eZ^-E@j5c7VPLSk~b58*TZS<5$s^N>C-0rfuOxK+O(oEuQ3b$ zPEw{Ezfp1#f+mwRam@yq@zMlqd$wSa>Y^rWcz1J;kp`|yR=IzvqPBr%S)4CGo08Zj zB5j7PvA#u7BjBegTjW9&PE_X|M=l!q_3&d4c|LR{+wG6rDchJ}`)G^X$#Tu}t)z9} zJaBzkjakhnX4{-HG<|dzzJPnJxglv`%p_hi*Cv zOLON`(vP;!1N&_6m$WZH|GmtoCX0YSE@}Vp=p+1F$$?Rd?MZ5`ZU8qP+WEZg-N4c2 z+2Qx?5NQ*afyy{D6rKp}q$D+XYPhf@Fm27pOKK~z}7&6(ee6xkKW zzvtenTUEpKsL>v07#$fLJ28`W10fF^OkgoVAsQhFi}(_<5Z@O42Lirj$%BL}tRMy= z=n~?Oz=jZ5f)8QAhr}Tn6A2wh*UXQWZO8sq)%ByRP9CO9YHF%`ddBI-3q{jix4M76 z=bX&K2AV+?rEMiYv~ zqBS=+_r7i0KM8{1TbiapDFwqYpzAtxT?Y|;YTNd2EX(>c0PnvocvM~cN_ z)i4Y+8Vy*M1u11xJR61qA;hWS;o*N%&1UnSTH_5u7zPp3kwS< zl}cb{7DB)<43bg;04&Smy?giOpFMkK0Px-f@!-`#M1;x7NgOzE0F_Dwi;IhF7zUZ9 z38fU6IY!WXQ#_wG1k8+)kr85M@_ir7j3|m$6Nm@^-W<<&8etfMxqDvTxN(1DzvDRj zT-V(fMbQ&x{^G)g3ttYT+A#C(TCKJOK&8*EtgN8bYOVQA2!SV0p6r{SpKlP+dr=hq zkePqv`#v;HTTx2gF%07mL{uymi~qfJ=~DDYiGTd~F+F|ybir|)iFQ&$*LBu3jWkVz z5CWQ}-BU_^#>~Gsefl&H9Gibm_U3Xq96EGpqF%3av)Lri^H?cGnx;Y1G`1{@lv3|1 zrQTgxS@{sa;KjF-GaV@!9v+s3LIKTYld9D!8jS|k>vaY|hGCFpSx`zr2!U#~ssZo^ zj!mUfK@bFMDv=NZwr%U9qoV;4AwFKbco8~|BXwP0ljMtwi(+|s`73`?%JaVOk1D0^ zyRQ5B`Sa)h*LQ4^-j9XG4vEVu0GOspzVE*(sd0YTw#}aB{oFLo4@}d9Wm)g-*ss`a70o!8A<>A;ySk48ZrLl&9|Az57tt z^$$;;JUP4V%nKpb)%t&|T=luo1 zY+n*KjZQa1(_{DU-Bc(P^3`gU9zA*#GPBI(a!^V^O36Y93d2xs8JljNB%(E*PbO&+ zm8}0DqPTPxEX#uHxoI$hI=y35QJ>UQT|OQm%_wmeHHSCM%TPu*qV+!`xiDH%iZqA9l8l`Hj5W z%QbD0^;81)gxjXD*{I?qJs01s$M6rO=cMoT+Tu6EJbuxl5N63(RQ7^ptTd zgrF=DL^PBT9%ii(TTWOavU@3&u@UVfOkG1=BIhK&Ye|2hotnHgk?JP?=FOYCvgX7> zewk7fB&YdeUv&^{ZI>r;88d`5FWf{Oi2q!UT zjp!(f5Jk~k6h;4jorI-c6So}!Eh~4@87qXKmoHz2wOXw)GBPsUjvzIgO{djreI}*+ zG>W2s+O~iFuh%J+oMk|Ibxn+Nn$ryJAR;)9gL1k2P7nk?j-u#o$8r7|1i?Sb zL)U+GieZ{?W@dT+{{7_#4<3w9O--RtC}7vFUGe7GE8acNbD8<0N~Q8!05bWI(a%9$ z#8dnIA(T=%A;dR`=&h-#shR!z_y52&&95x_zW=9cwR-*V;lsZxl}a==Ha5^*@c#pO WvA2INX1v${0000 Date: Wed, 14 Jan 2015 19:17:58 +0100 Subject: [PATCH 066/152] Fixed: Avoid space into address string --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dcb76a10cd7..3ec602c9d2b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -800,7 +800,7 @@ function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='') else if (in_array($object->country_code,array('ES','TR'))) // ES: title firstname name \n address lines \n zip town \n state \n country { $ret .= ($ret ? $sep : '' ).$object->zip; - $ret .= ' '.$object->town; + $ret .= ($object->town?' '.$object->town:''); if ($object->state && in_array($object->country_code,$countriesusingstate)) { $ret.="\n".$object->state; @@ -810,14 +810,14 @@ function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='') else // Other: title firstname name \n address lines \n zip town \n country { $ret .= ($ret ? $sep : '' ).$object->zip; - $ret .= ' '.$object->town; + $ret .= ($object->town?' '.$object->town:''); if ($object->state && in_array($object->country_code,$countriesusingstate)) { $ret.=", ".$object->state; } } if (! is_object($outputlangs)) $outputlangs=$langs; - if ($withcountry) $ret.=($object->country_code?$sep.$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):''); + if ($withcountry) $ret.=($object->country_code?($ret?$sep:'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):''); return $ret; } From ba49cce47a9e62c930021bd5f7705e40bd6aecf2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jan 2015 02:06:04 +0100 Subject: [PATCH 067/152] Fix: The filter into event views on user must be done on assigned resource, not only owner. --- htdocs/comm/action/class/actioncomm.class.php | 3 + htdocs/comm/action/index.php | 38 ++++---- htdocs/comm/action/listactions.php | 95 +++++-------------- htdocs/comm/action/peruser.php | 37 ++++---- htdocs/core/lib/agenda.lib.php | 2 +- .../install/mysql/migration/3.6.0-3.7.0.sql | 3 + .../tables/llx_actioncomm_resources.key.sql | 2 +- htdocs/install/upgrade2.php | 80 ++++++++++++++++ htdocs/langs/en_US/install.lang | 1 + 9 files changed, 146 insertions(+), 115 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 135b775249b..bf668be6daa 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -141,6 +141,9 @@ class ActionComm extends CommonObject $userownerid=$this->userownerid; $userdoneid=$this->userdoneid; + // Be sure assigned user array is not empty. + if (count($this->userassigned) == 0) $this->userassigned = array('id'=>$this->$userownerid); + if (! $this->type_id || ! $this->type_code) { $key=empty($this->type_id)?$this->type_code:$this->type_id; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 4630d486ebf..7820de113b7 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -40,9 +40,7 @@ if (! empty($conf->projet->enabled)) { if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; $filter=GETPOST("filter",'',3); -$filtera = GETPOST("userasked","int",3)?GETPOST("userasked","int",3):GETPOST("filtera","int",3); $filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3); -$filterd = GETPOST("userdone","int",3)?GETPOST("userdone","int",3):GETPOST("filterd","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -72,9 +70,7 @@ if (! $user->rights->agenda->myactions->read) accessforbidden(); if (! $user->rights->agenda->allactions->read) $canedit=0; if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me { - $filtera=$user->id; $filtert=$user->id; - $filterd=$user->id; } $action=GETPOST('action','alpha'); @@ -283,9 +279,7 @@ $param=''; if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode; if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status; if ($filter) $param.="&filter=".$filter; -if ($filtera) $param.="&filtera=".$filtera; if ($filtert) $param.="&filtert=".$filtert; -if ($filterd) $param.="&filterd=".$filterd; if ($socid) $param.="&socid=".$socid; if ($showbirthday) $param.="&showbirthday=1"; if ($pid) $param.="&projectid=".$pid; @@ -340,7 +334,7 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param); $head = calendars_prepare_head($paramnoaction); dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); -print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$action,$listofextcals,$actioncode,$usergroup); +print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,$listofextcals,$actioncode,$usergroup); dol_fiche_end(); $showextcals=$listofextcals; @@ -405,27 +399,29 @@ print_fiche_titre($s,$link.'     '.$nav, ''); // Get event in an array $eventarray=array(); -$sql = 'SELECT a.id,a.label,'; +$sql = 'SELECT '; +if ($usergroup > 0) $sql.=" DISTINCT"; +$sql.= ' a.id, a.label,'; $sql.= ' a.datep,'; $sql.= ' a.datep2,'; -$sql.= ' a.datea,'; -$sql.= ' a.datea2,'; $sql.= ' a.percent,'; -$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,'; +$sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; $sql.= ' a.fk_soc, a.fk_contact,'; $sql.= ' ca.code as type_code, ca.libelle as type_label'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; -if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu"; +// We must filter on assignement table +if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $sql.= ' WHERE a.fk_action = ca.id'; $sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; if ($actioncode) $sql.=" AND ca.code='".$db->escape($actioncode)."'"; if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid; -// FIXME: We must filter on assignement table -if ($usergroup > 0) $sql.= " AND ugu.fk_user = a.fk_user_action"; +// We must filter on assignement table +if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { $sql.= " AND ("; @@ -459,14 +455,12 @@ if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; } if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; } -// FIXME: We must filter on assignement table -if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0) +// We must filter on assignement table +if ($filtert > 0 || $usergroup > 0) { $sql.= " AND ("; - if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera; - if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert; - if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd; - if ($usergroup > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; + if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; $sql.= ")"; } // Sort on date @@ -1094,7 +1088,7 @@ $db->close(); function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60) { global $user, $conf, $langs; - global $action, $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form + global $action, $filter, $filtert, $status, $actioncode; // Filters used into search form global $theme_datacolor; global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused; @@ -1383,7 +1377,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa { print ''.img_picto("all","1downarrow_selected.png").' ...'; print ' +'.(count($eventarray[$daykey])-$maxprint); diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index a53628e3d31..b8c913df271 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; +$langs->load("users"); $langs->load("companies"); $langs->load("agenda"); $langs->load("commercial"); @@ -52,9 +53,7 @@ if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $s if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); $filter=GETPOST("filter",'',3); -$filtera = GETPOST("userasked","int",3)?GETPOST("userasked","int",3):GETPOST("filtera","int",3); $filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3); -$filterd = GETPOST("userdone","int",3)?GETPOST("userdone","int",3):GETPOST("filterd","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -94,9 +93,7 @@ if (! $user->rights->agenda->myactions->read) accessforbidden(); if (! $user->rights->agenda->allactions->read) $canedit=0; if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permission to see all, we show only affected to me { - $filtera=$user->id; $filtert=$user->id; - $filterd=$user->id; } // Purge search criteria @@ -133,15 +130,14 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) */ $form=new Form($db); +$userstatic=new User($db); $nav=''; $nav.='   '; if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $nav.=''; if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav.=''; if ($filter) $nav.=''; -if ($filtera) $nav.=''; if ($filtert) $nav.=''; -if ($filterd) $nav.=''; if ($socid) $nav.=''; if ($showbirthday) $nav.=''; if ($pid) $nav.=''; @@ -163,65 +159,57 @@ $param=''; if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode; if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status; if ($filter) $param.="&filter=".$filter; -if ($filtera) $param.="&filtera=".$filtera; if ($filtert) $param.="&filtert=".$filtert; -if ($filterd) $param.="&filterd=".$filterd; if ($socid) $param.="&socid=".$socid; if ($showbirthday) $param.="&showbirthday=1"; if ($pid) $param.="&projectid=".$pid; if ($type) $param.="&type=".$type; if ($usergroup) $param.="&usergroup=".$usergroup; -$sql = "SELECT s.nom as societe, s.rowid as socid, s.client,"; -$sql.= " a.id, a.datep as dp, a.datep2 as dp2,"; -$sql.= " a.fk_contact, a.note, a.label, a.percent as percent,"; +$sql = "SELECT"; +if ($usergroup > 0) $sql.=" DISTINCT"; +$sql.= " s.nom as societe, s.rowid as socid, s.client,"; +$sql.= " a.id, a.label, a.datep as dp, a.datep2 as dp2,"; +$sql.= ' a.fk_user_author,a.fk_user_action,'; +$sql.= " a.fk_contact, a.note, a.percent as percent,"; $sql.= " c.code as type_code, c.libelle as type_label,"; -$sql.= " ua.login as loginauthor, ua.rowid as useridauthor,"; -$sql.= " ut.login as logintodo, ut.rowid as useridtodo,"; -//$sql.= " ud.login as logindone, ud.rowid as useriddone,"; $sql.= " sp.lastname, sp.firstname"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c,"; -$sql.= " ".MAIN_DB_PREFIX.'user as u,'; -$sql.= " ".MAIN_DB_PREFIX."actioncomm as a"; +$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON a.fk_user_author = ua.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ut ON a.fk_user_action = ut.rowid"; -//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ud ON a.fk_user_done = ud.rowid"; -if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu"; +// We must filter on assignement table +if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $sql.= " WHERE c.id = a.fk_action"; -$sql.= ' AND a.fk_user_author = u.rowid'; $sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; if ($actioncode) $sql.=" AND c.code='".$db->escape($actioncode)."'"; if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if ($socid > 0) $sql.= " AND s.rowid = ".$socid; -// FIXME: We must filter on assignement table -if ($usergroup > 0) $sql.= " AND ugu.fk_user = a.fk_user_action"; +// We must filter on assignement table +if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($type) $sql.= " AND c.id = ".$type; if ($status == '0') { $sql.= " AND a.percent = 0"; } if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; } if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; } -// FIXME: We must filter on assignement table -if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0) +// We must filter on assignement table +if ($filtert > 0 || $usergroup > 0) { $sql.= " AND ("; - if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera; - if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert; - if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd; - if ($usergroup > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; + if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; $sql.= ")"; } + // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) if ($dateselect > 0) $sql.= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect-3600)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."'))"; if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'"; if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1, $offset); - //print $sql; dol_syslog("comm/action/listactions.php", LOG_DEBUG); @@ -246,7 +234,7 @@ if ($resql) $head = calendars_prepare_head($param); dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); - print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$action,-1,$actioncode,$usergroup); + print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,-1,$actioncode,$usergroup); dol_fiche_end(); // Add link to show birthdays @@ -275,14 +263,11 @@ if ($resql) print ''; print ''; print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"ut.login",$param,"","",$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("DoneBy"),$_SERVER["PHP_SELF"],"ud.login",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder); print "\n"; @@ -375,46 +360,16 @@ if ($resql) } print ''; - // User author - /* - print ''; - */ - // User to do print ''; - // User did - /* - print ''; - */ - // Status/Percent print ''; @@ -434,6 +389,6 @@ else } -$db->close(); - llxFooter(); + +$db->close(); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 8379960f764..04353190adb 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -39,9 +39,7 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; $filter=GETPOST("filter",'',3); -$filtera = GETPOST("userasked","int",3)?GETPOST("userasked","int",3):GETPOST("filtera","int",3); $filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3); -$filterd = GETPOST("userdone","int",3)?GETPOST("userdone","int",3):GETPOST("filterd","int",3); $usergroup = GETPOST("usergroup","int",3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -73,9 +71,7 @@ if (! $user->rights->agenda->myactions->read) accessforbidden(); if (! $user->rights->agenda->allactions->read) $canedit=0; if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me { - $filtera=$user->id; $filtert=$user->id; - $filterd=$user->id; } //$action=GETPOST('action','alpha'); @@ -130,6 +126,7 @@ if (GETPOST('viewday') || $action == 'show_day') { } // View by day +$langs->load("users"); $langs->load("agenda"); $langs->load("other"); $langs->load("commercial"); @@ -198,9 +195,7 @@ $param=''; if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode; if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status; if ($filter) $param.="&filter=".$filter; -if ($filtera) $param.="&filtera=".$filtera; if ($filtert) $param.="&filtert=".$filtert; -if ($filterd) $param.="&filterd=".$filterd; if ($usergroup) $param.="&usergroup=".$usergroup; if ($socid) $param.="&socid=".$socid; if ($showbirthday) $param.="&showbirthday=1"; @@ -280,7 +275,7 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param); $head = calendars_prepare_head($paramnoaction); dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); -print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup); +print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup); dol_fiche_end(); $showextcals=$listofextcals; @@ -332,27 +327,29 @@ print_fiche_titre($s,$link.'     '.$nav, ''); // Get event in an array $eventarray=array(); -$sql = 'SELECT a.id,a.label,'; +$sql = 'SELECT'; +if ($usergroup > 0) $sql.=" DISTINCT"; +$sql.= ' a.id, a.label,'; $sql.= ' a.datep,'; $sql.= ' a.datep2,'; -$sql.= ' a.datea,'; -$sql.= ' a.datea2,'; $sql.= ' a.percent,'; -$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,'; +$sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; $sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,'; $sql.= ' ca.code, ca.color'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; -if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu"; +// We must filter on assignement table +if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $sql.= ' WHERE a.fk_action = ca.id'; $sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; if ($actioncode) $sql.=" AND ca.code='".$db->escape($actioncode)."'"; if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid; -// FIXME: We must filter on assignement table -if ($usergroup > 0) $sql.= " AND ugu.fk_user = a.fk_user_action"; +// We must filter on assignement table +if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { $sql.= " AND ("; @@ -386,14 +383,12 @@ if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; } if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; } -// FIXME: We must filter on assignement table -if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0) +// We must filter on assignement table +if ($filtert > 0 || $usergroup > 0) { $sql.= " AND ("; - if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera; - if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert; - if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd; - if ($usergroup > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; + if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; $sql.= ")"; } // Sort on date @@ -809,7 +804,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & { global $db; global $user, $conf, $langs, $hookmanager, $action; - global $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form + global $filter, $filtert, $status, $actioncode; // Filters used into search form global $theme_datacolor; // Array with a list of different we can use (come from theme) global $cachethirdparties, $cachecontacts, $colorindexused; global $begin_h, $end_h; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 23a17534ccf..80e556378c0 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -70,7 +70,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh { print ''; print ''; } +/** + * Migrate event assignement to owner + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void + */ +function migrate_event_assignement($db,$langs,$conf) +{ + print ''; +} + /** * Migration directory * diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 20abe7b9c70..c296bd788e8 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -206,6 +206,7 @@ MigrationProjectTaskTime=Update time spent in seconds MigrationActioncommElement=Update data on actions MigrationPaymentMode=Data migration for payment mode MigrationCategorieAssociation=Migration of categories +MigrationEvents=Migration of events to add event owner into assignement table ShowNotAvailableOptions=Show not available options HideNotAvailableOptions=Hide not available options \ No newline at end of file From ccfbd3614e6bdfe07999e3a66e5d3a92725e190d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jan 2015 02:09:28 +0100 Subject: [PATCH 068/152] Not nice looking --- htdocs/societe/soc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 1a936db37fb..72e249ce542 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1754,7 +1754,8 @@ else print ''; // Zip / Town diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3ec602c9d2b..cdb7e2b4d78 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4574,6 +4574,7 @@ function dol_eval($s,$returnvalue=0) global $leftmenu; global $rights; global $object; + global $soc; //print $s."
\n"; if ($returnvalue) return @eval('return '.$s.';'); diff --git a/htdocs/societe/info.php b/htdocs/societe/info.php index 305936e6f56..9d06d203d9c 100644 --- a/htdocs/societe/info.php +++ b/htdocs/societe/info.php @@ -59,21 +59,21 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); -$soc = new Societe($db); -$soc->fetch($socid); -$soc->info($socid); +$object = new Societe($db); +$object->fetch($socid); +$object->info($socid); /* * Affichage onglets */ -$head = societe_prepare_head($soc); +$head = societe_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("ThirdParty"),0,'company'); print '
'; - if ($obj->useridauthor) - { - $userstatic=new User($db); - $userstatic->id=$obj->useridauthor; - $userstatic->login=$obj->loginauthor; - print $userstatic->getLoginUrl(1); - } - else print ' '; - print ''; - if ($obj->useridtodo) + if ($obj->fk_user_action > 0) { - $userstatic=new User($db); - $userstatic->id=$obj->useridtodo; - $userstatic->login=$obj->logintodo; + $userstatic->fetch($obj->fk_user_action); print $userstatic->getLoginUrl(1); } else print ' '; print ''; - if ($obj->useriddone) - { - $userstatic=new User($db); - $userstatic->id=$obj->useriddone; - $userstatic->login=$obj->logindone; - print $userstatic->getLoginUrl(1); - } - else print ' '; - print ''.$actionstatic->LibStatut($obj->percent,6).'
'; - print $langs->trans("ActionsOwnedBy").'   '; + print $langs->trans("ActionsToDoBy").'   '; print ''; print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit); if (empty($conf->dol_optimize_smallscreen)) print '   '.$langs->trans("or") . ' '.$langs->trans("Group").'   '; diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index ad05f850e16..7dbdb7eb7dc 100755 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -153,6 +153,9 @@ ALTER TABLE llx_projet_task_time ADD COLUMN task_datehour datetime after task_da ALTER TABLE llx_actioncomm_resources CHANGE COLUMN transparent transparency smallint default 1; +ALTER TABLE llx_actioncomm_resources DROP INDEX idx_actioncomm_resources_idx1; +ALTER TABLE llx_actioncomm_resources ADD UNIQUE INDEX uk_actioncomm_resources(fk_actioncomm, element_type, fk_element); + -- Localtaxes by thirds ALTER TABLE llx_c_tva MODIFY COLUMN localtax1 varchar(10); diff --git a/htdocs/install/mysql/tables/llx_actioncomm_resources.key.sql b/htdocs/install/mysql/tables/llx_actioncomm_resources.key.sql index caaa0969944..8c7bb4ad237 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm_resources.key.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm_resources.key.sql @@ -18,7 +18,7 @@ -- ============================================================================ -ALTER TABLE llx_actioncomm_resources ADD UNIQUE INDEX idx_actioncomm_resources_idx1 (fk_actioncomm, element_type, fk_element); +ALTER TABLE llx_actioncomm_resources ADD UNIQUE INDEX uk_actioncomm_resources(fk_actioncomm, element_type, fk_element); ALTER TABLE llx_actioncomm_resources ADD INDEX idx_actioncomm_resources_fk_element (fk_element); -- Pas de contrainte sur fk_source et fk_target car pointe sur differentes tables diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 57004f3cb16..86ab911c71b 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -362,6 +362,8 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) $beforeversionarray=explode('.','3.7.9'); // target is before this if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) { + migrate_event_assignement($db,$langs,$conf); + // Reload modules (this must be always and only into last targeted version) $listofmodule=array( 'MAIN_MODULE_AGENDA', @@ -391,6 +393,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) $db->commit(); $db->close(); + // Actions for all version (not in database) migrate_delete_old_files($db,$langs,$conf); @@ -3519,6 +3522,83 @@ function migrate_categorie_association($db,$langs,$conf) print '
'; + + print '
'; + print ''.$langs->trans('MigrationEvents')."
\n"; + + $error = 0; + + dolibarr_install_syslog("upgrade2::migrate_event_assignement"); + + $db->begin(); + + $sqlSelect = "SELECT a.id, a.fk_user_action"; + $sqlSelect.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action"; + $sqlSelect.= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')"; + $sqlSelect.= " ORDER BY a.id"; + //print $sqlSelect; + + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; + $sqlUpdate.= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")"; + + $result=$db->query($sqlUpdate); + if (! $result) + { + $error++; + dol_print_error($db); + } + print ". "; + $i++; + } + } + else + { + print $langs->trans('AlreadyDone')."
\n"; + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db); + $db->rollback(); + } + + + print '
'.$langs->trans("Country").''; if (! empty($object->country_code)) { - $img=picto_from_langcode($object->country_code); + //$img=picto_from_langcode($object->country_code); + $img=''; if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0); else print ($img?$img.' ':'').$object->country; } From 4d67e6f4d41611b3ceb2d3f73cce6aff9e1bd59d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jan 2015 02:11:22 +0100 Subject: [PATCH 069/152] Add ignore --- htdocs/custom/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 htdocs/custom/.gitignore diff --git a/htdocs/custom/.gitignore b/htdocs/custom/.gitignore new file mode 100644 index 00000000000..ed069fdfd81 --- /dev/null +++ b/htdocs/custom/.gitignore @@ -0,0 +1,4 @@ +/a* +/b* +/c* +/d* From 362167f31974f2367faa4989ba896e6fd956ea33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jan 2015 02:32:15 +0100 Subject: [PATCH 070/152] Fixed: Export was not using user assigned --- htdocs/admin/agenda_xcal.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 32 ++++++------------- htdocs/langs/en_US/agenda.lang | 2 +- htdocs/public/agenda/agendaexport.php | 4 +-- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 40454ed1302..fd8c3092c0d 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -171,7 +171,7 @@ $message.='
'; print $message; $message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'
'; -$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'
'; +//$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index bf668be6daa..9a750daa015 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -976,7 +976,7 @@ class ActionComm extends CommonObject $sql.= " a.label, a.code, a.note, a.fk_action as type_id,"; $sql.= " a.fk_soc,"; $sql.= " a.fk_user_author, a.fk_user_mod,"; - $sql.= " a.fk_user_action, a.fk_user_done,"; + $sql.= " a.fk_user_action,"; $sql.= " a.fk_contact, a.percent as percentage,"; $sql.= " a.fk_element, a.elementtype,"; $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; @@ -984,9 +984,11 @@ class ActionComm extends CommonObject $sql.= " s.nom as socname,"; $sql.= " c.id as type_id, c.code as type_code, c.libelle"; $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; - $sql.= " WHERE a.fk_action=c.id"; + // We must filter on assignement table + if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; + $sql.= " WHERE a.fk_action=c.id"; $sql.= " AND a.entity = ".$conf->entity; foreach ($filters as $key => $value) { @@ -996,17 +998,8 @@ class ActionComm extends CommonObject if ($key == 'idfrom') $sql.=" AND a.id >= ".(is_numeric($value)?$value:0); if ($key == 'idto') $sql.=" AND a.id <= ".(is_numeric($value)?$value:0); if ($key == 'project') $sql.=" AND a.fk_project=".(is_numeric($value)?$value:0); - if ($key == 'login') - { - $login=$value; - $userforfilter=new User($this->db); - $result=$userforfilter->fetch('',$value); - $sql.= " AND ("; - $sql.= " a.fk_user_author = ".$userforfilter->id; - $sql.= " OR a.fk_user_action = ".$userforfilter->id; - $sql.= " OR a.fk_user_done = ".$userforfilter->id; - $sql.= ")"; - } + // We must filter on assignement table + if ($key == 'logint' || $key == 'login') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($key == 'logina') { $logina=$value; @@ -1014,19 +1007,12 @@ class ActionComm extends CommonObject $result=$userforfilter->fetch('',$value); $sql.= " AND a.fk_user_author = ".$userforfilter->id; } - if ($key == 'logint') + if ($key == 'logint' || $key == 'login') { $logint=$value; $userforfilter=new User($this->db); $result=$userforfilter->fetch('',$value); - $sql.= " AND a.fk_user_action = ".$userforfilter->id; - } - if ($key == 'logind') - { - $logind=$value; - $userforfilter=new User($this->db); - $result=$userforfilter->fetch('',$value); - $sql.= " AND a.fk_user_done = ".$userforfilter->id; + $sql.= " AND ar.fk_element = ".$userforfilter->id; } } $sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 1cc01ec2e7b..9ed2d79edd2 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -68,7 +68,7 @@ DateActionDoneEnd= Real end date DateActionStart= Start date DateActionEnd= End date AgendaUrlOptions1=You can also add following parameters to filter output: -AgendaUrlOptions2=login=%s to restrict output to actions created by, assigned to or done by user %s. +AgendaUrlOptions2=login=%s to restrict output to actions created by or assigned to user %s. AgendaUrlOptions3=logina=%s to restrict output to actions owned by a user %s. AgendaUrlOptions4=logint=%s to restrict output to actions assigned to user %s. AgendaUrlOptionsProject=project=PROJECT_ID to restrict output to actions associated to project PROJECT_ID. diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index c36766e2777..2b1d02ef493 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -69,7 +69,6 @@ if (! empty($_GET["project"])) $filters['project']=$_GET["project"]; if (! empty($_GET["login"])) $filters['login']=$_GET["login"]; if (! empty($_GET["logina"])) $filters['logina']=$_GET["logina"]; if (! empty($_GET["logint"])) $filters['logint']=$_GET["logint"]; -if (! empty($_GET["logind"])) $filters['logind']=$_GET["logind"]; // Not older than if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100; $filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY; @@ -111,8 +110,7 @@ foreach ($filters as $key => $value) if ($key == 'project') $filename.='-project'.$value; if ($key == 'login') $filename.='-login'.$value; if ($key == 'logina') $filename.='-logina'.$value; // Author - if ($key == 'logind') $filename.='-logind'.$value; // Affected to - if ($key == 'logint') $filename.='-logint'.$value; // Done by + if ($key == 'logint') $filename.='-logint'.$value; // Assigned to } // Add extension if ($format == 'vcal') { $shortfilename.='.vcs'; $filename.='.vcs'; } From d16ce7eb96a8461a1eb5d251d09136085e3607e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jan 2015 02:42:41 +0100 Subject: [PATCH 071/152] Fix: Bad var --- htdocs/comm/action/class/actioncomm.class.php | 2 +- test/phpunit/NumberingModulesTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9a750daa015..dd7819f7dbb 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -142,7 +142,7 @@ class ActionComm extends CommonObject $userdoneid=$this->userdoneid; // Be sure assigned user array is not empty. - if (count($this->userassigned) == 0) $this->userassigned = array('id'=>$this->$userownerid); + if (count($this->userassigned) == 0) $this->userassigned = array('id'=>$userownerid); if (! $this->type_id || ! $this->type_code) { diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 48d26216268..891bc5495cf 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -165,7 +165,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $this->assertEquals(1, $result); // Can be deleted $result=$localobject->is_erasable(); print __METHOD__." is_erasable=".$result."\n"; - $this->assertEquals(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent + $this->assertEquals(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent) // Now we try with a reset $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}'; @@ -552,7 +552,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1980 to be sure to not have existing invoice for this year + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($tmpthirdparty, $localobject); $result2=$localobject->create($user,1); From c5a3b4481e382ac2042a4a0d01c27b56f7921fc4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jan 2015 03:11:06 +0100 Subject: [PATCH 072/152] Fixed: use object --- htdocs/societe/agenda.php | 53 ++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 8d731875442..a6ba3d7b1cf 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -59,9 +59,6 @@ $contactstatic = new Contact($db); $form = new Form($db); -/* - * Fiche categorie de client et/ou fournisseur - */ if ($socid) { require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -70,79 +67,79 @@ if ($socid) $langs->load("companies"); - $soc = new Societe($db); - $result = $soc->fetch($socid); + $object = new Societe($db); + $result = $object->fetch($socid); llxHeader("",$langs->trans("Agenda"),''); if (! empty($conf->notification->enabled)) $langs->load("mails"); - $head = societe_prepare_head($soc); + $head = societe_prepare_head($object); dol_fiche_head($head, 'agenda', $langs->trans("ThirdParty"),0,'company'); print ''; print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print ''; + print ''; } - if ($soc->client) + if ($object->client) { print ''; } - if ($soc->fournisseur) + if ($object->fournisseur) { print ''; } if (! empty($conf->barcode->enabled)) { - print ''; + print ''; } print ""; // Zip / Town - print '"; - print '"; + print '"; + print '"; // Country - if ($soc->country) { + if ($object->country) { print ''; } // EMail print ''; // Web print ''; // Phone / Fax - print ''; - print ''; + print ''; + print ''; print '
'.$langs->trans("ThirdPartyName").''; - print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); + print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); print '
'.$langs->trans('Prefix').''.$soc->prefix_comm.'
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; print $langs->trans('CustomerCode').''; - print $soc->code_client; - if ($soc->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print '
'; print $langs->trans('SupplierCode').''; - print $soc->code_fournisseur; - if ($soc->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
'.$langs->trans('Gencod').''.$soc->barcode.'
'.$langs->trans('Gencod').''.$object->barcode.'
".$langs->trans('Address').""; - dol_print_address($soc->address, 'gmap', 'thirdparty', $soc->id); + dol_print_address($object->address, 'gmap', 'thirdparty', $object->id); print "
'.$langs->trans('Zip').''.$soc->zip."'.$langs->trans('Town').''.$soc->town."
'.$langs->trans('Zip').''.$object->zip."'.$langs->trans('Town').''.$object->town."
'.$langs->trans('Country').''; - $img=picto_from_langcode($soc->country_code); + $img=picto_from_langcode($object->country_code); print ($img?$img.' ':''); - print $soc->country; + print $object->country; print '
'.$langs->trans('EMail').''; - print dol_print_email($soc->email,0,$soc->id,'AC_EMAIL'); + print dol_print_email($object->email,0,$object->id,'AC_EMAIL'); print '
'.$langs->trans('Web').''; - print dol_print_url($soc->url); + print dol_print_url($object->url); print '
'.$langs->trans('Phone').''.dol_print_phone($soc->phone,$soc->country_code,0,$soc->id,'AC_TEL').''.$langs->trans('Fax').''.dol_print_phone($soc->fax,$soc->country_code,0,$soc->id,'AC_FAX').'
'.$langs->trans('Phone').''.dol_print_phone($object->phone,$object->country_code,0,$object->id,'AC_TEL').''.$langs->trans('Fax').''.dol_print_phone($object->fax,$object->country_code,0,$object->id,'AC_FAX').'
'; @@ -171,7 +168,7 @@ if ($socid) print '
'; - $objthirdparty=$soc; + $objthirdparty=$object; $objcon=new stdClass(); $out=''; @@ -189,10 +186,10 @@ if ($socid) print load_fiche_titre($langs->trans("ActionsOnCompany"),$out,''); // List of todo actions - show_actions_todo($conf,$langs,$db,$soc); + show_actions_todo($conf,$langs,$db,$object); // List of done actions - show_actions_done($conf,$langs,$db,$soc); + show_actions_done($conf,$langs,$db,$object); } From e20c1decdf30886e4c36654ddd3175a92ea1bebc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jan 2015 03:51:47 +0100 Subject: [PATCH 073/152] Fixed: object instead of soc and vis versa. --- htdocs/categories/categorie.php | 2 +- htdocs/core/lib/functions.lib.php | 1 + htdocs/societe/info.php | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index e9e11b656b9..a77751fcb29 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -278,7 +278,7 @@ if ($socid) // Address print '
'.$langs->trans('Address').''; - print dol_print_address($soc->address,'gmap','thirdparty',$object->id); + print dol_print_address($soc->address,'gmap','thirdparty',$soc->id); print '
'; -dol_print_object_info($soc); +dol_print_object_info($object); print '
'; From d40eab2494be4bc9d6379be26bcaab78bd9ff896 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 15 Jan 2015 09:57:20 +0100 Subject: [PATCH 074/152] Fix: withdrawal create error if in the same month are deleted previus withdrawals. --- ChangeLog | 1 + htdocs/compta/prelevement/class/bonprelevement.class.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b621467312..d85b8e3535d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.6.3 compared to 3.6.2 ***** - Fix: ref_ext was not saved when recording a customer order from web service - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. +- Fix: withdrawal create error if in the same month are deleted previus withdrawals. ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3a83d9c3dba..4fe098b8706 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2014 Ferran Marcet * @@ -892,10 +892,11 @@ class BonPrelevement extends CommonObject { $ref = "T".substr($year,-2).$month; - $sql = "SELECT count(*)"; + $sql = "SELECT CAST(RIGHT(ref,2) AS SIGNED INTEGER)"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; $sql.= " WHERE ref LIKE '".$ref."%'"; $sql.= " AND entity = ".$conf->entity; + $sql.= " ORDER BY ref DESC LIMIT 1"; dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); From f03ffaf5a3fe2892daba5d637b65f9a54e23ead6 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 15 Jan 2015 10:00:52 +0100 Subject: [PATCH 075/152] Fix: withdrawal create error if in the same month are deleted previus withdrawals. Conflicts: ChangeLog --- ChangeLog | 2 ++ htdocs/compta/prelevement/class/bonprelevement.class.php | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3b8e1193ab..1e87b51ca43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -172,6 +172,8 @@ Dolibarr better: ***** ChangeLog for 3.6.3 compared to 3.6.2 ***** - Fix: ref_ext was not saved when recording a customer order from web service +- Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. +- Fix: withdrawal create error if in the same month are deleted previus withdrawals. ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 497d690072b..d044e32e078 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2014 Ferran Marcet * @@ -895,10 +895,11 @@ class BonPrelevement extends CommonObject { $ref = "T".substr($year,-2).$month; - $sql = "SELECT count(*)"; + $sql = "SELECT CAST(RIGHT(ref,2) AS SIGNED INTEGER)"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; $sql.= " WHERE ref LIKE '".$ref."%'"; $sql.= " AND entity = ".$conf->entity; + $sql.= " ORDER BY ref DESC LIMIT 1"; dol_syslog(get_class($this)."::Create", LOG_DEBUG); $resql = $this->db->query($sql); From 1930d0677e9207fc7322217af644ba09ca2f835e Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 15 Jan 2015 10:00:52 +0100 Subject: [PATCH 076/152] Fix: withdrawal create error if in the same month are deleted previus withdrawals. Conflicts: ChangeLog --- ChangeLog | 2 ++ htdocs/compta/prelevement/class/bonprelevement.class.php | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e61b274398..6485000c375 100644 --- a/ChangeLog +++ b/ChangeLog @@ -189,6 +189,8 @@ Dolibarr better: ***** ChangeLog for 3.6.3 compared to 3.6.2 ***** - Fix: ref_ext was not saved when recording a customer order from web service +- Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. +- Fix: withdrawal create error if in the same month are deleted previus withdrawals. ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index d88bc8da8ac..457209c5e76 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2014 Ferran Marcet * @@ -895,10 +895,11 @@ class BonPrelevement extends CommonObject { $ref = "T".substr($year,-2).$month; - $sql = "SELECT count(*)"; + $sql = "SELECT CAST(RIGHT(ref,2) AS SIGNED INTEGER)"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; $sql.= " WHERE ref LIKE '".$ref."%'"; $sql.= " AND entity = ".$conf->entity; + $sql.= " ORDER BY ref DESC LIMIT 1"; dol_syslog(get_class($this)."::Create", LOG_DEBUG); $resql = $this->db->query($sql); From eb90e0124e32e56769a1442f021eaa16ffadcba7 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 30 Dec 2014 12:05:55 +0100 Subject: [PATCH 077/152] Add support for configurable first day of week - Force loading of database configuration to retrieve the first day of week - Order the day titles based on first day of week - Change layout based on first day of week Conflicts: htdocs/core/datepicker.php --- htdocs/core/datepicker.php | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index 7c5c4898fce..9c584c2ef6e 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -27,7 +27,7 @@ */ if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); @@ -186,27 +186,13 @@ function displayBox($selectedDate,$month,$year) global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1; - if($startday==1) - {?> - trans("ShortMonday") ?> - trans("ShortTuesday") ?> - trans("ShortWednesday") ?> - trans("ShortThursday") ?> - trans("ShortFriday") ?> - trans("ShortSaturday") ?> - trans("ShortSunday") ?> - - trans("ShortSunday") ?> - trans("ShortMonday") ?> - trans("ShortTuesday") ?> - trans("ShortWednesday") ?> - trans("ShortThursday") ?> - trans("ShortFriday") ?> - trans("ShortSaturday") ?> - + $first_day_of_week = isset($conf->global->MAIN_START_WEEK) ? (int) $conf->global->MAIN_START_WEEK : 0; + $day_names = array('ShortSunday', 'ShortMonday', 'ShortTuesday', 'ShortWednesday', 'ShortThursday', 'ShortFriday', 'ShortSaturday'); + for( $i=0; $i < 7; $i++ ) + { + echo '', $langs->trans($day_names[($i + $first_day_of_week) % 7]), '', "\n"; + } + ?> "; $cols=0; - for($i=0;$i< $mydate["wday"];$i++) + for($i=0;$i< ($mydate["wday"]+7-$first_day_of_week)%7;$i++) { echo " "; $cols++; @@ -230,7 +216,7 @@ function displayBox($selectedDate,$month,$year) } else { - if ($mydate["wday"]==0) + if ($mydate["wday"]==$first_day_of_week) { echo ""; $cols=0; @@ -254,7 +240,7 @@ function displayBox($selectedDate,$month,$year) echo ">".sprintf("%02s",$mydate["mday"]).""; $cols++; - if ($mydate["wday"]==6) echo "\n"; + if ($mydate != $firstdate && $mydate["wday"]==(($first_day_of_week + 6)%7)) echo "\n"; //$thedate=strtotime("tomorrow",$thedate); $day++; From 71b609fab0b440f23def50ed972fdf58ed2297b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Thu, 15 Jan 2015 13:08:33 +0100 Subject: [PATCH 078/152] Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules --- ChangeLog | 1 + htdocs/fourn/facture/fiche.php | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b621467312..986e90047cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.6.3 compared to 3.6.2 ***** - Fix: ref_ext was not saved when recording a customer order from web service - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. +- Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 98522e21342..e06ebfa73ca 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1500,12 +1500,7 @@ else if ($objectref == 'PROV') { $savdate=$object->date; - if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) - { - $object->date=dol_now(); - //TODO: Possibly will have to control payment information into suppliers - //$object->date_lim_reglement=$object->calculate_date_lim_reglement(); - } + $numref = $object->getNextNumRef($societe); } else From 61809ef6b5211c048e6ec49df18a5e677f335a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Thu, 15 Jan 2015 13:22:58 +0100 Subject: [PATCH 079/152] - Fix: [ bug #1802 ] SQL error when updating a task with PostgreSQL database --- ChangeLog | 1 + htdocs/projet/class/task.class.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d85b8e3535d..de1d5fd7040 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ English Dolibarr ChangeLog - Fix: ref_ext was not saved when recording a customer order from web service - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. +- Fix: [ bug #1802 ] SQL error when updating a task with PostgreSQL database ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 4f253b47f8b..678660b7e6f 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -287,8 +287,8 @@ class Task extends CommonObject $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; $sql.= " duration_effective=".(isset($this->duration_effective)?$this->duration_effective:"null").","; $sql.= " planned_workload=".(isset($this->planned_workload)?$this->planned_workload:"0").","; - $sql.= " dateo=".($this->date_start!=''?$this->db->idate($this->date_start):'null').","; - $sql.= " datee=".($this->date_end!=''?$this->db->idate($this->date_end):'null').","; + $sql.= " dateo=".($this->date_start!=''?"'".$this->db->idate($this->date_start)."'":'null').","; + $sql.= " datee=".($this->date_end!=''?"'".$this->db->idate($this->date_end)."'":'null').","; $sql.= " progress=".$this->progress.","; $sql.= " rang=".((!empty($this->rang))?$this->rang:"0"); $sql.= " WHERE rowid=".$this->id; From 999a6052ff6e703e1935fea31a5ea3db9474e5c6 Mon Sep 17 00:00:00 2001 From: Cedric Date: Thu, 15 Jan 2015 16:23:10 +0100 Subject: [PATCH 080/152] FIX : Creating default object from empty when validating supplier order --- htdocs/fourn/commande/fiche.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 00884d368f6..8e536904616 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -522,6 +522,13 @@ else if ($action == 'confirm_approve' && $confirm == 'yes' && $user->rights->fou $result = $object->approve($user, $idwarehouse); if ($result > 0) { + $outputlangs = $langs; + if (GETPOST('lang_id')) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang(GETPOST('lang_id')); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } @@ -554,6 +561,13 @@ else if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fo $result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']); if ($result > 0) { + $outputlangs = $langs; + if (GETPOST('lang_id')) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang(GETPOST('lang_id')); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } From 2396ba833cb3471fb6938f4d8c2121c10468a747 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Wed, 14 Jan 2015 16:08:18 +0100 Subject: [PATCH 081/152] Ignore content of directory custom --- htdocs/custom/.gitignore | 5 +++++ htdocs/custom/index.html | 0 2 files changed, 5 insertions(+) create mode 100644 htdocs/custom/.gitignore create mode 100644 htdocs/custom/index.html diff --git a/htdocs/custom/.gitignore b/htdocs/custom/.gitignore new file mode 100644 index 00000000000..fee9c05b885 --- /dev/null +++ b/htdocs/custom/.gitignore @@ -0,0 +1,5 @@ +/* +!.gitignore +!README.md +!index.html + diff --git a/htdocs/custom/index.html b/htdocs/custom/index.html new file mode 100644 index 00000000000..e69de29bb2d From a9008c499370b624e1bf02f43c5c7caefb369177 Mon Sep 17 00:00:00 2001 From: KreizIT Date: Thu, 15 Jan 2015 17:40:15 +0100 Subject: [PATCH 082/152] Fix Creating default object from empty on supplier order confirmation --- htdocs/fourn/commande/card.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 09556bd9125..220dc02b4d7 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -479,14 +479,16 @@ else if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->r $result = $object->deleteline(GETPOST('lineid')); if ($result >= 0) { - $outputlangs = $langs; - if (GETPOST('lang_id')) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang(GETPOST('lang_id')); - } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } $ret=$object->fetch($object->id); // Reload to get new records $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } @@ -571,6 +573,14 @@ else if ($action == 'confirm_approve' && $confirm == 'yes' && $user->rights->fou if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); From 41890d0a0be2663273ac15002d39cd7c9836538d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jan 2015 14:38:00 +0100 Subject: [PATCH 083/152] Fixed: Translation of module name and desc was not used for external modules. --- htdocs/core/modules/DolibarrModules.class.php | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index e4d1f834b4a..b19557f25ff 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -344,7 +344,8 @@ abstract class DolibarrModules /** - * Gives the translated module name if translation exists in admin.lang or the default module name. + * Gives the translated module name if translation exists in admin.lang or into language files of module. + * Otherwise return the module key name. * * @return string Translated module name */ @@ -359,9 +360,16 @@ abstract class DolibarrModules return $langs->trans("Module".$this->numero."Name"); } else - { - // If module name translation using it's unique id does not exists, we take its name - return $this->name; + { + // If module name translation using it's unique id does not exists, we take use its name to find translation + if (is_array($this->langfiles)) + { + foreach($this->langfiles as $val) + { + if ($val) $langs->load($val); + } + } + return $langs->trans($this->name); } } @@ -382,9 +390,16 @@ abstract class DolibarrModules return $langs->trans("Module".$this->numero."Desc"); } else - { - // If module description translation using it's unique id does not exists, we take its description - return $this->description; + { + // If module description translation using it's unique id does not exists, we take use its name to find translation + if (is_array($this->langfiles)) + { + foreach($this->langfiles as $val) + { + if ($val) $langs->load($val); + } + } + return $langs->trans($this->description); } } From fe5533d1c37444031539d2d8aaa7aa4c95a2513f Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 16 Jan 2015 17:41:56 +0100 Subject: [PATCH 084/152] Fix: PostgreSQL compatibilty --- .../class/bonprelevement.class.php | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 4fe098b8706..7f0b693391e 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -890,31 +890,31 @@ class BonPrelevement extends CommonObject */ if (!$error) { - $ref = "T".substr($year,-2).$month; + $ref = substr($year,-2).$month; + + $sql = "SELECT substring(ref from char_length(ref) - 1)"; + $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; + $sql.= " WHERE ref LIKE '%".$ref."%'"; + $sql.= " AND entity = ".$conf->entity; + $sql.= " ORDER BY ref DESC LIMIT 1"; + + dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); - $sql = "SELECT CAST(RIGHT(ref,2) AS SIGNED INTEGER)"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; - $sql.= " WHERE ref LIKE '".$ref."%'"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " ORDER BY ref DESC LIMIT 1"; + if ($resql) + { + $row = $this->db->fetch_row($resql); + } + else + { + $error++; + dol_syslog("Erreur recherche reference"); + } - dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG); - $resql = $this->db->query($sql); - - if ($resql) - { - $row = $this->db->fetch_row($resql); - } - else - { - $error++; - dol_syslog("Erreur recherche reference"); - } - - $ref = $ref . substr("00".($row[0]+1), -2); - - $filebonprev = $ref; + $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1),2,"0",STR_PAD_LEFT); + $filebonprev = $ref; + // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; $sql.= " ref, entity, datec"; From 0d4aad4111fe67408066a7751ee1e30ce77e2b9e Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 16 Jan 2015 17:59:58 +0100 Subject: [PATCH 085/152] Fix: PostgreSQL compatibilty Conflicts: htdocs/compta/prelevement/class/bonprelevement.class.php --- .../class/bonprelevement.class.php | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index d044e32e078..21417483b80 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -893,31 +893,31 @@ class BonPrelevement extends CommonObject */ if (!$error) { - $ref = "T".substr($year,-2).$month; + $ref = substr($year,-2).$month; + + $sql = "SELECT substring(ref from char_length(ref) - 1)"; + $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; + $sql.= " WHERE ref LIKE '%".$ref."%'"; + $sql.= " AND entity = ".$conf->entity; + $sql.= " ORDER BY ref DESC LIMIT 1"; + + dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); - $sql = "SELECT CAST(RIGHT(ref,2) AS SIGNED INTEGER)"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; - $sql.= " WHERE ref LIKE '".$ref."%'"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " ORDER BY ref DESC LIMIT 1"; + if ($resql) + { + $row = $this->db->fetch_row($resql); + } + else + { + $error++; + dol_syslog("Erreur recherche reference"); + } - dol_syslog(get_class($this)."::Create", LOG_DEBUG); - $resql = $this->db->query($sql); - - if ($resql) - { - $row = $this->db->fetch_row($resql); - } - else - { - $error++; - dol_syslog("Erreur recherche reference"); - } - - $ref = $ref . substr("00".($row[0]+1), -2); - - $filebonprev = $ref; + $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1),2,"0",STR_PAD_LEFT); + $filebonprev = $ref; + // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; $sql.= " ref, entity, datec"; From 93d3ffb06fdeb1170ccba075ee3225d23ee2d9f0 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 16 Jan 2015 17:59:58 +0100 Subject: [PATCH 086/152] Fix: PostgreSQL compatibilty Conflicts: htdocs/compta/prelevement/class/bonprelevement.class.php --- .../class/bonprelevement.class.php | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 457209c5e76..724c2dc9a64 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -893,31 +893,31 @@ class BonPrelevement extends CommonObject */ if (!$error) { - $ref = "T".substr($year,-2).$month; + $ref = substr($year,-2).$month; + + $sql = "SELECT substring(ref from char_length(ref) - 1)"; + $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; + $sql.= " WHERE ref LIKE '%".$ref."%'"; + $sql.= " AND entity = ".$conf->entity; + $sql.= " ORDER BY ref DESC LIMIT 1"; + + dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); - $sql = "SELECT CAST(RIGHT(ref,2) AS SIGNED INTEGER)"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; - $sql.= " WHERE ref LIKE '".$ref."%'"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " ORDER BY ref DESC LIMIT 1"; + if ($resql) + { + $row = $this->db->fetch_row($resql); + } + else + { + $error++; + dol_syslog("Erreur recherche reference"); + } - dol_syslog(get_class($this)."::Create", LOG_DEBUG); - $resql = $this->db->query($sql); - - if ($resql) - { - $row = $this->db->fetch_row($resql); - } - else - { - $error++; - dol_syslog("Erreur recherche reference"); - } - - $ref = $ref . substr("00".($row[0]+1), -2); - - $filebonprev = $ref; + $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1),2,"0",STR_PAD_LEFT); + $filebonprev = $ref; + // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; $sql.= " ref, entity, datec"; From 26e5efd71db015fe31fc934f47ecb8ab7c8d55c3 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 16 Jan 2015 23:09:13 +0100 Subject: [PATCH 087/152] Improve code create function --- .../class/bonprelevement.class.php | 109 +++++++++--------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 724c2dc9a64..9188d573924 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -736,8 +736,8 @@ class BonPrelevement extends CommonObject function Create($banque=0, $agence=0, $mode='real') { global $conf,$langs; - - dol_syslog(get_class($this)."::Create banque=$banque agence=$agence"); + + dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence, LOG_DEBUG); require_once (DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once (DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); @@ -781,7 +781,8 @@ class BonPrelevement extends CommonObject //if ($banque) $sql.= " AND sr.code_banque = '".$conf->global->PRELEVEMENT_CODE_BANQUE."'"; //if ($agence) $sql.= " AND sr.code_guichet = '".$conf->global->PRELEVEMENT_CODE_GUICHET."'"; - dol_syslog(get_class($this)."::Create", LOG_DEBUG); + dol_syslog(__METHOD__."::Read invoices, sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { @@ -795,13 +796,12 @@ class BonPrelevement extends CommonObject $i++; } $this->db->free($resql); - dol_syslog($i." invoices to withdraw"); + dol_syslog(__METHOD__."::Read invoices, ".$i." invoices to withdraw", LOG_DEBUG); } else { - $error = 1; - dol_syslog("Erreur -1"); - dol_syslog($this->db->error()); + $error++; + dol_syslog(__METHOD__."::Read invoices error ".$this->db->error(), LOG_ERR); } } @@ -812,7 +812,7 @@ class BonPrelevement extends CommonObject // Check RIB $i = 0; - dol_syslog("Start RIB check"); + dol_syslog(__METHOD__."::Check RIB", LOG_DEBUG); if (count($factures) > 0) { @@ -836,24 +836,24 @@ class BonPrelevement extends CommonObject } else { - dol_syslog("Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR); + dol_syslog(__METHOD__."::Check RIB Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR); $this->invoice_in_error[$fac[0]]="Error on default bank number RIB/IBAN for invoice ".$fact->getNomUrl(0)." for thirdparty (reported by function verif) ".$soc->name; } } else { - dol_syslog("Failed to read company", LOG_ERR); + dol_syslog(__METHOD__."::Check RIB Failed to read company", LOG_ERR); } } else { - dol_syslog("Failed to read invoice", LOG_ERR); + dol_syslog(__METHOD__."::Check RIB Failed to read invoice", LOG_ERR); } } } else { - dol_syslog("No invoice to process"); + dol_syslog(__METHOD__."::Check RIB No invoice to process", LOG_ERR); } } @@ -902,50 +902,52 @@ class BonPrelevement extends CommonObject $sql.= " ORDER BY ref DESC LIMIT 1"; dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG); + dol_syslog(__METHOD__."::Treatments", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); + $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1),2,"0",STR_PAD_LEFT); + + $filebonprev = $ref; + + // Create withdraw receipt in database + $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; + $sql.= " ref, entity, datec"; + $sql.= ") VALUES ("; + $sql.= "'".$this->db->escape($ref)."'"; + $sql.= ", ".$conf->entity; + $sql.= ", '".$this->db->idate($now)."'"; + $sql.= ")"; + + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + + if ($resql) + { + $prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons"); + + $dir=$conf->prelevement->dir_output.'/receipts'; + $file=$filebonprev; + if (! is_dir($dir)) dol_mkdir($dir); + + $bonprev = new BonPrelevement($this->db, $dir."/".$file); + $bonprev->id = $prev_id; + } + else + { + $error++; + dol_syslog(__METHOD__."::Create withdraw receipt ".$this->db->error(), LOG_ERR); + } } else { $error++; - dol_syslog("Erreur recherche reference"); + dol_syslog(__METHOD__."::Get last withdraw receipt ".$this->db->error(), LOG_ERR); } - $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1),2,"0",STR_PAD_LEFT); - - $filebonprev = $ref; - - // Create withdraw receipt in database - $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; - $sql.= " ref, entity, datec"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($ref)."'"; - $sql.= ", ".$conf->entity; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ")"; - - dol_syslog(get_class($this)."::Create", LOG_DEBUG); - $resql = $this->db->query($sql); - - if ($resql) - { - $prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons"); - - $dir=$conf->prelevement->dir_output.'/receipts'; - $file=$filebonprev; - if (! is_dir($dir)) dol_mkdir($dir); - - $bonprev = new BonPrelevement($this->db, $dir."/".$file); - $bonprev->id = $prev_id; - } - else - { - $error++; - dol_syslog("Erreur creation du bon de prelevement"); - } + } /* @@ -988,13 +990,12 @@ class BonPrelevement extends CommonObject $sql.= ", fk_prelevement_bons = ".$prev_id; $sql.= " WHERE rowid = ".$fac[1]; - dol_syslog(get_class($this)."::Create", LOG_DEBUG); + dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { $error++; - dol_syslog("Erreur mise a jour des demandes"); - dol_syslog($this->db->error()); + dol_syslog(__METHOD__."::Update Orders::Error=".$this->db->error() ,LOG_ERR); } } @@ -1009,8 +1010,8 @@ class BonPrelevement extends CommonObject * Withdraw receipt */ - dol_syslog("Debut prelevement - Nombre de factures ".count($factures_prev)); - + dol_syslog(__METHOD__."::Init withdraw receipt for ".count($factures_prev)." invoices", LOG_DEBUG); + if (count($factures_prev) > 0) { $bonprev->date_echeance = $datetimeprev; @@ -1032,8 +1033,7 @@ class BonPrelevement extends CommonObject //Build file $bonprev->generate(); } - dol_syslog($filebonprev); - dol_syslog("Fin prelevement"); + dol_syslog(__METHOD__."::End withdraw receipt, file ".$filebonprev, LOG_DEBUG); } /* @@ -1045,12 +1045,14 @@ class BonPrelevement extends CommonObject $sql.= " WHERE rowid = ".$prev_id; $sql.= " AND entity = ".$conf->entity; - dol_syslog(get_class($this)."::Create", LOG_DEBUG); + dol_syslog(__METHOD__."::Update total, sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); if (! $resql) { $error++; dol_syslog("Erreur mise a jour du total - $sql"); + dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR); } /* @@ -1063,7 +1065,6 @@ class BonPrelevement extends CommonObject else { $this->db->rollback(); - dol_syslog("Error",LOG_ERR); } return count($factures_prev); From a7d263c14e6c9aaa5afa7c37300181a37f88bcfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 16 Jan 2015 23:34:10 +0100 Subject: [PATCH 088/152] Typo --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 9188d573924..e4fa1e05d29 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -995,7 +995,7 @@ class BonPrelevement extends CommonObject if (! $resql) { $error++; - dol_syslog(__METHOD__."::Update Orders::Error=".$this->db->error() ,LOG_ERR); + dol_syslog(__METHOD__."::Update Orders::Error=".$this->db->error(), LOG_ERR); } } From 8cd46e483088cd72fd35225d2c8028e0075469fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jan 2015 14:34:16 +0100 Subject: [PATCH 089/152] Introduce option MAIN_HTML_TITLE to start to control format of html title content. --- ChangeLog | 1 + htdocs/comm/card.php | 41 ++++++++++++------------ htdocs/core/class/commonobject.class.php | 1 - htdocs/fourn/card.php | 18 ++++++++--- htdocs/main.inc.php | 3 +- htdocs/societe/soc.php | 28 +++++++--------- 6 files changed, 49 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e61b274398..37b693f2ab8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ For users: - Fix / Improve : [ bug #1747 ] Remove creation of batch 'Undefined' - Add Weighted average price as default price for buying price for margin calculation. Add option MARGIN_PMP_AS_DEFAULT_BUY_PRICE to replace with first supplier price. +- Introduce option MAIN_HTML_TITLE to start to control format of html title content. For translators: - Update language files. diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 5b64c834401..ecb171c6570 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -85,7 +85,7 @@ $cancelbutton = GETPOST('cancel'); if ($action == 'setcustomeraccountancycode') { - if (! $cancelbutton) + if (! $cancelbutton) { $result=$object->fetch($id); $object->code_compta=$_POST["customeraccountancycode"]; @@ -105,6 +105,7 @@ if ($action == 'setconditions' && $user->rights->societe->creer) $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); if ($result < 0) dol_print_error($db,$object->error); } + // mode de reglement if ($action == 'setmode' && $user->rights->societe->creer) { @@ -112,16 +113,14 @@ if ($action == 'setmode' && $user->rights->societe->creer) $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); if ($result < 0) dol_print_error($db,$object->error); } + // assujetissement a la TVA if ($action == 'setassujtva' && $user->rights->societe->creer) { $object->fetch($id); $object->tva_assuj=$_POST['assujtva_value']; - - // TODO move to DAO class - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE rowid='".$id."'"; - $result = $db->query($sql); - if (! $result) dol_print_error($result); + $result=$object->update($object->id); + if ($result < 0) dol_print_error($db,$object->error); } // set prospect level @@ -133,7 +132,7 @@ if ($action == 'setprospectlevel' && $user->rights->societe->creer) if ($result < 0) setEventMessage($object->error,'errors'); } -// Update communication level +// update prospect level if ($action == 'cstc') { $object->fetch($id); @@ -142,10 +141,10 @@ if ($action == 'cstc') if ($result < 0) setEventMessage($object->error,'errors'); } -// Update communication level +// update outstandng limit if ($action == 'setOutstandingBill') { - if (!$cancelbutton) + if (!$cancelbutton) { $object->fetch($id); $object->outstanding_limit=GETPOST('OutstandingBill'); @@ -159,14 +158,24 @@ if ($action == 'setOutstandingBill') * View */ -llxHeader('',$langs->trans('CustomerCard')); - - $contactstatic = new Contact($db); $userstatic=new User($db); $form = new Form($db); $formcompany=new FormCompany($db); +if ($id > 0 && empty($object->id)) +{ + // Load data of third party + $res=$object->fetch($id); + if ($object->id <= 0) dol_print_error($db,$object->error); +} + +$title=$langs->trans("CustomerCard"); +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name; +$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('',$title,$help_url); + + if ($mode == 'search') { @@ -196,14 +205,6 @@ if ($mode == 'search') if ($id > 0) { - // Load data of third party - $object->fetch($id); - if ($object->id <= 0) - { - dol_print_error($db,$object->error); - } - - $head = societe_prepare_head($object); dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"),0,'company'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 183fed325be..c2718cf504c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2191,7 +2191,6 @@ abstract class CommonObject $obj = $this->db->fetch_object($resql); if ($obj) { - $this->id = $obj->rowid; $this->canvas = $obj->canvas; return 1; } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 8511a3e1a48..0447bd0a758 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -63,7 +63,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if ($action == 'setsupplieraccountancycode') { $cancelbutton = GETPOST('cancel'); - if (! $cancelbutton) + if (! $cancelbutton) { $result=$object->fetch($id); $object->code_compta_fournisseur=$_POST["supplieraccountancycode"]; @@ -98,12 +98,22 @@ if ($action == 'setmode' && $user->rights->societe->creer) $contactstatic = new Contact($db); $form = new Form($db); -if ($object->fetch($id)) +if ($id > 0 && empty($object->id)) { - llxHeader('',$langs->trans('SupplierCard')); + // Load data of third party + $res=$object->fetch($id); + if ($object->id <= 0) dol_print_error($db,$object->error); +} + +if ($object->id > 0) +{ + $title=$langs->trans("SupplierCard"); + if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name; + $help_url=''; + llxHeader('',$title, $help_url); /* - * Affichage onglets + * Show tabs */ $head = societe_prepare_head($object); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b805e098706..48f788c96fa 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -976,7 +976,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs // Displays meta print ''."\n"; // Evite indexation par robots print ''."\n"; - if ($conf->global->MAIN_FEATURES_LEVEL == 2 || ! empty($conf->global->MAIN_ACTIVATE_HTML5)) print ''."\n"; // Needed for Responsive Web Design + if (! empty($conf->global->MAIN_ACTIVATE_HTML5)) print ''."\n"; // Needed for Responsive Web Design $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; print ''."\n"; @@ -988,6 +988,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs $appli='Dolibarr'; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; + if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) print ''.dol_htmlentities($title).''; if ($title) print ''.dol_htmlentities($appli.' - '.$title).''; else print "".dol_htmlentities($appli).""; print "\n"; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 656e88ec83c..67757376569 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -106,7 +106,6 @@ if (empty($reshook)) { //obtidre selected del combobox $value=GETPOST('lt1'); - $object = new Societe($db); $object->fetch($socid); $res=$object->setValueFrom('localtax1_value', $value); } @@ -114,7 +113,6 @@ if (empty($reshook)) { //obtidre selected del combobox $value=GETPOST('lt2'); - $object = new Societe($db); $object->fetch($socid); $res=$object->setValueFrom('localtax2_value', $value); } @@ -583,14 +581,22 @@ if (empty($reshook)) * View */ -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('',$langs->trans("ThirdParty"),$help_url); - $form = new Form($db); $formfile = new FormFile($db); $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); +if ($socid > 0 && empty($object->id)) +{ + $res=$object->fetch($socid); + if ($result <= 0) dol_print_error('',$object->error); +} + +$title=$langs->trans("ThirdParty"); +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name; +$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('',$title,$help_url); + $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) @@ -598,12 +604,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (empty($object->error) && $socid) - { - $object = new Societe($db); - $result=$object->fetch($socid); - if ($result <= 0) dol_print_error('',$object->error); - } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->display_canvas($action); // Show template } @@ -1111,9 +1111,6 @@ else if ($socid) { - $object = new Societe($db); - $res=$object->fetch($socid); - if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); //if ($res < 0) { dol_print_error($db); exit; } @@ -1624,9 +1621,6 @@ else /* * View */ - $object = new Societe($db); - $res=$object->fetch($socid); - if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); //if ($res < 0) { dol_print_error($db); exit; } From 9876b303874ce14a00933b4ee74cbd5f14a18e17 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jan 2015 16:22:37 +0100 Subject: [PATCH 090/152] Need more info to find bugs --- htdocs/core/lib/functions.lib.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index cdb7e2b4d78..b2a2a7df949 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2405,19 +2405,22 @@ function dol_print_error($db='',$error='') if ($_SERVER['DOCUMENT_ROOT']) // Mode web { $out.=$langs->trans("DolibarrHasDetectedError").".
\n"; - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) - $out.="You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.
\n"; + if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $out.="You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.
\n"; $out.=$langs->trans("InformationToHelpDiagnose").":
\n"; - $out.="".$langs->trans("Date").": ".dol_print_date(time(),'dayhourlog')."
\n";; - $out.="".$langs->trans("Dolibarr").": ".DOL_VERSION."
\n";; - if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.="".$langs->trans("LevelOfFeature").": ".$conf->global->MAIN_FEATURES_LEVEL."
\n";; + $out.="".$langs->trans("Date").": ".dol_print_date(time(),'dayhourlog')."
\n"; + $out.="".$langs->trans("Dolibarr").": ".DOL_VERSION."
\n"; + if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.="".$langs->trans("LevelOfFeature").": ".$conf->global->MAIN_FEATURES_LEVEL."
\n"; if (function_exists("phpversion")) { $out.="".$langs->trans("PHP").": ".phpversion()."
\n"; - //phpinfo(); // This is to show location of php.ini file } $out.="".$langs->trans("Server").": ".$_SERVER["SERVER_SOFTWARE"]."
\n"; + if (function_exists("php_uname")) + { + $out.="".$langs->trans("OS").": ".php_uname()."
\n"; + } + $out.="".$langs->trans("UserAgent").": ".$_SERVER["HTTP_USER_AGENT"]."
\n"; $out.="
\n"; $out.="".$langs->trans("RequestedUrl").": ".dol_htmlentities($_SERVER["REQUEST_URI"],ENT_COMPAT,'UTF-8')."
\n"; $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?dol_htmlentities($_SERVER["HTTP_REFERER"],ENT_COMPAT,'UTF-8'):'')."
\n"; From a64084308d2c58d1f4ef89520a611ca050e775a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 18:12:43 +0100 Subject: [PATCH 091/152] Fix: [ bug #1804 ] SQL error when sending email without addresee --- COPYRIGHT | 3 +++ ChangeLog | 1 + htdocs/comm/propal.php | 14 +++++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index ed8a667acc8..7457542f060 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -52,6 +52,9 @@ http://www.fsf.org/licensing/licenses/index_html Copyright --------- +Copyright (C) 2015 +- Marcos García + Copyright (C) 2014 - Laurent Destailleur - Raphaël Doursenaud diff --git a/ChangeLog b/ChangeLog index 2a49b467783..da95f296432 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules +- Fix: [ bug #1804 ] SQL error when sending email without addresee ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 4929ee9c70e..57d2508aefe 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -9,6 +9,7 @@ * Copyright (C) 2010-2011 Philippe Grand * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2015 Marcos García * * 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 @@ -404,20 +405,23 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $langs->load('mails'); if ($object->id > 0) { + + $receiver = GETPOST('receiver'); + if ($_POST ['sendto']) { // Le destinataire a ete fourni via le champ libre $sendto = $_POST ['sendto']; $sendtoid = 0; - } elseif ($_POST ['receiver'] != '-1') { + } elseif ($receiver !== "") { // Recipient was provided from combo list - if ($_POST ['receiver'] == 'thirdparty') // Id of third party + if ($receiver == 'thirdparty') // Id of third party { $sendto = $object->client->email; $sendtoid = 0; - } else // Id du contact + } elseif ($receiver != '-1') // Id du contact { - $sendto = $object->client->contact_get_property($_POST ['receiver'], 'email'); - $sendtoid = $_POST ['receiver']; + $sendto = $object->client->contact_get_property($receiver, 'email'); + $sendtoid = $receiver; } } From 068045f6a0a7abb6a68c8b4c1c86aff9420dba24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 18:23:20 +0100 Subject: [PATCH 092/152] Fix: [ bug #1803 ] AJAX company contact input is not aligned --- ChangeLog | 2 +- htdocs/core/class/html.formcompany.class.php | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..08dc5861666 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules - +- Fix: [ bug #1803 ] AJAX company contact input is not aligned ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. - Fix: bug 1588 : relative discount. diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index a22f0b38c10..e33ff0a2072 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -610,8 +610,6 @@ class FormCompany } print "\n".''."\n"; - print ''; - print ''; - print ''; - print '
'; if ($obj->rowid == 0) { print ''; @@ -621,9 +619,6 @@ class FormCompany print ''; } print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php','',$minLength); - print '
'; print "\n"; return $socid; } From ed839114ab3b4fcc7f27f8a31f6c04c948af22b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 18:42:19 +0100 Subject: [PATCH 093/152] Fixed loading of external numeration modules in FactureFournisseur and Propal --- htdocs/comm/propal/class/propal.class.php | 13 ++++++++----- htdocs/fourn/class/fournisseur.facture.class.php | 10 +++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 846bb5acb10..84b0f65d679 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2564,11 +2564,14 @@ class Propal extends CommonObject $classname = $conf->global->PROPALE_ADDON; // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/propale/"; - // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/propale/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; } if (! $mybool) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 786d619665e..918baea1425 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1497,10 +1497,14 @@ class FactureFournisseur extends CommonInvoice $file = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER.".php"; $classname = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER; + // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/supplier_invoice/"; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/supplier_invoice/"); + // Load file with numbering class (if found) $mybool|=@include_once $dir.$file; } From 41e01a22a3dfb5aa762ec212d3199f04a21f51b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 18:58:05 +0100 Subject: [PATCH 094/152] Fixed loading of external numeration modules in Contrat, Commande, Facture, Contrat, Expedition, Fichinter, CommandeFournisseur and uniformized code --- htdocs/commande/class/commande.class.php | 17 ++-- htdocs/compta/facture/class/facture.class.php | 80 +++++++++++-------- htdocs/contrat/class/contrat.class.php | 38 +++++---- htdocs/expedition/class/expedition.class.php | 43 ++++++---- htdocs/fichinter/class/fichinter.class.php | 29 ++++--- .../class/fournisseur.commande.class.php | 54 +++++++------ 6 files changed, 155 insertions(+), 106 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 52e454bf14e..573778e808c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -137,17 +137,20 @@ class Commande extends CommonOrder $classname = $conf->global->COMMANDE_ADDON; // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/commande/"; - // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/commande/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; } if (! $mybool) { - dol_print_error('',"Failed to include file ".$file); - return ''; + dol_print_error('',"Failed to include file ".$file); + return ''; } $obj = new $classname(); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1df0696486c..63cdcaeb865 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2504,52 +2504,64 @@ class Facture extends CommonInvoice else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre'; else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure'; - $mybool=false; - - $file = $conf->global->FACTURE_ADDON.".php"; - $classname = $conf->global->FACTURE_ADDON; - // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) + if (! empty($conf->global->FACTURE_ADDON)) { - $dir = $dirroot."/core/modules/facture/"; - // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; - } + $mybool=false; + + $file = $conf->global->FACTURE_ADDON.".php"; + $classname = $conf->global->FACTURE_ADDON; - // For compatibility - if (! $mybool) - { - $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; - $classname = "mod_facture_".$conf->global->FACTURE_ADDON; - $classname = preg_replace('/\-.*$/','',$classname); // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/facture/"; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/facture/"); + // Load file with numbering class (if found) $mybool|=@include_once $dir.$file; } - } - //print "xx".$mybool.$dir.$file."-".$classname; - if (! $mybool) - { - dol_print_error('',"Failed to include file ".$file); - return ''; - } + // For compatibility + if (! $mybool) + { + $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; + $classname = "mod_facture_".$conf->global->FACTURE_ADDON; + $classname = preg_replace('/\-.*$/','',$classname); + // Include file with class + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot."/core/modules/facture/"; + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + } - $obj = new $classname(); - $numref = ""; - $numref = $obj->getNumRef($soc,$this,$mode); + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } - if ($numref != "") - { - return $numref; + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc,$this,$mode); + + if ($numref != "") + { + return $numref; + } + else + { + dol_print_error($db,"Facture::getNextNumRef ".$obj->error); + return ""; + } } else { - //dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); - return false; + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + return ""; } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 6cf04c10522..3e4605a8f2c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -92,23 +92,31 @@ class Contrat extends CommonObject global $db, $langs, $conf; $langs->load("contracts"); - $dir = DOL_DOCUMENT_ROOT . "/core/modules/contract"; - - if (empty($conf->global->CONTRACT_ADDON)) + if (!empty($conf->global->CONTRACT_ADDON)) { - $conf->global->CONTRACT_ADDON='mod_contract_serpis'; - } + $mybool = false; - $file = $conf->global->CONTRACT_ADDON.".php"; + $file = $conf->global->CONTRACT_ADDON.".php"; + $classname = $conf->global->CONTRACT_ADDON; - // Chargement de la classe de numerotation - $classname = $conf->global->CONTRACT_ADDON; + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/contract/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } - $result=include_once $dir.'/'.$file; - if ($result) - { $obj = new $classname(); - $numref = ""; $numref = $obj->getNextValue($soc,$this); @@ -118,15 +126,17 @@ class Contrat extends CommonObject } else { + $this->error = $obj->error; dol_print_error($db,get_class($this)."::getNextValue ".$obj->error); return ""; } } else { - print $langs->trans("Error")." ".$langs->trans("Error_CONTRACT_ADDON_NotDefined"); + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); return ""; - } + } } /** diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b6cdf5457d3..1045bed42be 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -119,21 +119,30 @@ class Expedition extends CommonObject global $db, $langs, $conf; $langs->load("sendings"); - $dir = DOL_DOCUMENT_ROOT . "/core/modules/expedition"; - - if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) + if (!empty($conf->global->EXPEDITION_ADDON_NUMBER)) { - $conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor'; - } + $mybool = false; - $file = $conf->global->EXPEDITION_ADDON_NUMBER.".php"; + $file = $conf->global->EXPEDITION_ADDON_NUMBER.".php"; + $classname = $conf->global->EXPEDITION_ADDON_NUMBER; - // Chargement de la classe de numerotation - $classname = $conf->global->EXPEDITION_ADDON_NUMBER; + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/expedition/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } - $result=include_once $dir.'/'.$file; - if ($result) - { $obj = new $classname(); $numref = ""; $numref = $obj->getNextValue($soc,$this); @@ -147,12 +156,12 @@ class Expedition extends CommonObject dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } - } - else - { - print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined"); - return ""; - } + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined"); + return ""; + } } /** diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 5c556ff2356..42c9208ff08 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -599,25 +599,33 @@ class Fichinter extends CommonObject global $conf, $db, $langs; $langs->load("interventions"); - $dir = DOL_DOCUMENT_ROOT . "/core/modules/fichinter/"; - if (! empty($conf->global->FICHEINTER_ADDON)) { + $mybool = false; + $file = $conf->global->FICHEINTER_ADDON.".php"; $classname = $conf->global->FICHEINTER_ADDON; - if (! file_exists($dir.$file)) - { - $file='mod_'.$file; - $classname='mod_'.$classname; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/fichinter/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; } - // Chargement de la classe de numerotation - require_once $dir.$file; + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } $obj = new $classname(); - $numref = ""; - $numref = $obj->getNumRef($soc,$this); + $numref = $obj->getNextValue($soc,$this); if ( $numref != "") { @@ -631,6 +639,7 @@ class Fichinter extends CommonObject } else { + $langs->load("errors"); print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"); return ""; } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3aa9d77f5de..8e618ba0eee 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -551,44 +551,50 @@ class CommandeFournisseur extends CommonOrder global $db, $langs, $conf; $langs->load("orders"); - $dir = DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/'; - if (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER)) { + $mybool = false; + $file = $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER.'.php'; + $classname=$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER; - if (is_readable($dir.'/'.$file)) + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/supplier_order/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + + if (! $mybool) { - // Definition du nom de modele de numerotation de commande fournisseur - $modName=$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER; - require_once $dir.'/'.$file; + dol_print_error('',"Failed to include file ".$file); + return ''; + } - // Recuperation de la nouvelle reference - $objMod = new $modName($this->db); + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc,$this); - $numref = ""; - $numref = $objMod->commande_get_num($soc,$this); - - if ( $numref != "") - { - return $numref; - } - else - { - dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error); - return -1; - } + if ( $numref != "") + { + return $numref; } else { - print $langs->trans("Error")." ".$langs->trans("Error_FailedToLoad_COMMANDE_SUPPLIER_ADDON_File",$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER); - return -2; + $this->error = $obj->error; + dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error); + return ""; } } else { - print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_SUPPLIER_ADDON_NotDefined"); - return -3; + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + return ""; } } From 103a433bdf912cb8bacd819f7a4192e2b778ccb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:00:44 +0100 Subject: [PATCH 095/152] Fix: [ bug #1796 ] Unable to use numeration modules from an external module --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..6b25a471b81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules +- Fix: [ bug #1796 ] Unable to use numeration modules from an external module ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. From cc9197e4c85df1daae9c66dbdddd20348d9c1f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:13:38 +0100 Subject: [PATCH 096/152] Fixed problem with Fichinter::getNextNumRef --- htdocs/fichinter/class/fichinter.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 42c9208ff08..c1ec1bef0fc 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -603,8 +603,8 @@ class Fichinter extends CommonObject { $mybool = false; - $file = $conf->global->FICHEINTER_ADDON.".php"; - $classname = $conf->global->FICHEINTER_ADDON; + $file = "mod_".$conf->global->FICHEINTER_ADDON.".php"; + $classname = "mod_".$conf->global->FICHEINTER_ADDON; // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); From 7f59cf919403d858f00fd3028e6eab875b03d96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:28:27 +0100 Subject: [PATCH 097/152] Fix: [ bug #1787 ] Incorrect behaviour of doActions hook --- ChangeLog | 1 + htdocs/adherents/fiche.php | 942 ++++----- htdocs/comm/fiche.php | 132 +- htdocs/comm/mailing/fiche.php | 902 ++++---- htdocs/comm/propal.php | 1704 +++++++-------- htdocs/comm/prospect/list.php | 12 +- htdocs/commande/fiche.php | 2137 +++++++++---------- htdocs/compta/facture.php | 3289 +++++++++++++++-------------- htdocs/compta/paiement.php | 330 +-- htdocs/expedition/fiche.php | 882 ++++---- htdocs/fourn/facture/paiement.php | 262 +-- htdocs/fourn/fiche.php | 57 +- htdocs/product/document.php | 12 +- htdocs/product/fournisseurs.php | 204 +- htdocs/resource/card.php | 69 +- 15 files changed, 5480 insertions(+), 5455 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..e19f3947a59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules +- Fix: [ bug #1787 ] Incorrect behaviour of doActions hook ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index ef04edeeb53..97d71d1572a 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -121,556 +121,558 @@ $hookmanager->initHooks(array('membercard')); $parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) -{ - $error=0; - if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only - { - if ($userid != $user->id && $userid != $object->user_id) - { - $error++; - $mesg='
'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'
'; - } - } +if (empty($reshook)) { - if (! $error) + if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { - if ($userid != $object->user_id) // If link differs from currently in database + $error=0; + if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only { - $result=$object->setUserId($userid); - if ($result < 0) dol_print_error($object->db,$object->error); - $action=''; - } - } -} - -if ($action == 'setsocid') -{ - $error=0; - if (! $error) - { - if ($socid != $object->fk_soc) // If link differs from currently in database - { - $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql.=" WHERE fk_soc = '".$socid."'"; - $sql.=" AND entity = ".$conf->entity; - $resql = $db->query($sql); - if ($resql) + if ($userid != $user->id && $userid != $object->user_id) { - $obj = $db->fetch_object($resql); - if ($obj && $obj->rowid > 0) - { - $othermember=new Adherent($db); - $othermember->fetch($obj->rowid); - $thirdparty=new Societe($db); - $thirdparty->fetch($socid); - $error++; - $errmsg='
'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'
'; - } + $error++; + $mesg='
'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'
'; } + } - if (! $error) + if (! $error) + { + if ($userid != $object->user_id) // If link differs from currently in database { - $result=$object->setThirdPartyId($socid); + $result=$object->setUserId($userid); if ($result < 0) dol_print_error($object->db,$object->error); $action=''; } } } -} -// Create user from a member -if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) -{ - if ($result > 0) + if ($action == 'setsocid') { - // Creation user - $nuser = new User($db); - $result=$nuser->create_from_member($object,GETPOST('login')); - - if ($result < 0) + $error=0; + if (! $error) { - $langs->load("errors"); - $errmsg=$langs->trans($nuser->error); - } - } - else - { - $errmsg=$object->error; - } -} - -// Create third party from a member -if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) -{ - if ($result > 0) - { - // Creation user - $company = new Societe($db); - $result=$company->create_from_member($object,GETPOST('companyname')); - - if ($result < 0) - { - $langs->load("errors"); - $errmsg=$langs->trans($company->error); - $errmsgs=$company->errors; - } - } - else - { - $errmsg=$object->error; - } -} - -if ($action == 'confirm_sendinfo' && $confirm == 'yes') -{ - if ($object->email) - { - $from=$conf->email_from; - if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM; - - $result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent")); - - $langs->load("mails"); - $mesg=$langs->trans("MailSuccessfulySent", $from, $object->email); - } -} - -if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $birthdate=''; - if (isset($_POST["birthday"]) && $_POST["birthday"] - && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) - { - $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); - } - $lastname=$_POST["lastname"]; - $firstname=$_POST["firstname"]; - $morphy=$morphy=$_POST["morphy"];; - if ($morphy != 'mor' && empty($lastname)) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."
\n"; - } - if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; - } - - // Create new object - if ($result > 0 && ! $error) - { - $object->oldcopy=dol_clone($object); - - // Change values - $object->civility_id = trim($_POST["civility_id"]); - $object->firstname = trim($_POST["firstname"]); - $object->lastname = trim($_POST["lastname"]); - $object->login = trim($_POST["login"]); - $object->pass = trim($_POST["pass"]); - - $object->societe = trim($_POST["societe"]); - $object->company = trim($_POST["societe"]); - - $object->address = trim($_POST["address"]); - $object->zip = trim($_POST["zipcode"]); - $object->town = trim($_POST["town"]); - $object->state_id = $_POST["state_id"]; - $object->country_id = $_POST["country_id"]; - - $object->phone = trim($_POST["phone"]); - $object->phone_perso = trim($_POST["phone_perso"]); - $object->phone_mobile= trim($_POST["phone_mobile"]); - $object->email = trim($_POST["email"]); - $object->skype = trim($_POST["skype"]); - $object->birth = $birthdate; - - $object->typeid = $_POST["typeid"]; - //$object->note = trim($_POST["comment"]); - $object->morphy = $_POST["morphy"]; - - $object->amount = $_POST["amount"]; - - if (GETPOST('deletephoto')) $object->photo=''; - elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); - - // Get status and public property - $object->statut = $_POST["statut"]; - $object->public = $_POST["public"]; - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); - - // Check if we need to also synchronize user information - $nosyncuser=0; - if ($object->user_id) // If linked to a user - { - if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing - } - - // Check if we need to also synchronize password information - $nosyncuserpass=0; - if ($object->user_id) // If linked to a user - { - if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing - } - - $result=$object->update($user,0,$nosyncuser,$nosyncuserpass); - if ($result >= 0 && ! count($object->errors)) - { - // Logo/Photo save - $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos'; - $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if ($file_OK) + if ($socid != $object->fk_soc) // If link differs from currently in database { - if (GETPOST('deletephoto')) + $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; + $sql.=" WHERE fk_soc = '".$socid."'"; + $sql.=" AND entity = ".$conf->entity; + $resql = $db->query($sql); + if ($resql) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/'.$object->photo; - $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); + $obj = $db->fetch_object($resql); + if ($obj && $obj->rowid > 0) + { + $othermember=new Adherent($db); + $othermember->fetch($obj->rowid); + $thirdparty=new Societe($db); + $thirdparty->fetch($socid); + $error++; + $errmsg='
'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'
'; + } } - if (image_format_supported($_FILES['photo']['name']) > 0) + if (! $error) { - dol_mkdir($dir); + $result=$object->setThirdPartyId($socid); + if ($result < 0) dol_print_error($object->db,$object->error); + $action=''; + } + } + } + } - if (@is_dir($dir)) + // Create user from a member + if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) + { + if ($result > 0) + { + // Creation user + $nuser = new User($db); + $result=$nuser->create_from_member($object,GETPOST('login')); + + if ($result < 0) + { + $langs->load("errors"); + $errmsg=$langs->trans($nuser->error); + } + } + else + { + $errmsg=$object->error; + } + } + + // Create third party from a member + if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) + { + if ($result > 0) + { + // Creation user + $company = new Societe($db); + $result=$company->create_from_member($object,GETPOST('companyname')); + + if ($result < 0) + { + $langs->load("errors"); + $errmsg=$langs->trans($company->error); + $errmsgs=$company->errors; + } + } + else + { + $errmsg=$object->error; + } + } + + if ($action == 'confirm_sendinfo' && $confirm == 'yes') + { + if ($object->email) + { + $from=$conf->email_from; + if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM; + + $result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent")); + + $langs->load("mails"); + $mesg=$langs->trans("MailSuccessfulySent", $from, $object->email); + } + } + + if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $birthdate=''; + if (isset($_POST["birthday"]) && $_POST["birthday"] + && isset($_POST["birthmonth"]) && $_POST["birthmonth"] + && isset($_POST["birthyear"]) && $_POST["birthyear"]) + { + $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); + } + $lastname=$_POST["lastname"]; + $firstname=$_POST["firstname"]; + $morphy=$morphy=$_POST["morphy"];; + if ($morphy != 'mor' && empty($lastname)) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."
\n"; + } + if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; + } + + // Create new object + if ($result > 0 && ! $error) + { + $object->oldcopy=dol_clone($object); + + // Change values + $object->civility_id = trim($_POST["civility_id"]); + $object->firstname = trim($_POST["firstname"]); + $object->lastname = trim($_POST["lastname"]); + $object->login = trim($_POST["login"]); + $object->pass = trim($_POST["pass"]); + + $object->societe = trim($_POST["societe"]); + $object->company = trim($_POST["societe"]); + + $object->address = trim($_POST["address"]); + $object->zip = trim($_POST["zipcode"]); + $object->town = trim($_POST["town"]); + $object->state_id = $_POST["state_id"]; + $object->country_id = $_POST["country_id"]; + + $object->phone = trim($_POST["phone"]); + $object->phone_perso = trim($_POST["phone_perso"]); + $object->phone_mobile= trim($_POST["phone_mobile"]); + $object->email = trim($_POST["email"]); + $object->skype = trim($_POST["skype"]); + $object->birth = $birthdate; + + $object->typeid = $_POST["typeid"]; + //$object->note = trim($_POST["comment"]); + $object->morphy = $_POST["morphy"]; + + $object->amount = $_POST["amount"]; + + if (GETPOST('deletephoto')) $object->photo=''; + elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + + // Get status and public property + $object->statut = $_POST["statut"]; + $object->public = $_POST["public"]; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + + // Check if we need to also synchronize user information + $nosyncuser=0; + if ($object->user_id) // If linked to a user + { + if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing + } + + // Check if we need to also synchronize password information + $nosyncuserpass=0; + if ($object->user_id) // If linked to a user + { + if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing + } + + $result=$object->update($user,0,$nosyncuser,$nosyncuserpass); + if ($result >= 0 && ! count($object->errors)) + { + // Logo/Photo save + $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos'; + $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); + if ($file_OK) + { + if (GETPOST('deletephoto')) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0) - { - $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; - } - else - { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/'.$object->photo; + $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + } - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + if (image_format_supported($_FILES['photo']['name']) > 0) + { + dol_mkdir($dir); + + if (@is_dir($dir)) + { + $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0) + { + $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; + } + else + { + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + } } } + else + { + $errmsgs[] = "ErrorBadImageFormat"; + } } else { - $errmsgs[] = "ErrorBadImageFormat"; + switch($_FILES['photo']['error']) + { + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $errors[] = "ErrorFileSizeTooLarge"; + break; + case 3: //uploaded file was only partially uploaded + $errors[] = "ErrorFilePartiallyUploaded"; + break; + } + } + + $rowid=$object->id; + $action=''; + + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; } } else { - switch($_FILES['photo']['error']) - { - case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini - case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form - $errors[] = "ErrorFileSizeTooLarge"; - break; - case 3: //uploaded file was only partially uploaded - $errors[] = "ErrorFilePartiallyUploaded"; - break; + if ($object->error) $errmsg=$object->error; + else $errmsgs=$object->errors; + $action=''; + } + } + else + { + $action='edit'; + } + } + + if ($action == 'add' && $user->rights->adherent->creer) + { + if ($canvas) $object->canvas=$canvas; + $birthdate=''; + if (isset($_POST["birthday"]) && $_POST["birthday"] + && isset($_POST["birthmonth"]) && $_POST["birthmonth"] + && isset($_POST["birthyear"]) && $_POST["birthyear"]) + { + $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); + } + $datecotisation=''; + if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) + { + $datecotisation=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + } + + $typeid=$_POST["typeid"]; + $civility_id=$_POST["civility_id"]; + $lastname=$_POST["lastname"]; + $firstname=$_POST["firstname"]; + $societe=$_POST["societe"]; + $address=$_POST["address"]; + $zip=$_POST["zipcode"]; + $town=$_POST["town"]; + $state_id=$_POST["state_id"]; + $country_id=$_POST["country_id"]; + + $phone=$_POST["phone"]; + $phone_perso=$_POST["phone_perso"]; + $phone_mobile=$_POST["phone_mobile"]; + $skype=$_POST["member_skype"]; + $email=$_POST["member_email"]; + $login=$_POST["member_login"]; + $pass=$_POST["password"]; + $photo=$_POST["photo"]; + //$comment=$_POST["comment"]; + $morphy=$_POST["morphy"]; + $cotisation=$_POST["cotisation"]; + $public=$_POST["public"]; + + $userid=$_POST["userid"]; + $socid=$_POST["socid"]; + + $object->civility_id = $civility_id; + $object->firstname = $firstname; + $object->lastname = $lastname; + $object->societe = $societe; + $object->address = $address; + $object->zip = $zip; + $object->town = $town; + $object->state_id = $state_id; + $object->country_id = $country_id; + $object->phone = $phone; + $object->phone_perso = $phone_perso; + $object->phone_mobile= $phone_mobile; + $object->skype = $skype; + $object->email = $email; + $object->login = $login; + $object->pass = $pass; + $object->naiss = $birthdate; + $object->photo = $photo; + $object->typeid = $typeid; + //$object->note = $comment; + $object->morphy = $morphy; + $object->user_id = $userid; + $object->fk_soc = $socid; + $object->public = $public; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + + // Check parameters + if (empty($morphy) || $morphy == "-1") { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature"))."
\n"; + } + // Test si le login existe deja + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + if (empty($login)) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."
\n"; + } + else { + $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + } + if ($num) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."
\n"; } } + if (empty($pass)) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."
\n"; + } + } + if ($morphy != 'mor' && empty($lastname)) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."
\n"; + } + if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; + } + if (! ($typeid > 0)) { // Keep () before ! + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))."
\n"; + } + if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorBadEMail",$email)."
\n"; + } + $public=0; + if (isset($public)) $public=1; - $rowid=$object->id; - $action=''; + if (! $error) + { + $db->begin(); + // Email a peu pres correct et le login n'existe pas + $result=$object->create($user); + if ($result > 0) + { + $db->commit(); + $rowid=$object->id; + $action=''; + } + else + { + $db->rollback(); + + if ($object->error) $errmsg=$object->error; + else $errmsgs=$object->errors; + + $action = 'create'; + } + } + else { + $action = 'create'; + } + } + + if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') + { + $result=$object->delete($rowid); + if ($result > 0) + { if (! empty($backtopage)) { header("Location: ".$backtopage); exit; } + else + { + header("Location: liste.php"); + exit; + } } else { - if ($object->error) $errmsg=$object->error; - else $errmsgs=$object->errors; - $action=''; + $errmesg=$object->error; } } - else + + if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') { - $action='edit'; - } -} + $error=0; -if ($action == 'add' && $user->rights->adherent->creer) -{ - if ($canvas) $object->canvas=$canvas; - $birthdate=''; - if (isset($_POST["birthday"]) && $_POST["birthday"] - && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) - { - $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); - } - $datecotisation=''; - if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) - { - $datecotisation=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - } - - $typeid=$_POST["typeid"]; - $civility_id=$_POST["civility_id"]; - $lastname=$_POST["lastname"]; - $firstname=$_POST["firstname"]; - $societe=$_POST["societe"]; - $address=$_POST["address"]; - $zip=$_POST["zipcode"]; - $town=$_POST["town"]; - $state_id=$_POST["state_id"]; - $country_id=$_POST["country_id"]; - - $phone=$_POST["phone"]; - $phone_perso=$_POST["phone_perso"]; - $phone_mobile=$_POST["phone_mobile"]; - $skype=$_POST["member_skype"]; - $email=$_POST["member_email"]; - $login=$_POST["member_login"]; - $pass=$_POST["password"]; - $photo=$_POST["photo"]; - //$comment=$_POST["comment"]; - $morphy=$_POST["morphy"]; - $cotisation=$_POST["cotisation"]; - $public=$_POST["public"]; - - $userid=$_POST["userid"]; - $socid=$_POST["socid"]; - - $object->civility_id = $civility_id; - $object->firstname = $firstname; - $object->lastname = $lastname; - $object->societe = $societe; - $object->address = $address; - $object->zip = $zip; - $object->town = $town; - $object->state_id = $state_id; - $object->country_id = $country_id; - $object->phone = $phone; - $object->phone_perso = $phone_perso; - $object->phone_mobile= $phone_mobile; - $object->skype = $skype; - $object->email = $email; - $object->login = $login; - $object->pass = $pass; - $object->naiss = $birthdate; - $object->photo = $photo; - $object->typeid = $typeid; - //$object->note = $comment; - $object->morphy = $morphy; - $object->user_id = $userid; - $object->fk_soc = $socid; - $object->public = $public; - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); - - // Check parameters - if (empty($morphy) || $morphy == "-1") { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature"))."
\n"; - } - // Test si le login existe deja - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { - if (empty($login)) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."
\n"; - } - else { - $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - } - if ($num) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."
\n"; - } - } - if (empty($pass)) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."
\n"; - } - } - if ($morphy != 'mor' && empty($lastname)) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."
\n"; - } - if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; - } - if (! ($typeid > 0)) { // Keep () before ! - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))."
\n"; - } - if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadEMail",$email)."
\n"; - } - $public=0; - if (isset($public)) $public=1; - - if (! $error) - { $db->begin(); - // Email a peu pres correct et le login n'existe pas - $result=$object->create($user); - if ($result > 0) + $adht = new AdherentType($db); + $adht->fetch($object->typeid); + + $result=$object->validate($user); + + if ($result >= 0 && ! count($object->errors)) + { + // Send confirmation Email (selon param du type adherent sinon generique) + if ($object->email && GETPOST("send_mail")) + { + $result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); + if ($result < 0) + { + $error++; + $errmsg.=$object->error; + } + } + } + else + { + $error++; + if ($object->error) $errmsg=$object->error; + else $errmsgs=$object->errors; + } + + if (! $error) { $db->commit(); - $rowid=$object->id; - $action=''; } else { $db->rollback(); - - if ($object->error) $errmsg=$object->error; - else $errmsgs=$object->errors; - - $action = 'create'; } + $action=''; } - else { - $action = 'create'; - } -} -if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') -{ - $result=$object->delete($rowid); - if ($result > 0) + if ($user->rights->adherent->supprimer && $action == 'confirm_resign') { - if (! empty($backtopage)) + if ($confirm == 'yes') + { + $adht = new AdherentType($db); + $adht->fetch($object->typeid); + + $result=$object->resiliate($user); + + if ($result >= 0 && ! count($object->errors)) + { + if ($object->email && GETPOST("send_mail")) + { + $result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1); + } + if ($result < 0) + { + $errmsg.=$object->error; + } + } + else + { + if ($object->error) $errmsg=$object->error; + else $errmsgs=$object->errors; + $action=''; + } + } + if (! empty($backtopage) && ! $errmsg) { header("Location: ".$backtopage); exit; } - else - { - header("Location: liste.php"); - exit; - } } - else + + // SPIP Management + if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') { - $errmesg=$object->error; - } -} - -if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') -{ - $error=0; - - $db->begin(); - - $adht = new AdherentType($db); - $adht->fetch($object->typeid); - - $result=$object->validate($user); - - if ($result >= 0 && ! count($object->errors)) - { - // Send confirmation Email (selon param du type adherent sinon generique) - if ($object->email && GETPOST("send_mail")) + if (! count($object->errors)) { - $result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); - if ($result < 0) + if (!$mailmanspip->del_to_spip($object)) { - $error++; - $errmsg.=$object->error; + $errmsg.= $langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error."
\n"; } } } - else - { - $error++; - if ($object->error) $errmsg=$object->error; - else $errmsgs=$object->errors; - } - if (! $error) + if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') { - $db->commit(); - } - else - { - $db->rollback(); - } - $action=''; -} - -if ($user->rights->adherent->supprimer && $action == 'confirm_resign') -{ - if ($confirm == 'yes') - { - $adht = new AdherentType($db); - $adht->fetch($object->typeid); - - $result=$object->resiliate($user); - - if ($result >= 0 && ! count($object->errors)) + if (! count($object->errors)) { - if ($object->email && GETPOST("send_mail")) + if (!$mailmanspip->add_to_spip($object)) { - $result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1); - } - if ($result < 0) - { - $errmsg.=$object->error; + $errmsg.= $langs->trans('AddIntoSpipError').': '.$mailmanspip->error."
\n"; } } - else - { - if ($object->error) $errmsg=$object->error; - else $errmsgs=$object->errors; - $action=''; - } - } - if (! empty($backtopage) && ! $errmsg) - { - header("Location: ".$backtopage); - exit; } } -// SPIP Management -if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') -{ - if (! count($object->errors)) - { - if (!$mailmanspip->del_to_spip($object)) - { - $errmsg.= $langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error."
\n"; - } - } -} - -if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') -{ - if (! count($object->errors)) - { - if (!$mailmanspip->add_to_spip($object)) - { - $errmsg.= $langs->trans('AddIntoSpipError').': '.$mailmanspip->error."
\n"; - } - } -} - - /* * View diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 307a8c57385..0741b468ed9 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -79,76 +79,78 @@ $object = new Societe($db); $parameters = array('socid' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some -//Some actions show a "cancel" input submit button with name="cancel" -$cancelbutton = GETPOST('cancel'); +if (empty($reshook)) { + //Some actions show a "cancel" input submit button with name="cancel" + $cancelbutton = GETPOST('cancel'); -if ($action == 'setcustomeraccountancycode') -{ - if (!$cancelbutton) { - $result=$object->fetch($id); - $object->code_compta=$_POST["customeraccountancycode"]; - $result=$object->update($object->id,$user,1,1,0); - if ($result < 0) - { - $mesgs[]=join(',',$object->errors); + if ($action == 'setcustomeraccountancycode') + { + if (!$cancelbutton) { + $result=$object->fetch($id); + $object->code_compta=$_POST["customeraccountancycode"]; + $result=$object->update($object->id,$user,1,1,0); + if ($result < 0) + { + $mesgs[]=join(',',$object->errors); + } + $action=""; } - $action=""; } -} -// conditions de reglement -if ($action == 'setconditions' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); - if ($result < 0) dol_print_error($db,$object->error); -} -// mode de reglement -if ($action == 'setmode' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); - if ($result < 0) dol_print_error($db,$object->error); -} -// assujetissement a la TVA -if ($action == 'setassujtva' && $user->rights->societe->creer) -{ - $object->fetch($id); - $object->tva_assuj=$_POST['assujtva_value']; - - // TODO move to DAO class - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE rowid='".$id."'"; - $result = $db->query($sql); - if (! $result) dol_print_error($result); -} - -// set prospect level -if ($action == 'setprospectlevel' && $user->rights->societe->creer) -{ - $object->fetch($id); - $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); - $result=$object->set_prospect_level($user); - if ($result < 0) setEventMessage($object->error,'errors'); -} - -// Update communication level -if ($action == 'cstc') -{ - $object->fetch($id); - $object->stcomm_id=GETPOST('stcomm','int'); - $result=$object->set_commnucation_level($user); - if ($result < 0) setEventMessage($object->error,'errors'); -} - -// Update communication level -if ($action == 'setOutstandingBill') -{ - if (!$cancelbutton) { + // conditions de reglement + if ($action == 'setconditions' && $user->rights->societe->creer) + { $object->fetch($id); - $object->outstanding_limit = GETPOST('OutstandingBill'); - $result = $object->set_OutstandingBill($user); - if ($result < 0) { - setEventMessage($object->error, 'errors'); + $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); + if ($result < 0) dol_print_error($db,$object->error); + } + // mode de reglement + if ($action == 'setmode' && $user->rights->societe->creer) + { + $object->fetch($id); + $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); + if ($result < 0) dol_print_error($db,$object->error); + } + // assujetissement a la TVA + if ($action == 'setassujtva' && $user->rights->societe->creer) + { + $object->fetch($id); + $object->tva_assuj=$_POST['assujtva_value']; + + // TODO move to DAO class + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE rowid='".$id."'"; + $result = $db->query($sql); + if (! $result) dol_print_error($result); + } + + // set prospect level + if ($action == 'setprospectlevel' && $user->rights->societe->creer) + { + $object->fetch($id); + $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); + $result=$object->set_prospect_level($user); + if ($result < 0) setEventMessage($object->error,'errors'); + } + + // Update communication level + if ($action == 'cstc') + { + $object->fetch($id); + $object->stcomm_id=GETPOST('stcomm','int'); + $result=$object->set_commnucation_level($user); + if ($result < 0) setEventMessage($object->error,'errors'); + } + + // Update communication level + if ($action == 'setOutstandingBill') + { + if (!$cancelbutton) { + $object->fetch($id); + $object->outstanding_limit = GETPOST('OutstandingBill'); + $result = $object->set_OutstandingBill($user); + if ($result < 0) { + setEventMessage($object->error, 'errors'); + } } } } diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index d803de28357..6e7546fb70d 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -102,446 +102,390 @@ $object->substitutionarrayfortest=array( $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') -{ - if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) +if (empty($reshook)) { + + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes') { - $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; - } - else - { - $result=$object->createFromClone($object->id,$_REQUEST["clone_content"],$_REQUEST["clone_receivers"]); - if ($result > 0) + if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); - exit; + $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; } else { - $mesg=$object->error; - } - } - $action=''; -} - -// Action send emailing for everybody -if ($action == 'sendallconfirmed' && $confirm == 'yes') -{ - if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) - { - // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, - // on affiche donc juste un message - $mesg='
'.$langs->trans("MailingNeedCommand").'
'; - $mesg.='
'; - $mesg.='

'.$langs->trans("MailingNeedCommand2").'
'; - $action=''; - } - else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) - { - $mesg='
'.$langs->trans("NotEnoughPermissions").'
'; - $action=''; - } - else - { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - if ($object->statut == 0) - { - dol_print_error('','ErrorMailIsNotValidated'); - exit; - } - - $id = $object->id; - $subject = $object->sujet; - $message = $object->body; - $from = $object->email_from; - $replyto = $object->email_replyto; - $errorsto = $object->email_errorsto; - // Le message est-il en html - $msgishtml=-1; // Unknown by default - if (preg_match('/[\s\t]*/i',$message)) $msgishtml=1; - - // Warning, we must not use begin-commit transaction here - // because we want to save update for each mail sent. - - $nbok=0; $nbko=0; - - // On choisit les mails non deja envoyes pour ce mailing (statut=0) - // ou envoyes en erreur (statut=-1) - $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; - $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; - - dol_syslog("fiche.php: select targets sql=".$sql, LOG_DEBUG); - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); // nb of possible recipients - - if ($num) + $result=$object->createFromClone($object->id,$_REQUEST["clone_content"],$_REQUEST["clone_receivers"]); + if ($result > 0) { - dol_syslog("comm/mailing/fiche.php: nb of targets = ".$num, LOG_DEBUG); + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + $mesg=$object->error; + } + } + $action=''; + } - $now=dol_now(); + // Action send emailing for everybody + if ($action == 'sendallconfirmed' && $confirm == 'yes') + { + if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) + { + // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, + // on affiche donc juste un message + $mesg='
'.$langs->trans("MailingNeedCommand").'
'; + $mesg.='
'; + $mesg.='

'.$langs->trans("MailingNeedCommand2").'
'; + $action=''; + } + else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) + { + $mesg='
'.$langs->trans("NotEnoughPermissions").'
'; + $action=''; + } + else + { + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - // Positionne date debut envoi - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=".$db->idate($now)." WHERE rowid=".$object->id; + if ($object->statut == 0) + { + dol_print_error('','ErrorMailIsNotValidated'); + exit; + } + + $id = $object->id; + $subject = $object->sujet; + $message = $object->body; + $from = $object->email_from; + $replyto = $object->email_replyto; + $errorsto = $object->email_errorsto; + // Le message est-il en html + $msgishtml=-1; // Unknown by default + if (preg_match('/[\s\t]*/i',$message)) $msgishtml=1; + + // Warning, we must not use begin-commit transaction here + // because we want to save update for each mail sent. + + $nbok=0; $nbko=0; + + // On choisit les mails non deja envoyes pour ce mailing (statut=0) + // ou envoyes en erreur (statut=-1) + $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; + + dol_syslog("fiche.php: select targets sql=".$sql, LOG_DEBUG); + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); // nb of possible recipients + + if ($num) + { + dol_syslog("comm/mailing/fiche.php: nb of targets = ".$num, LOG_DEBUG); + + $now=dol_now(); + + // Positionne date debut envoi + $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=".$db->idate($now)." WHERE rowid=".$object->id; + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + + // Loop on each email and send it + $i = 0; + + while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) + { + + $res=1; + + $obj = $db->fetch_object($resql); + + // sendto en RFC2822 + $sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname))." <".$obj->email.">"; + + // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... + $other=explode(';',$obj->other); + $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) + $substitutionarray=array( + '__ID__' => $obj->source_id, + '__EMAIL__' => $obj->email, + '__LASTNAME__' => $obj->lastname, + '__FIRSTNAME__' => $obj->firstname, + '__MAILTOEMAIL__' => '
'.$obj->email.'', + '__OTHER1__' => $other1, + '__OTHER2__' => $other2, + '__OTHER3__' => $other3, + '__OTHER4__' => $other4, + '__OTHER5__' => $other5, + '__CHECK_READ__' => '', + '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'' + ); + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); + } + $substitutionisok=true; + complete_substitutions_array($substitutionarray, $langs); + $newsubject=make_substitutions($subject,$substitutionarray); + $newmessage=make_substitutions($message,$substitutionarray); + + $arr_file = array(); + $arr_mime = array(); + $arr_name = array(); + $arr_css = array(); + + $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); + if (count($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $arr_file[]=$listofpaths[$key]['fullname']; + $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); + $arr_name[]=$listofpaths[$key]['name']; + } + } + + // Fabrication du mail + $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css); + + if ($mail->error) + { + $res=0; + } + if (! $substitutionisok) + { + $mail->error='Some substitution failed'; + $res=0; + } + + // Send mail + if ($res) + { + $res=$mail->sendfile(); + } + + if ($res) + { + // Mail successful + $nbok++; + + dol_syslog("comm/mailing/fiche.php: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); + + $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql.=" SET statut=1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid; + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + else + { + //if cheack read is use then update prospect contact status + if (strpos($message, '__CHECK_READ__') !== false) + { + //Update status communication of thirdparty prospect + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")"; + dol_syslog("fiche.php: set prospect thirdparty status sql=".$sql, LOG_DEBUG); + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + + //Update status communication of contact prospect + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; + dol_syslog("fiche.php: set prospect contact status sql=".$sql, LOG_DEBUG); + + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + } + } + + + //test if CHECK READ change statut prospect contact + } + else + { + // Mail failed + $nbko++; + + dol_syslog("comm/mailing/fiche.php: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_WARNING); + + $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid; + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + } + + $i++; + } + } + else + { + setEventMessage($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo")); + } + + // Loop finished, set global statut of mail + if ($nbko > 0) + { + $statut=2; // Status 'sent partially' (because at least one error) + if ($nbok > 0) setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + } + else + { + if ($nbok >= $num) + { + $statut=3; // Send to everybody + setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + } + else + { + $statut=2; // Status 'sent partially' (because not send to everybody) + setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + } + } + + $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; + dol_syslog("comm/mailing/fiche.php: update global status sql=".$sql, LOG_DEBUG); $resql2=$db->query($sql); if (! $resql2) { dol_print_error($db); } - - // Loop on each email and send it - $i = 0; - - while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) - { - - $res=1; - - $obj = $db->fetch_object($resql); - - // sendto en RFC2822 - $sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname))." <".$obj->email.">"; - - // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... - $other=explode(';',$obj->other); - $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) - $substitutionarray=array( - '__ID__' => $obj->source_id, - '__EMAIL__' => $obj->email, - '__LASTNAME__' => $obj->lastname, - '__FIRSTNAME__' => $obj->firstname, - '__MAILTOEMAIL__' => ''.$obj->email.'', - '__OTHER1__' => $other1, - '__OTHER2__' => $other2, - '__OTHER3__' => $other3, - '__OTHER4__' => $other4, - '__OTHER5__' => $other5, - '__CHECK_READ__' => '', - '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'' - ); - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); - } - $substitutionisok=true; - complete_substitutions_array($substitutionarray, $langs); - $newsubject=make_substitutions($subject,$substitutionarray); - $newmessage=make_substitutions($message,$substitutionarray); - - $arr_file = array(); - $arr_mime = array(); - $arr_name = array(); - $arr_css = array(); - - $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); - if (count($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $arr_file[]=$listofpaths[$key]['fullname']; - $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); - $arr_name[]=$listofpaths[$key]['name']; - } - } - - // Fabrication du mail - $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css); - - if ($mail->error) - { - $res=0; - } - if (! $substitutionisok) - { - $mail->error='Some substitution failed'; - $res=0; - } - - // Send mail - if ($res) - { - $res=$mail->sendfile(); - } - - if ($res) - { - // Mail successful - $nbok++; - - dol_syslog("comm/mailing/fiche.php: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); - - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid; - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - else - { - //if cheack read is use then update prospect contact status - if (strpos($message, '__CHECK_READ__') !== false) - { - //Update status communication of thirdparty prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")"; - dol_syslog("fiche.php: set prospect thirdparty status sql=".$sql, LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - - //Update status communication of contact prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; - dol_syslog("fiche.php: set prospect contact status sql=".$sql, LOG_DEBUG); - - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - } - } - - - //test if CHECK READ change statut prospect contact - } - else - { - // Mail failed - $nbko++; - - dol_syslog("comm/mailing/fiche.php: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_WARNING); - - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid; - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - } - - $i++; - } } else { - setEventMessage($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo")); - } - - // Loop finished, set global statut of mail - if ($nbko > 0) - { - $statut=2; // Status 'sent partially' (because at least one error) - if ($nbok > 0) setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - } - else - { - if ($nbok >= $num) - { - $statut=3; // Send to everybody - setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - } - else - { - $statut=2; // Status 'sent partially' (because not send to everybody) - setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - } - } - - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; - dol_syslog("comm/mailing/fiche.php: update global status sql=".$sql, LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) - { + dol_syslog($db->error()); dol_print_error($db); } + + $action = ''; } - else - { - dol_syslog($db->error()); - dol_print_error($db); - } - - $action = ''; - } -} - -// Action send test emailing -if ($action == 'send' && empty($_POST["cancel"])) -{ - $error=0; - - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - $object->sendto = $_POST["sendto"]; - if (! $object->sendto) - { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("MailTo")).'
'; - $error++; } - if (! $error) + // Action send test emailing + if ($action == 'send' && empty($_POST["cancel"])) { - // Le message est-il en html - $msgishtml=-1; // Inconnu par defaut - if (preg_match('/[\s\t]*/i',$object->body)) $msgishtml=1; + $error=0; - // Pratique les substitutions sur le sujet et message - $tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest); - $tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest); + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - $arr_file = array(); - $arr_mime = array(); - $arr_name = array(); - $arr_css = array(); - - // Ajout CSS - if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/',$object->bgcolor)?'':'#').$object->bgcolor; - if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; - - // Attached files - $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); - if (count($listofpaths)) + $object->sendto = $_POST["sendto"]; + if (! $object->sendto) { - foreach($listofpaths as $key => $val) + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("MailTo")).'
'; + $error++; + } + + if (! $error) + { + // Le message est-il en html + $msgishtml=-1; // Inconnu par defaut + if (preg_match('/[\s\t]*/i',$object->body)) $msgishtml=1; + + // Pratique les substitutions sur le sujet et message + $tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest); + $tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest); + + $arr_file = array(); + $arr_mime = array(); + $arr_name = array(); + $arr_css = array(); + + // Ajout CSS + if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/',$object->bgcolor)?'':'#').$object->bgcolor; + if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; + + // Attached files + $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); + if (count($listofpaths)) { - $arr_file[]=$listofpaths[$key]['fullname']; - $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); - $arr_name[]=$listofpaths[$key]['name']; + foreach($listofpaths as $key => $val) + { + $arr_file[]=$listofpaths[$key]['fullname']; + $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); + $arr_name[]=$listofpaths[$key]['name']; + } } + + $mailfile = new CMailFile($tmpsujet,$object->sendto,$object->email_from,$tmpbody, $arr_file,$arr_mime,$arr_name,'', '', 0, $msgishtml,$object->email_errorsto,$arr_css); + + $result=$mailfile->sendfile(); + if ($result) + { + $mesg='
'.$langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)).'
'; + } + else + { + $mesg='
'.$langs->trans("ResultKo").'
'.$mailfile->error.' '.$result.'
'; + } + + $action=''; } - - $mailfile = new CMailFile($tmpsujet,$object->sendto,$object->email_from,$tmpbody, $arr_file,$arr_mime,$arr_name,'', '', 0, $msgishtml,$object->email_errorsto,$arr_css); - - $result=$mailfile->sendfile(); - if ($result) - { - $mesg='
'.$langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)).'
'; - } - else - { - $mesg='
'.$langs->trans("ResultKo").'
'.$mailfile->error.' '.$result.'
'; - } - - $action=''; - } -} - -// Action add emailing -if ($action == 'add') -{ - $object->email_from = trim($_POST["from"]); - $object->email_replyto = trim($_POST["replyto"]); - $object->email_errorsto = trim($_POST["errorsto"]); - $object->titre = trim($_POST["titre"]); - $object->sujet = trim($_POST["sujet"]); - $object->body = trim($_POST["body"]); - $object->bgcolor = trim($_POST["bgcolor"]); - $object->bgimage = trim($_POST["bgimage"]); - - if (! $object->titre) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle")); - if (! $object->sujet) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTopic")); - if (! $object->body) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailMessage")); - - if (! $mesg) - { - if ($object->create($user) >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - $mesg=$object->error; } - $mesg='
'.$mesg.'
'; - $action="create"; -} - -// Action update description of emailing -if ($action == 'settitre' || $action == 'setemail_from' || $actino == 'setreplyto' || $action == 'setemail_errorsto') -{ - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - if ($action == 'settitre') $object->titre = trim(GETPOST('titre','alpha')); - else if ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from','alpha')); - else if ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto','alpha')); - else if ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto','alpha')); - - else if ($action == 'settitre' && empty($object->titre)) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle")); - else if ($action == 'setfrom' && empty($object->email_from)) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom")); - - if (! $mesg) - { - if ($object->update($user) >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - $mesg=$object->error; - } - - $mesg='
'.$mesg.'
'; - $action=""; -} - -/* - * Add file in email form - */ -if (! empty($_POST['addfile'])) -{ - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory - dol_add_file_process($upload_dir,0,0); - - $action="edit"; -} - -// Action remove file -if (! empty($_POST["removedfile"])) -{ - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - dol_remove_file_process($_POST['removedfile'],0); - - $action="edit"; -} - -// Action update emailing -if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $isupload=0; - - if (! $isupload) + // Action add emailing + if ($action == 'add') { + $object->email_from = trim($_POST["from"]); + $object->email_replyto = trim($_POST["replyto"]); + $object->email_errorsto = trim($_POST["errorsto"]); + $object->titre = trim($_POST["titre"]); $object->sujet = trim($_POST["sujet"]); $object->body = trim($_POST["body"]); $object->bgcolor = trim($_POST["bgcolor"]); $object->bgimage = trim($_POST["bgimage"]); + if (! $object->titre) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle")); if (! $object->sujet) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTopic")); if (! $object->body) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailMessage")); + if (! $mesg) + { + if ($object->create($user) >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + $mesg=$object->error; + } + + $mesg='
'.$mesg.'
'; + $action="create"; + } + + // Action update description of emailing + if ($action == 'settitre' || $action == 'setemail_from' || $actino == 'setreplyto' || $action == 'setemail_errorsto') + { + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + + if ($action == 'settitre') $object->titre = trim(GETPOST('titre','alpha')); + else if ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from','alpha')); + else if ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto','alpha')); + else if ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto','alpha')); + + else if ($action == 'settitre' && empty($object->titre)) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle")); + else if ($action == 'setfrom' && empty($object->email_from)) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom")); + if (! $mesg) { if ($object->update($user) >= 0) @@ -553,78 +497,136 @@ if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel" } $mesg='
'.$mesg.'
'; + $action=""; + } + + /* + * Add file in email form + */ + if (! empty($_POST['addfile'])) + { + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory + dol_add_file_process($upload_dir,0,0); + $action="edit"; } - else + + // Action remove file + if (! empty($_POST["removedfile"])) { + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + dol_remove_file_process($_POST['removedfile'],0); + $action="edit"; } -} -// Action confirmation validation -if ($action == 'confirm_valid' && $confirm == 'yes') -{ - if ($object->id > 0) + // Action update emailing + if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) { - $object->valid($user); - setEventMessage($langs->trans("MailingSuccessfullyValidated")); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - dol_print_error($db); - } -} + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -// Resend -if ($action == 'confirm_reset' && $confirm == 'yes') -{ - if ($object->id > 0) - { - $db->begin(); + $isupload=0; - $result=$object->valid($user); - if ($result > 0) + if (! $isupload) { - $result=$object->reset_targets_status($user); + $object->sujet = trim($_POST["sujet"]); + $object->body = trim($_POST["body"]); + $object->bgcolor = trim($_POST["bgcolor"]); + $object->bgimage = trim($_POST["bgimage"]); + + if (! $object->sujet) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTopic")); + if (! $object->body) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailMessage")); + + if (! $mesg) + { + if ($object->update($user) >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + $mesg=$object->error; + } + + $mesg='
'.$mesg.'
'; + $action="edit"; } - - if ($result > 0) + else { - $db->commit(); + $action="edit"; + } + } + + // Action confirmation validation + if ($action == 'confirm_valid' && $confirm == 'yes') + { + if ($object->id > 0) + { + $object->valid($user); + setEventMessage($langs->trans("MailingSuccessfullyValidated")); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - $mesg=$object->error; - $db->rollback(); + dol_print_error($db); } } - else + + // Resend + if ($action == 'confirm_reset' && $confirm == 'yes') { - dol_print_error($db); + if ($object->id > 0) + { + $db->begin(); + + $result=$object->valid($user); + if ($result > 0) + { + $result=$object->reset_targets_status($user); + } + + if ($result > 0) + { + $db->commit(); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + $mesg=$object->error; + $db->rollback(); + } + } + else + { + dol_print_error($db); + } + } + + // Action confirmation suppression + if ($action == 'confirm_delete' && $confirm == 'yes') + { + if ($object->delete($object->id)) + { + $url= (! empty($urlfrom) ? $urlfrom : 'liste.php'); + header("Location: ".$url); + exit; + } + } + + if (! empty($_POST["cancel"])) + { + $action = ''; } } -// Action confirmation suppression -if ($action == 'confirm_delete' && $confirm == 'yes') -{ - if ($object->delete($object->id)) - { - $url= (! empty($urlfrom) ? $urlfrom : 'liste.php'); - header("Location: ".$url); - exit; - } -} - -if (! empty($_POST["cancel"])) -{ - $action = ''; -} - - /* * View diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 4929ee9c70e..945f6498ce5 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -106,65 +106,46 @@ $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some // hooks -include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once +if (empty($reshook)) { + include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') { - if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); - } else { - if ($object->id > 0) { - $result = $object->createFromClone($socid); - if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); - exit(); - } else { - setEventMessage($object->error, 'errors'); - $action = ''; + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes') { + if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { + setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + } else { + if ($object->id > 0) { + $result = $object->createFromClone($socid); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + exit(); + } else { + setEventMessage($object->error, 'errors'); + $action = ''; + } } } } -} -// Delete proposal -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) { - $result = $object->delete($user); - if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php'); - exit(); - } else { - $langs->load("errors"); - setEventMessage($langs->trans($object->error), 'errors'); - } -} - -// Remove line -else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) { - $result = $object->deleteline($lineid); - // reorder lines - if ($result) - $object->line_order(true); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); + // Delete proposal + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) { + $result = $object->delete($user); + if ($result > 0) { + header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php'); + exit(); + } else { + $langs->load("errors"); + setEventMessage($langs->trans($object->error), 'errors'); } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); - exit(); -} + // Remove line + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) { + $result = $object->deleteline($lineid); + // reorder lines + if ($result) + $object->line_order(true); -// Validation -else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) { - $result = $object->valid($user); - if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -176,148 +157,587 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr $ret = $object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } else { - $langs->load("errors"); - if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); - else setEventMessage($langs->trans($object->error), 'errors'); - } -} -else if ($action == 'setdate' && $user->rights->propal->creer) { - $datep = dol_mktime(12, 0, 0, $_POST ['remonth'], $_POST ['reday'], $_POST ['reyear']); - - if (empty($datep)) { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + exit(); } - if (! $error) { - $result = $object->set_date($user, $datep); + // Validation + else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) { + $result = $object->valid($user); + if ($result >= 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } else { + $langs->load("errors"); + if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); + else setEventMessage($langs->trans($object->error), 'errors'); + } + } + + else if ($action == 'setdate' && $user->rights->propal->creer) { + $datep = dol_mktime(12, 0, 0, $_POST ['remonth'], $_POST ['reday'], $_POST ['reyear']); + + if (empty($datep)) { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); + } + + if (! $error) { + $result = $object->set_date($user, $datep); + if ($result < 0) + dol_print_error($db, $object->error); + } + } else if ($action == 'setecheance' && $user->rights->propal->creer) { + $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST ['echmonth'], $_POST ['echday'], $_POST ['echyear'])); + if ($result < 0) + dol_print_error($db, $object->error); + } else if ($action == 'setdate_livraison' && $user->rights->propal->creer) { + $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST ['liv_month'], $_POST ['liv_day'], $_POST ['liv_year'])); if ($result < 0) dol_print_error($db, $object->error); } -} else if ($action == 'setecheance' && $user->rights->propal->creer) { - $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST ['echmonth'], $_POST ['echday'], $_POST ['echyear'])); - if ($result < 0) - dol_print_error($db, $object->error); -} else if ($action == 'setdate_livraison' && $user->rights->propal->creer) { - $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST ['liv_month'], $_POST ['liv_day'], $_POST ['liv_year'])); - if ($result < 0) - dol_print_error($db, $object->error); -} -// Positionne ref client -else if ($action == 'set_ref_client' && $user->rights->propal->creer) { - $object->set_ref_client($user, $_POST ['ref_client']); -} - -// Create proposal -else if ($action == 'add' && $user->rights->propal->creer) { - $object->socid = $socid; - $object->fetch_thirdparty(); - - $datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $date_delivery = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - $duration = GETPOST('duree_validite'); - - if (empty($datep)) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); - $action = 'create'; - $error ++; - } - if (empty($duration)) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); - $action = 'create'; - $error ++; + // Positionne ref client + else if ($action == 'set_ref_client' && $user->rights->propal->creer) { + $object->set_ref_client($user, $_POST ['ref_client']); } - if ($socid < 1) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); - $action = 'create'; - $error ++; - } + // Create proposal + else if ($action == 'add' && $user->rights->propal->creer) { + $object->socid = $socid; + $object->fetch_thirdparty(); - if (! $error) { - $db->begin(); + $datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $date_delivery = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $duration = GETPOST('duree_validite'); - // Si on a selectionne une propal a copier, on realise la copie - if (GETPOST('createmode') == 'copy' && GETPOST('copie_propal')) { - if ($object->fetch(GETPOST('copie_propal')) > 0) { + if (empty($datep)) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); + $action = 'create'; + $error ++; + } + if (empty($duration)) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); + $action = 'create'; + $error ++; + } + + if ($socid < 1) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); + $action = 'create'; + $error ++; + } + + if (! $error) { + $db->begin(); + + // Si on a selectionne une propal a copier, on realise la copie + if (GETPOST('createmode') == 'copy' && GETPOST('copie_propal')) { + if ($object->fetch(GETPOST('copie_propal')) > 0) { + $object->ref = GETPOST('ref'); + $object->datep = $datep; + $object->date_livraison = $date_delivery; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->duree_validite = $duration; + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = GETPOST('remise_absolue'); + $object->socid = GETPOST('socid'); + $object->contactid = GETPOST('contactidp'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); + $object->author = $user->id; // deprecated + $object->note = GETPOST('note'); + $object->statut = 0; + + $id = $object->create_from($user); + } else { + setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); + } + } else { $object->ref = GETPOST('ref'); + $object->ref_client = GETPOST('ref_client'); $object->datep = $datep; $object->date_livraison = $date_delivery; $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); $object->fk_delivery_address = GETPOST('fk_address'); - $object->duree_validite = $duration; + $object->duree_validite = GETPOST('duree_validite'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $object->remise_percent = GETPOST('remise_percent'); - $object->remise_absolue = GETPOST('remise_absolue'); - $object->socid = GETPOST('socid'); + $object->contactid = GETPOST('contactidp'); $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note'); - $object->statut = 0; - $id = $object->create_from($user); - } else { - setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); - } - } else { - $object->ref = GETPOST('ref'); - $object->ref_client = GETPOST('ref_client'); - $object->datep = $datep; - $object->date_livraison = $date_delivery; - $object->availability_id = GETPOST('availability_id'); - $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->fk_delivery_address = GETPOST('fk_address'); - $object->duree_validite = GETPOST('duree_validite'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->origin = GETPOST('origin'); + $object->origin_id = GETPOST('originid'); - $object->contactid = GETPOST('contactidp'); - $object->fk_project = GETPOST('projectid'); - $object->modelpdf = GETPOST('model'); - $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); - - $object->origin = GETPOST('origin'); - $object->origin_id = GETPOST('originid'); - - for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) { - if ($_POST ['idprod' . $i]) { - $xid = 'idprod' . $i; - $xqty = 'qty' . $i; - $xremise = 'remise' . $i; - $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); - } - } - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error ++; - $action = 'create'; - } - } - - if (! $error) { - $id = $object->create($user); - - if ($id > 0) { - // Insertion contact par defaut si defini - if (GETPOST('contactidp') > 0) { - $result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external'); - if ($result < 0) { - $error ++; - setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) { + if ($_POST ['idprod' . $i]) { + $xid = 'idprod' . $i; + $xqty = 'qty' . $i; + $xremise = 'remise' . $i; + $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); } } - if (! $error) { + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + $action = 'create'; + } + } + + if (! $error) { + $id = $object->create($user); + + if ($id > 0) { + // Insertion contact par defaut si defini + if (GETPOST('contactidp') > 0) { + $result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external'); + if ($result < 0) { + $error ++; + setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + } + } + + if (! $error) { + $db->commit(); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + exit(); + } else { + $db->rollback(); + } + } else { + dol_print_error($db, $object->error); + $db->rollback(); + exit(); + } + } + } + } + + // Classify billed + else if ($action == 'classifybilled' && $user->rights->propal->cloturer) { + $object->cloture($user, 4, ''); + } + + // Reopen proposal + else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { + // prevent browser refresh from reopening proposal several times + if ($object->statut == 2 || $object->statut == 3) { + $object->reopen($user, 1); + } + } + + // Close proposal + else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { + if (! GETPOST('statut')) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors'); + $action = 'statut'; + } else { + // prevent browser refresh from closing proposal several times + if ($object->statut == 1) { + $object->cloture($user, GETPOST('statut'), GETPOST('note')); + } + } + } + + // Add file in email form + if (GETPOST('addfile')) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; + + dol_add_file_process($upload_dir_tmp, 0, 0); + $action = 'presend'; + } + + // Remove file in email form + if (GETPOST('removedfile')) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + // Set tmp user directory + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; + + // TODO Delete only files that was uploaded from email form + dol_remove_file_process($_POST ['removedfile'], 0); + $action = 'presend'; + } + + /* + * Send mail + */ + if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { + $langs->load('mails'); + + if ($object->id > 0) { + if ($_POST ['sendto']) { + // Le destinataire a ete fourni via le champ libre + $sendto = $_POST ['sendto']; + $sendtoid = 0; + } elseif ($_POST ['receiver'] != '-1') { + // Recipient was provided from combo list + if ($_POST ['receiver'] == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } else // Id du contact + { + $sendto = $object->client->contact_get_property($_POST ['receiver'], 'email'); + $sendtoid = $_POST ['receiver']; + } + } + + if (dol_strlen($sendto)) { + $langs->load("commercial"); + + $from = $_POST ['fromname'] . ' <' . $_POST ['frommail'] . '>'; + $replyto = $_POST ['replytoname'] . ' <' . $_POST ['replytomail'] . '>'; + $message = $_POST ['message']; + $sendtocc = $_POST ['sendtocc']; + $deliveryreceipt = $_POST ['deliveryreceipt']; + + if (dol_strlen($_POST ['subject'])) + $subject = $_POST ['subject']; + else + $subject = $langs->transnoentities('Propal') . ' ' . $object->ref; + $actiontypecode = 'AC_PROP'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + if ($message) { + $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; + $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; + $actionmsg .= $message; + } + $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); + + // Create form object + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles = $formmail->get_attached_files(); + $filepath = $attachedfiles ['paths']; + $filename = $attachedfiles ['names']; + $mimetype = $attachedfiles ['mimes']; + + // Envoi de la propal + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); + if ($mailfile->error) { + setEventMessage($mailfile->error, 'errors'); + } else { + $result = $mailfile->sendfile(); + if ($result) { + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface = new Interfaces($db); + $result = $interface->run_triggers('PROPAL_SENTBYMAIL', $object, $user, $langs, $conf); + if ($result < 0) { + $error++; + $object->errors = $interface->errors; + } + // Fin appel triggers + + if (! $error) { + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); + setEventMessage($mesg); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + exit(); + } else { + dol_print_error($db); + } + } else { + $langs->load("other"); + if ($mailfile->error) { + $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); + $mesg .= '
' . $mailfile->error; + } else { + $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + setEventMessage($mesg, 'errors'); + } + } + } else { + $langs->load("other"); + setEventMessage($langs->trans('ErrorMailRecipientIsEmpty') . '!', 'errors'); + dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); + } + } else { + $langs->load("other"); + setEventMessage($langs->trans('ErrorFailedToReadEntity', $langs->trans("Proposal")), 'errors'); + dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Proposal"))); + } + } + + // Go back to draft + if ($action == 'modif' && $user->rights->propal->creer) { + $object->set_draft($user); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { + if ($_POST ["remise_id"]) { + if ($object->id > 0) { + $result = $object->insert_discount($_POST ["remise_id"]); + if ($result < 0) { + setEventMessage($object->error, 'errors'); + } + } + } + } + + // Add line + else if ($action == 'addline' && $user->rights->propal->creer) { + + // Set if we used free entry or predefined product + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $price_ht = GETPOST('price_ht'); + if (GETPOST('prod_entry_mode') == 'free') + { + $idprod=0; + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { + $idprod=GETPOST('idprod', 'int'); + $tva_tx = ''; + } + + $qty = GETPOST('qty' . $predef); + $remise_percent = GETPOST('remise_percent' . $predef); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST ["options_" . $key]); + } + } + + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; + } + + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); + $error ++; + } + + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + $pu_ht = 0; + $pu_ttc = 0; + $price_min = 0; + $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); + + $db->begin(); + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + if (! empty($idprod)) { + $prod = new Product($db); + $prod->fetch($idprod); + + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); + + // If prices fields are update + $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); + $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); + + // On defini prix unitaire + if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) + { + $pu_ht = $prod->multiprices[$object->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; + $price_min = $prod->multiprices_min[$object->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; + if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) { + if (count($prodcustprice->lines) > 0) { + $found = true; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; + }else { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + }else { + setEventMessage($prodcustprice->error,'errors'); + } + } + else + { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + + // if price ht is forced (ie: calculated by margin rate and cost price) + if (! empty($price_ht)) { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + elseif ($tva_tx != $prod->tva_tx) { + if ($price_base_type != 'HT') { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); + } else { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + } + + $desc = ''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if (empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + } else { + $desc = $prod->description; + } + + $desc = dol_concatdesc($desc, $product_desc); + + // Add custom code and origin country into description + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + $tmptxt = '('; + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + $tmptxt .= ')'; + $desc = dol_concatdesc($desc, $tmptxt); + } + + $type = $prod->type; + } else { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); + } + + // Margin + $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); + + $date_start = dol_mktime(0, 0, 0, GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); + $date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $object->client); + $localtax2_tx = get_localtax($tva_tx, 2, $object->client); + + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessage($mesg, 'errors'); + } else { + // Insert line + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_option); + + if ($result > 0) { $db->commit(); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -332,411 +752,120 @@ else if ($action == 'add' && $user->rights->propal->creer) { propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); - exit(); + unset($_POST ['prod_entry_mode']); + + unset($_POST ['qty']); + unset($_POST ['type']); + unset($_POST ['remise_percent']); + unset($_POST ['price_ht']); + unset($_POST ['price_ttc']); + unset($_POST ['tva_tx']); + unset($_POST ['product_ref']); + unset($_POST ['product_label']); + unset($_POST ['product_desc']); + unset($_POST ['fournprice']); + unset($_POST ['buying_price']); + unset($_POST ['np_marginRate']); + unset($_POST ['np_markRate']); + unset($_POST ['dp_desc']); + unset($_POST ['idprod']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { $db->rollback(); - } - } else { - dol_print_error($db, $object->error); - $db->rollback(); - exit(); - } - } - } -} -// Classify billed -else if ($action == 'classifybilled' && $user->rights->propal->cloturer) { - $object->cloture($user, 4, ''); -} - -// Reopen proposal -else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { - // prevent browser refresh from reopening proposal several times - if ($object->statut == 2 || $object->statut == 3) { - $object->reopen($user, 1); - } -} - -// Close proposal -else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { - if (! GETPOST('statut')) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors'); - $action = 'statut'; - } else { - // prevent browser refresh from closing proposal several times - if ($object->statut == 1) { - $object->cloture($user, GETPOST('statut'), GETPOST('note')); - } - } -} - -// Add file in email form -if (GETPOST('addfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; - - dol_add_file_process($upload_dir_tmp, 0, 0); - $action = 'presend'; -} - -// Remove file in email form -if (GETPOST('removedfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process($_POST ['removedfile'], 0); - $action = 'presend'; -} - -/* - * Send mail - */ -if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { - $langs->load('mails'); - - if ($object->id > 0) { - if ($_POST ['sendto']) { - // Le destinataire a ete fourni via le champ libre - $sendto = $_POST ['sendto']; - $sendtoid = 0; - } elseif ($_POST ['receiver'] != '-1') { - // Recipient was provided from combo list - if ($_POST ['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } else // Id du contact - { - $sendto = $object->client->contact_get_property($_POST ['receiver'], 'email'); - $sendtoid = $_POST ['receiver']; - } - } - - if (dol_strlen($sendto)) { - $langs->load("commercial"); - - $from = $_POST ['fromname'] . ' <' . $_POST ['frommail'] . '>'; - $replyto = $_POST ['replytoname'] . ' <' . $_POST ['replytomail'] . '>'; - $message = $_POST ['message']; - $sendtocc = $_POST ['sendtocc']; - $deliveryreceipt = $_POST ['deliveryreceipt']; - - if (dol_strlen($_POST ['subject'])) - $subject = $_POST ['subject']; - else - $subject = $langs->transnoentities('Propal') . ' ' . $object->ref; - $actiontypecode = 'AC_PROP'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; - if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; - } - $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); - - // Create form object - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles ['paths']; - $filename = $attachedfiles ['names']; - $mimetype = $attachedfiles ['mimes']; - - // Envoi de la propal - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); - if ($mailfile->error) { - setEventMessage($mailfile->error, 'errors'); - } else { - $result = $mailfile->sendfile(); - if ($result) { - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2 = $actionmsg2; - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers('PROPAL_SENTBYMAIL', $object, $user, $langs, $conf); - if ($result < 0) { - $error++; - $object->errors = $interface->errors; - } - // Fin appel triggers - - if (! $error) { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); - setEventMessage($mesg); - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); - exit(); - } else { - dol_print_error($db); - } - } else { - $langs->load("other"); - if ($mailfile->error) { - $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); - $mesg .= '
' . $mailfile->error; - } else { - $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - setEventMessage($mesg, 'errors'); + setEventMessage($object->error, 'errors'); } } - } else { - $langs->load("other"); - setEventMessage($langs->trans('ErrorMailRecipientIsEmpty') . '!', 'errors'); - dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); - } - } else { - $langs->load("other"); - setEventMessage($langs->trans('ErrorFailedToReadEntity', $langs->trans("Proposal")), 'errors'); - dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Proposal"))); - } -} - -// Go back to draft -if ($action == 'modif' && $user->rights->propal->creer) { - $object->set_draft($user); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } -} - -else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { - if ($_POST ["remise_id"]) { - if ($object->id > 0) { - $result = $object->insert_discount($_POST ["remise_id"]); - if ($result < 0) { - setEventMessage($object->error, 'errors'); - } - } - } -} - -// Add line -else if ($action == 'addline' && $user->rights->propal->creer) { - - // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - if (GETPOST('prod_entry_mode') == 'free') - { - $idprod=0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { - $idprod=GETPOST('idprod', 'int'); - $tva_tx = ''; - } - - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); } } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; - } - - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. - { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); - $error ++; - } - - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - $pu_ht = 0; - $pu_ttc = 0; - $price_min = 0; - $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); - - $db->begin(); - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - if (! empty($idprod)) { - $prod = new Product($db); - $prod->fetch($idprod); - - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - - // If prices fields are update - $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); - - // On defini prix unitaire - if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) - { - $pu_ht = $prod->multiprices[$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; - $price_min = $prod->multiprices_min[$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) { - if (count($prodcustprice->lines) > 0) { - $found = true; - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; - }else { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - }else { - setEventMessage($prodcustprice->error,'errors'); - } - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - - // if price ht is forced (ie: calculated by margin rate and cost price) - if (! empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tva_tx != $prod->tva_tx) { - if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); - } else { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - } - - $desc = ''; - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } - - $desc = dol_concatdesc($desc, $product_desc); - - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } - - $type = $prod->type; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); - } - - // Margin - $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - - $date_start = dol_mktime(0, 0, 0, GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->client); - $localtax2_tx = get_localtax($tva_tx, 2, $object->client); - + // Mise a jour d'une ligne dans la propale + else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save') == $langs->trans("Save")) { + // Define info_bits $info_bits = 0; - if ($tva_npr) + if (preg_match('/\*/', GETPOST('tva_tx'))) $info_bits |= 0x01; - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); - } else { - // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_option); + // Clean parameters + $description = dol_htmlcleanlastbr(GETPOST('product_desc')); - if ($result > 0) { + // Define vat_rate + $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->client); + $localtax2_rate = get_localtax($vat_rate, 2, $object->client); + $pu_ht = GETPOST('price_ht'); + + // Add buying price + $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); + + $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST ["options_" . $key]); + } + } + + // Define special_code for special lines + $special_code=GETPOST('special_code'); + if (! GETPOST('qty')) $special_code=3; + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (! empty($productid)) { + $product = new Product($db); + $res = $product->fetch($productid); + + $type = $product->type; + + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + $price_min = $product->multiprices_min [$object->client->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); + + if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { + setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + $error ++; + } + } else { + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + + // Check parameters + if (GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; + } + } + + if (! $error) { + $db->begin(); + + $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_option); + + if ($result >= 0) { $db->commit(); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -751,10 +880,9 @@ else if ($action == 'addline' && $user->rights->propal->creer) { propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - unset($_POST ['prod_entry_mode']); - unset($_POST ['qty']); unset($_POST ['type']); + unset($_POST ['productid']); unset($_POST ['remise_percent']); unset($_POST ['price_ht']); unset($_POST ['price_ttc']); @@ -764,23 +892,6 @@ else if ($action == 'addline' && $user->rights->propal->creer) { unset($_POST ['product_desc']); unset($_POST ['fournprice']); unset($_POST ['buying_price']); - unset($_POST ['np_marginRate']); - unset($_POST ['np_markRate']); - unset($_POST ['dp_desc']); - unset($_POST ['idprod']); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); } else { $db->rollback(); @@ -788,303 +899,194 @@ else if ($action == 'addline' && $user->rights->propal->creer) { } } } -} -// Mise a jour d'une ligne dans la propale -else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save') == $langs->trans("Save")) { - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', GETPOST('tva_tx'))) - $info_bits |= 0x01; - - // Clean parameters - $description = dol_htmlcleanlastbr(GETPOST('product_desc')); - - // Define vat_rate - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $object->client); - $localtax2_rate = get_localtax($vat_rate, 2, $object->client); - $pu_ht = GETPOST('price_ht'); - - // Add buying price - $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); - - $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); - } + else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + exit(); } - // Define special_code for special lines - $special_code=GETPOST('special_code'); - if (! GETPOST('qty')) $special_code=3; - - // Check minimum price - $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { - $product = new Product($db); - $res = $product->fetch($productid); - - $type = $product->type; - - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - $price_min = $product->multiprices_min [$object->client->price_level]; - - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - - if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); - $error ++; + // Generation doc (depuis lien ou depuis cartouche doc) + else if ($action == 'builddoc' && $user->rights->propal->creer) { + if (GETPOST('model')) { + $object->setDocModel($user, GETPOST('model')); } - } else { - $type = GETPOST('type'); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - // Check parameters - if (GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); } - } + $ret = $object->fetch($id); // Reload to get new records + $result = propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if (! $error) { - $db->begin(); - - $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_option); - - if ($result >= 0) { - $db->commit(); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['productid']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); + if ($result <= 0) { + dol_print_error($db, $result); + exit(); } else { - $db->rollback(); - - setEventMessage($object->error, 'errors'); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); + exit(); } } -} -else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition - exit(); -} - -// Generation doc (depuis lien ou depuis cartouche doc) -else if ($action == 'builddoc' && $user->rights->propal->creer) { - if (GETPOST('model')) { - $object->setDocModel($user, GETPOST('model')); - } - - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - $result = propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - if ($result <= 0) { - dol_print_error($db, $result); - exit(); - } else { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); - exit(); - } -} - -// Remove file in doc form -else if ($action == 'remove_file' && $user->rights->propal->creer) { - if ($object->id > 0) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $conf->propal->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); - } -} - -// Set project -else if ($action == 'classin' && $user->rights->propal->creer) { - $object->setProject($_POST ['projectid']); -} - -// Delai de livraison -else if ($action == 'setavailability' && $user->rights->propal->creer) { - $result = $object->availability($_POST ['availability_id']); -} - -// Origine de la propale -else if ($action == 'setdemandreason' && $user->rights->propal->creer) { - $result = $object->demand_reason($_POST ['demand_reason_id']); -} - -// Conditions de reglement -else if ($action == 'setconditions' && $user->rights->propal->creer) { - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); -} - -else if ($action == 'setremisepercent' && $user->rights->propal->creer) { - $result = $object->set_remise_percent($user, $_POST ['remise_percent']); -} - -else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) { - $result = $object->set_remise_absolue($user, $_POST ['remise_absolue']); -} - -// Mode de reglement -else if ($action == 'setmode' && $user->rights->propal->creer) { - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); -} - -/* - * Ordonnancement des lignes -*/ - -else if ($action == 'up' && $user->rights->propal->creer) { - $object->line_up(GETPOST('rowid')); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); - exit(); -} - -else if ($action == 'down' && $user->rights->propal->creer) { - $object->line_down(GETPOST('rowid')); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); - exit(); -} else if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) - $error ++; - - if (! $error) { - // Actions on extra fields (by external module or standard code) - // FIXME le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('propaldao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been - // modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) - $error ++; - } - - if ($error) - $action = 'edit_extras'; -} - -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) { - if ($action == 'addcontact') { + // Remove file in doc form + else if ($action == 'remove_file' && $user->rights->propal->creer) { if ($object->id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST ["type"], $_POST ["source"]); + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $langs->load("other"); + $upload_dir = $conf->propal->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) + setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + else + setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + } + } + + // Set project + else if ($action == 'classin' && $user->rights->propal->creer) { + $object->setProject($_POST ['projectid']); + } + + // Delai de livraison + else if ($action == 'setavailability' && $user->rights->propal->creer) { + $result = $object->availability($_POST ['availability_id']); + } + + // Origine de la propale + else if ($action == 'setdemandreason' && $user->rights->propal->creer) { + $result = $object->demand_reason($_POST ['demand_reason_id']); + } + + // Conditions de reglement + else if ($action == 'setconditions' && $user->rights->propal->creer) { + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + } + + else if ($action == 'setremisepercent' && $user->rights->propal->creer) { + $result = $object->set_remise_percent($user, $_POST ['remise_percent']); + } + + else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) { + $result = $object->set_remise_absolue($user, $_POST ['remise_absolue']); + } + + // Mode de reglement + else if ($action == 'setmode' && $user->rights->propal->creer) { + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + } + + /* + * Ordonnancement des lignes + */ + + else if ($action == 'up' && $user->rights->propal->creer) { + $object->line_up(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); + exit(); + } + + else if ($action == 'down' && $user->rights->propal->creer) { + $object->line_down(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); + exit(); + } else if ($action == 'update_extras') { + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) + $error ++; + + if (! $error) { + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('propaldao')); + $parameters = array('id' => $object->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been + // modified by + // some hooks + if (empty($reshook)) { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } else if ($reshook < 0) + $error ++; + } + + if ($error) + $action = 'edit_extras'; + } + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) { + if ($action == 'addcontact') { + if ($object->id > 0) { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST ["type"], $_POST ["source"]); + } + + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); } else { - setEventMessage($object->error, 'errors'); + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + } else { + setEventMessage($object->error, 'errors'); + } } } - } - // Bascule du statut d'un contact - else if ($action == 'swapstatut') { - if ($object->fetch($id) > 0) { - $result = $object->swapContactStatus(GETPOST('ligne')); - } else { - dol_print_error($db); + // Bascule du statut d'un contact + else if ($action == 'swapstatut') { + if ($object->fetch($id) > 0) { + $result = $object->swapContactStatus(GETPOST('ligne')); + } else { + dol_print_error($db); + } } - } - // Efface un contact - else if ($action == 'deletecontact') { - $object->fetch($id); - $result = $object->delete_contact($lineid); + // Efface un contact + else if ($action == 'deletecontact') { + $object->fetch($id); + $result = $object->delete_contact($lineid); - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - dol_print_error($db); + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + dol_print_error($db); + } } } } diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 58a384df6d0..fdfa2495411 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -162,11 +162,13 @@ $hookmanager->initHooks(array('prospectlist')); $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks -if ($action == 'cstc') -{ - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"]; - $sql .= " WHERE rowid = ".$_GET["socid"]; - $result=$db->query($sql); +if (empty($reshook)) { + if ($action == 'cstc') + { + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"]; + $sql .= " WHERE rowid = ".$_GET["socid"]; + $result=$db->query($sql); + } } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 1c01b975a3b..02e6c74c13c 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -101,44 +101,88 @@ $permissionnote = $user->rights->commande->creer; // Used by the include of acti $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once +if (empty($reshook)) { -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) -{ - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) { - $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; - } - else - { - if ($object->id > 0) + if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { - // Because createFromClone modifies the object, we must clone it so that we can restore it later - $orig = dol_clone($object); + $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; + } + else + { + if ($object->id > 0) + { + // Because createFromClone modifies the object, we must clone it so that we can restore it later + $orig = dol_clone($object); - $result=$object->createFromClone($socid); + $result=$object->createFromClone($socid); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + setEventMessage($object->error, 'errors'); + $object = $orig; + $action=''; + } + } + } + } + + // Reopen a closed order + else if ($action == 'reopen' && $user->rights->commande->creer) { + if ($object->statut == 3) { + $result = $object->set_reopen($user); if ($result > 0) { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { setEventMessage($object->error, 'errors'); - $object = $orig; - $action=''; } } } -} -// Reopen a closed order -else if ($action == 'reopen' && $user->rights->commande->creer) { - if ($object->statut == 3) { - $result = $object->set_reopen($user); - if ($result > 0) - { + // Suppression de la commande + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) { + $result = $object->delete($user); + if ($result > 0) { + header('Location: index.php'); + exit; + } + else { + setEventMessage($object->error, 'errors'); + } + } + + // Remove a product line + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) { + $result = $object->deleteline($lineid); + if ($result > 0) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } @@ -147,697 +191,299 @@ else if ($action == 'reopen' && $user->rights->commande->creer) { setEventMessage($object->error, 'errors'); } } -} -// Suppression de la commande -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) { - $result = $object->delete($user); - if ($result > 0) { - header('Location: index.php'); - exit; + // Categorisation dans projet + else if ($action == 'classin' && $user->rights->commande->creer) { + $object->setProject(GETPOST('projectid')); } - else { - setEventMessage($object->error, 'errors'); - } -} -// Remove a product line -else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) { - $result = $object->deleteline($lineid); - if ($result > 0) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + // Add order + else if ($action == 'add' && $user->rights->commande->creer) { + $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + + if ($datecommande == '') { + $mesg = '
' . $langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')) . '
'; + $action = 'create'; + $error ++; } - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - setEventMessage($object->error, 'errors'); - } -} + if ($socid < 1) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); + $action = 'create'; + $error ++; + } -// Categorisation dans projet -else if ($action == 'classin' && $user->rights->commande->creer) { - $object->setProject(GETPOST('projectid')); -} + if (! $error) { + $object->socid = $socid; + $object->fetch_thirdparty(); -// Add order -else if ($action == 'add' && $user->rights->commande->creer) { - $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $db->begin(); - if ($datecommande == '') { - $mesg = '
' . $langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')) . '
'; - $action = 'create'; - $error ++; - } + $object->date_commande = $datecommande; + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); + $object->source = GETPOST('source_id'); + $object->fk_project = GETPOST('projectid'); + $object->ref_client = GETPOST('ref_client'); + $object->modelpdf = GETPOST('model'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->date_livraison = $datelivraison; + $object->fk_delivery_address = GETPOST('fk_address'); + $object->contactid = GETPOST('contactidp'); - if ($socid < 1) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); - $action = 'create'; - $error ++; - } + // If creation from another object of another module (Example: origin=propal, originid=1) + if (! empty($origin) && ! empty($originid)) { + // Parse element/subelement (ex: project_task) + $element = $subelement = $origin; + if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { + $element = $regs [1]; + $subelement = $regs [2]; + } - if (! $error) { - $object->socid = $socid; - $object->fetch_thirdparty(); + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; + $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } - $db->begin(); + $object->origin = $origin; + $object->origin_id = $originid; - $object->date_commande = $datecommande; - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); - $object->source = GETPOST('source_id'); - $object->fk_project = GETPOST('projectid'); - $object->ref_client = GETPOST('ref_client'); - $object->modelpdf = GETPOST('model'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $object->availability_id = GETPOST('availability_id'); - $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->date_livraison = $datelivraison; - $object->fk_delivery_address = GETPOST('fk_address'); - $object->contactid = GETPOST('contactidp'); + // Possibility to add external linked objects with hooks + $object->linked_objects [$object->origin] = $object->origin_id; + $other_linked_objects = GETPOST('other_linked_objects', 'array'); + if (! empty($other_linked_objects)) { + $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); + } - // If creation from another object of another module (Example: origin=propal, originid=1) - if (! empty($origin) && ! empty($originid)) { - // Parse element/subelement (ex: project_task) - $element = $subelement = $origin; - if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { - $element = $regs [1]; - $subelement = $regs [2]; - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) + $error ++; - // For compatibility - if ($element == 'order') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - $element = 'comm/propal'; - $subelement = 'propal'; - } - if ($element == 'contract') { - $element = $subelement = 'contrat'; - } - - $object->origin = $origin; - $object->origin_id = $originid; - - // Possibility to add external linked objects with hooks - $object->linked_objects [$object->origin] = $object->origin_id; - $other_linked_objects = GETPOST('other_linked_objects', 'array'); - if (! empty($other_linked_objects)) { - $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); - } - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) - $error ++; - - if (! $error) - { - $object_id = $object->create($user); - - if ($object_id > 0) + if (! $error) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + $object_id = $object->create($user); - $classname = ucfirst($subelement); - $srcobject = new $classname($db); - - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); - $result = $srcobject->fetch($object->origin_id); - if ($result > 0) + if ($object_id > 0) { - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); + if ($result > 0) { - $srcobject->fetch_lines(); $lines = $srcobject->lines; - } - - $fk_parent_line = 0; - $num = count($lines); - - for($i = 0; $i < $num; $i ++) - { - $label = (! empty($lines [$i]->label) ? $lines [$i]->label : ''); - $desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle); - $product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0); - - // Dates - // TODO mutualiser - $date_start = $lines [$i]->date_debut_prevue; - if ($lines [$i]->date_debut_reel) - $date_start = $lines [$i]->date_debut_reel; - if ($lines [$i]->date_start) - $date_start = $lines [$i]->date_start; - $date_end = $lines [$i]->date_fin_prevue; - if ($lines [$i]->date_fin_reel) - $date_end = $lines [$i]->date_fin_reel; - if ($lines [$i]->date_end) - $date_end = $lines [$i]->date_end; - - // Reset fk_parent_line for no child products and special product - if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) // For avoid conflicts if - // trigger used + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { - $lines [$i]->fetch_optionals($lines [$i]->rowid); - $array_option = $lines [$i]->array_options; + $srcobject->fetch_lines(); + $lines = $srcobject->lines; } - $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); + $fk_parent_line = 0; + $num = count($lines); - if ($result < 0) { + for($i = 0; $i < $num; $i ++) + { + $label = (! empty($lines [$i]->label) ? $lines [$i]->label : ''); + $desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle); + $product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0); + + // Dates + // TODO mutualiser + $date_start = $lines [$i]->date_debut_prevue; + if ($lines [$i]->date_debut_reel) + $date_start = $lines [$i]->date_debut_reel; + if ($lines [$i]->date_start) + $date_start = $lines [$i]->date_start; + $date_end = $lines [$i]->date_fin_prevue; + if ($lines [$i]->date_fin_reel) + $date_end = $lines [$i]->date_fin_reel; + if ($lines [$i]->date_end) + $date_end = $lines [$i]->date_end; + + // Reset fk_parent_line for no child products and special product + if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) // For avoid conflicts if + // trigger used + { + $lines [$i]->fetch_optionals($lines [$i]->rowid); + $array_option = $lines [$i]->array_options; + } + + $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); + + if ($result < 0) { + $error ++; + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines [$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) $error ++; - break; - } - - // Defined the new fk_parent_line - if ($result > 0 && $lines [$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - - // Hooks - $parameters = array('objFrom' => $srcobject); - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if ($reshook < 0) + } else { + $mesg = $srcobject->error; $error ++; + } } else { - $mesg = $srcobject->error; + $mesg = $object->error; $error ++; } } else { - $mesg = $object->error; - $error ++; + // Required extrafield left blank, error message already defined by setOptionalsFromPost() + $action = 'create'; } } else { - // Required extrafield left blank, error message already defined by setOptionalsFromPost() - $action = 'create'; - } - } else { - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) - $error ++; - - if (! $error) { - $object_id = $object->create($user); - - // If some invoice's lines already known - $NBLINES = 8; - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST ['idprod' . $i]) { - $xid = 'idprod' . $i; - $xqty = 'qty' . $i; - $xremise = 'remise_percent' . $i; - $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); - } - } - } - } - - // Insert default contacts if defined - if ($object_id > 0) { - if (GETPOST('contactidp')) { - $result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external'); - if ($result < 0) { - $mesg = '
' . $langs->trans("ErrorFailedToAddContact") . '
'; + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) $error ++; - } - } - $id = $object_id; - $action = ''; - } + if (! $error) { + $object_id = $object->create($user); - // End of object creation, we show it - if ($object_id > 0 && ! $error) { - $db->commit(); - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object_id); - exit(); - } else { - $db->rollback(); - $action = 'create'; - if (! $mesg) - $mesg = '
' . $object->error . '
'; - } - } -} - -else if ($action == 'classifybilled' && $user->rights->commande->creer) -{ - $ret=$object->classifyBilled(); - - if ($ret < 0) { - setEventMessage($object->error, 'errors'); - } -} - -// Positionne ref commande client -else if ($action == 'set_ref_client' && $user->rights->commande->creer) { - $object->set_ref_client($user, GETPOST('ref_client')); -} - -else if ($action == 'setremise' && $user->rights->commande->creer) { - $object->set_remise($user, GETPOST('remise')); -} - -else if ($action == 'setabsolutediscount' && $user->rights->commande->creer) { - if (GETPOST('remise_id')) { - if ($object->id > 0) { - $object->insert_discount(GETPOST('remise_id')); - } else { - dol_print_error($db, $object->error); - } - } -} - -else if ($action == 'setdate' && $user->rights->commande->creer) { - // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); - - $result = $object->set_date($user, $date); - if ($result < 0) { - $mesg = '
' . $object->error . '
'; - } -} - -else if ($action == 'setdate_livraison' && $user->rights->commande->creer) { - // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - - $result = $object->set_date_livraison($user, $datelivraison); - if ($result < 0) { - $mesg = '
' . $object->error . '
'; - } -} - -else if ($action == 'setmode' && $user->rights->commande->creer) { - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setavailability' && $user->rights->commande->creer) { - $result = $object->availability(GETPOST('availability_id')); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setdemandreason' && $user->rights->commande->creer) { - $result = $object->demand_reason(GETPOST('demand_reason_id')); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setconditions' && $user->rights->commande->creer) { - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) { - dol_print_error($db, $object->error); - } else { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - $newlang = GETPOST('lang_id', 'alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $ret = $object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } -} - -else if ($action == 'setremisepercent' && $user->rights->commande->creer) { - $result = $object->set_remise($user, GETPOST('remise_percent')); -} - -else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) { - $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); -} - -// Add a new line -else if ($action == 'addline' && $user->rights->commande->creer) { - $langs->load('errors'); - $error = 0; - - // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - if (GETPOST('prod_entry_mode') == 'free') - { - $idprod=0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { - $idprod=GETPOST('idprod', 'int'); - $tva_tx = ''; - } - - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); - } - } - - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { - setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' - { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; - } - if ($qty == '') { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error ++; - } - - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - // Clean parameters - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), 0, GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), 0, GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - // Ecrase $base_price_type par celui du produit - if (! empty($idprod)) { - $prod = new Product($db); - $prod->fetch($idprod); - - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - - // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); - - // multiprix - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - { - $pu_ht = $prod->multiprices [$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc [$object->client->price_level]; - $price_min = $prod->multiprices_min [$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type [$object->client->price_level]; - if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) { - if (count($prodcustprice->lines) > 0) { - $found = true; - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; - } else { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; + // If some invoice's lines already known + $NBLINES = 8; + for($i = 1; $i <= $NBLINES; $i ++) { + if ($_POST ['idprod' . $i]) { + $xid = 'idprod' . $i; + $xqty = 'qty' . $i; + $xremise = 'remise_percent' . $i; + $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); } - } else { - setEventMessage($prodcustprice->error,'errors'); } } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } + } - // if price ht is forced (ie: calculated by margin rate and cost price) - if (! empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tva_tx != $prod->tva_tx) { - if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); - } else { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + // Insert default contacts if defined + if ($object_id > 0) { + if (GETPOST('contactidp')) { + $result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external'); + if ($result < 0) { + $mesg = '
' . $langs->trans("ErrorFailedToAddContact") . '
'; + $error ++; } } - $desc = ''; + $id = $object_id; + $action = ''; + } - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } - - $desc = dol_concatdesc($desc, $product_desc); - - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } - - $type = $prod->type; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); - } - - // Margin - $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->client); - $localtax2_tx = get_localtax($tva_tx, 2, $object->client); - - $desc = dol_htmlcleanlastbr($desc); - - $info_bits = 0; - if ($tva_npr) - $info_bits |= 0x01; - - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); - } else { - // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); - - if ($result > 0) { - $ret = $object->fetch($object->id); // Reload to get new records - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - $newlang = GETPOST('lang_id', 'alpha'); - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST ['prod_entry_mode']); - - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); - unset($_POST ['np_marginRate']); - unset($_POST ['np_markRate']); - unset($_POST ['dp_desc']); - unset($_POST ['idprod']); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); + // End of object creation, we show it + if ($object_id > 0 && ! $error) { + $db->commit(); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object_id); + exit(); } else { - setEventMessage($object->error, 'errors'); + $db->rollback(); + $action = 'create'; + if (! $mesg) + $mesg = '
' . $object->error . '
'; } } } -} -/* - * Mise a jour d'une ligne dans la commande -*/ -else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('save') == $langs->trans('Save')) { - // Clean parameters - $date_start=''; - $date_end=''; - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description=dol_htmlcleanlastbr(GETPOST('product_desc')); - $pu_ht=GETPOST('price_ht'); - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + else if ($action == 'classifybilled' && $user->rights->commande->creer) + { + $ret=$object->classifyBilled(); - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) - $info_bits |= 0x01; - - // Define vat_rate - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $object->client); - $localtax2_rate = get_localtax($vat_rate, 2, $object->client); - - // Add buying price - $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); - - // Extrafields Lines - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); - // Unset extrafield POST Data - if (is_array($extralabelsline)) { - foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); + if ($ret < 0) { + setEventMessage($object->error, 'errors'); } } - // Check minimum price - $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { - $product = new Product($db); - $product->fetch($productid); + // Positionne ref commande client + else if ($action == 'set_ref_client' && $user->rights->commande->creer) { + $object->set_ref_client($user, GETPOST('ref_client')); + } - $type = $product->type; + else if ($action == 'setremise' && $user->rights->commande->creer) { + $object->set_remise($user, GETPOST('remise')); + } - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - $price_min = $product->multiprices_min [$object->client->price_level]; - - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - - if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); - $error ++; - } - } else { - $type = GETPOST('type'); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - - // Check parameters - if (GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; + else if ($action == 'setabsolutediscount' && $user->rights->commande->creer) { + if (GETPOST('remise_id')) { + if ($object->id > 0) { + $object->insert_discount(GETPOST('remise_id')); + } else { + dol_print_error($db, $object->error); + } } } - if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); + else if ($action == 'setdate' && $user->rights->commande->creer) { + // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); - if ($result >= 0) { + $result = $object->set_date($user, $date); + if ($result < 0) { + $mesg = '
' . $object->error . '
'; + } + } + + else if ($action == 'setdate_livraison' && $user->rights->commande->creer) { + // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + + $result = $object->set_date_livraison($user, $datelivraison); + if ($result < 0) { + $mesg = '
' . $object->error . '
'; + } + } + + else if ($action == 'setmode' && $user->rights->commande->creer) { + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setavailability' && $user->rights->commande->creer) { + $result = $object->availability(GETPOST('availability_id')); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setdemandreason' && $user->rights->commande->creer) { + $result = $object->demand_reason(GETPOST('demand_reason_id')); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setconditions' && $user->rights->commande->creer) { + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + if ($result < 0) { + dol_print_error($db, $object->error); + } else { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); + $newlang = GETPOST('lang_id', 'alpha'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->client->default_lang; if (! empty($newlang)) { @@ -848,491 +494,848 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' $ret = $object->fetch($object->id); // Reload to get new records commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } + } + } - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['productid']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); + else if ($action == 'setremisepercent' && $user->rights->commande->creer) { + $result = $object->set_remise($user, GETPOST('remise_percent')); + } + + else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) { + $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); + } + + // Add a new line + else if ($action == 'addline' && $user->rights->commande->creer) { + $langs->load('errors'); + $error = 0; + + // Set if we used free entry or predefined product + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $price_ht = GETPOST('price_ht'); + if (GETPOST('prod_entry_mode') == 'free') + { + $idprod=0; + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { + $idprod=GETPOST('idprod', 'int'); + $tva_tx = ''; + } + + $qty = GETPOST('qty' . $predef); + $remise_percent = GETPOST('remise_percent' . $predef); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST ["options_" . $key]); + } + } + + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { + setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error ++; + } + if ($qty == '') { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); + $error ++; + } + + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + // Clean parameters + $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), 0, GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), 0, GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + // Ecrase $base_price_type par celui du produit + if (! empty($idprod)) { + $prod = new Product($db); + $prod->fetch($idprod); + + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); + + // Update if prices fields are defined + $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); + $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); + + // multiprix + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + { + $pu_ht = $prod->multiprices [$object->client->price_level]; + $pu_ttc = $prod->multiprices_ttc [$object->client->price_level]; + $price_min = $prod->multiprices_min [$object->client->price_level]; + $price_base_type = $prod->multiprices_base_type [$object->client->price_level]; + if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) { + if (count($prodcustprice->lines) > 0) { + $found = true; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; + } else { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + } else { + setEventMessage($prodcustprice->error,'errors'); + } + } + else + { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + + // if price ht is forced (ie: calculated by margin rate and cost price) + if (! empty($price_ht)) { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + elseif ($tva_tx != $prod->tva_tx) { + if ($price_base_type != 'HT') { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); + } else { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + } + + $desc = ''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if (empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + } else { + $desc = $prod->description; + } + + $desc = dol_concatdesc($desc, $product_desc); + + // Add custom code and origin country into description + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + $tmptxt = '('; + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + $tmptxt .= ')'; + $desc = dol_concatdesc($desc, $tmptxt); + } + + $type = $prod->type; + } else { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); + } + + // Margin + $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $object->client); + $localtax2_tx = get_localtax($tva_tx, 2, $object->client); + + $desc = dol_htmlcleanlastbr($desc); + + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessage($mesg, 'errors'); + } else { + // Insert line + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); + + if ($result > 0) { + $ret = $object->fetch($object->id); // Reload to get new records + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang = GETPOST('lang_id', 'alpha'); + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST ['prod_entry_mode']); + + unset($_POST ['qty']); + unset($_POST ['type']); + unset($_POST ['remise_percent']); + unset($_POST ['price_ht']); + unset($_POST ['price_ttc']); + unset($_POST ['tva_tx']); + unset($_POST ['product_ref']); + unset($_POST ['product_label']); + unset($_POST ['product_desc']); + unset($_POST ['fournprice']); + unset($_POST ['buying_price']); + unset($_POST ['np_marginRate']); + unset($_POST ['np_markRate']); + unset($_POST ['dp_desc']); + unset($_POST ['idprod']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + } else { + setEventMessage($object->error, 'errors'); + } + } + } + } + + /* + * Mise a jour d'une ligne dans la commande + */ + else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('save') == $langs->trans('Save')) { + // Clean parameters + $date_start=''; + $date_end=''; + $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $description=dol_htmlcleanlastbr(GETPOST('product_desc')); + $pu_ht=GETPOST('price_ht'); + $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $vat_rate)) + $info_bits |= 0x01; + + // Define vat_rate + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->client); + $localtax2_rate = get_localtax($vat_rate, 2, $object->client); + + // Add buying price + $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); + + // Extrafields Lines + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + // Unset extrafield POST Data + if (is_array($extralabelsline)) { + foreach ($extralabelsline as $key => $value) { + unset($_POST ["options_" . $key]); + } + } + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (! empty($productid)) { + $product = new Product($db); + $product->fetch($productid); + + $type = $product->type; + + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + $price_min = $product->multiprices_min [$object->client->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); + + if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { + setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + $error ++; + } } else { - setEventMessage($object->error, 'errors'); - } - } -} + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); -else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('cancel') == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition - exit(); -} - -else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) { - $idwarehouse = GETPOST('idwarehouse'); - - $qualified_for_stock_change=0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change=$object->hasProductsOrServices(2); - } - else - { - $qualified_for_stock_change=$object->hasProductsOrServices(1); - } - - // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) - { - if (! $idwarehouse || $idwarehouse == -1) - { - $error++; - $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; - $action=''; - } - } - - if (! $error) { - $result = $object->valid($user, $idwarehouse); - if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); + // Check parameters + if (GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } -} -// Go back to draft status -else if ($action == 'confirm_modif' && $user->rights->commande->creer) { - $idwarehouse = GETPOST('idwarehouse'); + if (! $error) { + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); - $qualified_for_stock_change=0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change=$object->hasProductsOrServices(2); - } - else - { - $qualified_for_stock_change=$object->hasProductsOrServices(1); - } + if ($result >= 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) - { - if (! $idwarehouse || $idwarehouse == -1) - { - $error++; - $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; - $action=''; - } - } + $ret = $object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } - if (! $error) { - $result = $object->set_draft($user, $idwarehouse); - if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + unset($_POST ['qty']); + unset($_POST ['type']); + unset($_POST ['productid']); + unset($_POST ['remise_percent']); + unset($_POST ['price_ht']); + unset($_POST ['price_ttc']); + unset($_POST ['tva_tx']); + unset($_POST ['product_ref']); + unset($_POST ['product_label']); + unset($_POST ['product_desc']); + unset($_POST ['fournprice']); + unset($_POST ['buying_price']); + } else { + setEventMessage($object->error, 'errors'); } } } -} -else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { - $result = $object->cloture($user); - if ($result < 0) { - setEventMessage($object->error, 'errors'); - } -} - -else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) { - $idwarehouse = GETPOST('idwarehouse'); - - $qualified_for_stock_change=0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change=$object->hasProductsOrServices(2); - } - else - { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('cancel') == $langs->trans('Cancel')) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + exit(); } - // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) - { - if (! $idwarehouse || $idwarehouse == -1) + else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) { + $idwarehouse = GETPOST('idwarehouse'); + + $qualified_for_stock_change=0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $error++; - $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; - $action=''; + $qualified_for_stock_change=$object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change=$object->hasProductsOrServices(1); + } + + // Check parameters + if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; + $action=''; + } + } + + if (! $error) { + $result = $object->valid($user, $idwarehouse); + if ($result >= 0) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } } } - if (! $error) { - $result = $object->cancel($idwarehouse); + // Go back to draft status + else if ($action == 'confirm_modif' && $user->rights->commande->creer) { + $idwarehouse = GETPOST('idwarehouse'); + $qualified_for_stock_change=0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change=$object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change=$object->hasProductsOrServices(1); + } + + // Check parameters + if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; + $action=''; + } + } + + if (! $error) { + $result = $object->set_draft($user, $idwarehouse); + if ($result >= 0) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + } + } + + else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { + $result = $object->cloture($user); if ($result < 0) { setEventMessage($object->error, 'errors'); } } -} -/* - * Ordonnancement des lignes -*/ + else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) { + $idwarehouse = GETPOST('idwarehouse'); -else if ($action == 'up' && $user->rights->commande->creer) { - $object->line_up(GETPOST('rowid')); + $qualified_for_stock_change=0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change=$object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change=$object->hasProductsOrServices(1); + } - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); + // Check parameters + if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; + $action=''; + } + } + + if (! $error) { + $result = $object->cancel($idwarehouse); + + if ($result < 0) { + setEventMessage($object->error, 'errors'); + } + } } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); - exit(); -} - -else if ($action == 'down' && $user->rights->commande->creer) { - $object->line_down(GETPOST('rowid')); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); - exit(); -} - -else if ($action == 'builddoc') // In get or post -{ /* - * Generate order document - * define into /core/modules/commande/modules_commande.php - */ + * Ordonnancement des lignes + */ - // Save last template used to generate document - if (GETPOST('model')) - $object->setDocModel($user, GETPOST('model', 'alpha')); + else if ($action == 'up' && $user->rights->commande->creer) { + $object->line_up(GETPOST('rowid')); // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - if ($result <= 0) { - dol_print_error($db, $result); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); exit(); } -} -// Remove file in doc form -else if ($action == 'remove_file') { - if ($object->id > 0) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + else if ($action == 'down' && $user->rights->commande->creer) { + $object->line_down(GETPOST('rowid')); - $langs->load("other"); - $upload_dir = $conf->commande->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); + exit(); + } + + else if ($action == 'builddoc') // In get or post + { + /* + * Generate order document + * define into /core/modules/commande/modules_commande.php + */ + + // Save last template used to generate document + if (GETPOST('model')) + $object->setDocModel($user, GETPOST('model', 'alpha')); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $result = commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + if ($result <= 0) { + dol_print_error($db, $result); + exit(); + } + } + + // Remove file in doc form + else if ($action == 'remove_file') { + if ($object->id > 0) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $langs->load("other"); + $upload_dir = $conf->commande->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) + setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else + setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + $action = ''; + } + } + + // Print file + else if ($action == 'print_file' and $user->rights->printipp->read) { + require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; + $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); + $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); + setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); $action = ''; } -} -// Print file -else if ($action == 'print_file' and $user->rights->printipp->read) { - require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; - $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); - $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); - setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); - $action = ''; -} - -else if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) - $error ++; - - if (! $error) { - // Actions on extra fields (by external module or standard code) - // FIXME le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('orderdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) + else if ($action == 'update_extras') { + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) $error ++; + + if (! $error) { + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('orderdao')); + $parameters = array('id' => $object->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by + // some hooks + if (empty($reshook)) { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } else if ($reshook < 0) + $error ++; + } + + if ($error) + $action = 'edit_extras'; } - if ($error) - $action = 'edit_extras'; -} + /* + * Add file in email form + */ + if (GETPOST('addfile')) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; -/* - * Add file in email form -*/ -if (GETPOST('addfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; + dol_add_file_process($upload_dir_tmp, 0, 0); + $action = 'presend'; + } - dol_add_file_process($upload_dir_tmp, 0, 0); - $action = 'presend'; -} + /* + * Remove file in email form + */ + if (GETPOST('removedfile')) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; -/* - * Remove file in email form -*/ -if (GETPOST('removedfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + // Set tmp user directory + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; - // Set tmp user directory - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; + // TODO Delete only files that was uploaded from email form + dol_remove_file_process(GETPOST('removedfile'), 0); + $action = 'presend'; + } - // TODO Delete only files that was uploaded from email form - dol_remove_file_process(GETPOST('removedfile'), 0); - $action = 'presend'; -} + /* + * Send mail + */ + if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { + $langs->load('mails'); -/* - * Send mail -*/ -if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { - $langs->load('mails'); + if ($object->id > 0) { + // $ref = dol_sanitizeFileName($object->ref); + // $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - if ($object->id > 0) { - // $ref = dol_sanitizeFileName($object->ref); - // $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - - // if (is_readable($file)) - // { - if (GETPOST('sendto')) { - // Le destinataire a ete fourni via le champ libre - $sendto = GETPOST('sendto'); - $sendtoid = 0; - } elseif (GETPOST('receiver') != '-1') { - // Recipient was provided from combo list - if (GETPOST('receiver') == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; + // if (is_readable($file)) + // { + if (GETPOST('sendto')) { + // Le destinataire a ete fourni via le champ libre + $sendto = GETPOST('sendto'); $sendtoid = 0; - } else // Id du contact - { - $sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email'); - $sendtoid = GETPOST('receiver'); - } - } - - if (dol_strlen($sendto)) { - $langs->load("commercial"); - - $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>'; - $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>'; - $message = GETPOST('message'); - $sendtocc = GETPOST('sendtocc'); - $deliveryreceipt = GETPOST('deliveryreceipt'); - - if ($action == 'send') { - if (dol_strlen(GETPOST('subject'))) - $subject = GETPOST('subject'); - else - $subject = $langs->transnoentities('Order') . ' ' . $object->ref; - $actiontypecode = 'AC_COM'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; - if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; + } elseif (GETPOST('receiver') != '-1') { + // Recipient was provided from combo list + if (GETPOST('receiver') == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } else // Id du contact + { + $sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email'); + $sendtoid = GETPOST('receiver'); } - $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); } - // Create form object - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); + if (dol_strlen($sendto)) { + $langs->load("commercial"); - $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles ['paths']; - $filename = $attachedfiles ['names']; - $mimetype = $attachedfiles ['mimes']; + $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>'; + $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>'; + $message = GETPOST('message'); + $sendtocc = GETPOST('sendtocc'); + $deliveryreceipt = GETPOST('deliveryreceipt'); - // Send mail - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); - if ($mailfile->error) { - $mesg = '
' . $mailfile->error . '
'; - } else { - $result = $mailfile->sendfile(); - if ($result) { - $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); // Must not - // contains " - - $error = 0; - - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2 = $actionmsg2; - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers('ORDER_SENTBYMAIL', $object, $user, $langs, $conf); - if ($result < 0) { - $error ++; - $this->errors = $interface->errors; + if ($action == 'send') { + if (dol_strlen(GETPOST('subject'))) + $subject = GETPOST('subject'); + else + $subject = $langs->transnoentities('Order') . ' ' . $object->ref; + $actiontypecode = 'AC_COM'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + if ($message) { + $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; + $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; + $actionmsg .= $message; } - // Fin appel triggers + $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); + } - if ($error) { - dol_print_error($db); - } else { - // Redirect here - // This avoid sending mail twice if going out and then back to page - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&mesg=' . urlencode($mesg)); - exit(); - } + // Create form object + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles = $formmail->get_attached_files(); + $filepath = $attachedfiles ['paths']; + $filename = $attachedfiles ['names']; + $mimetype = $attachedfiles ['mimes']; + + // Send mail + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); + if ($mailfile->error) { + $mesg = '
' . $mailfile->error . '
'; } else { - $langs->load("other"); - $mesg = '
'; - if ($mailfile->error) { - $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); - $mesg .= '
' . $mailfile->error; + $result = $mailfile->sendfile(); + if ($result) { + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); // Must not + // contains " + + $error = 0; + + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface = new Interfaces($db); + $result = $interface->run_triggers('ORDER_SENTBYMAIL', $object, $user, $langs, $conf); + if ($result < 0) { + $error ++; + $this->errors = $interface->errors; + } + // Fin appel triggers + + if ($error) { + dol_print_error($db); + } else { + // Redirect here + // This avoid sending mail twice if going out and then back to page + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&mesg=' . urlencode($mesg)); + exit(); + } } else { - $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + $langs->load("other"); + $mesg = '
'; + if ($mailfile->error) { + $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); + $mesg .= '
' . $mailfile->error; + } else { + $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg .= '
'; } - $mesg .= '
'; + } + /* } + else + { + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; + $action='presend'; + dol_syslog('Recipient email is empty'); + }*/ + } else { + $langs->load("errors"); + $mesg = '
' . $langs->trans('ErrorCantReadFile', $file) . '
'; + dol_syslog('Failed to read file: ' . $file); + } + } else { + $langs->load("other"); + $mesg = '
' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Order")) . '
'; + dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order"))); + } + } + + if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) { + if ($action == 'addcontact') { + if ($object->id > 0) { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); + } + + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + $mesg = '
' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '
'; + } else { + $mesg = '
' . $object->error . '
'; } } - /* } - else - { - $langs->load("other"); - $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; - $action='presend'; - dol_syslog('Recipient email is empty'); - }*/ - } else { - $langs->load("errors"); - $mesg = '
' . $langs->trans('ErrorCantReadFile', $file) . '
'; - dol_syslog('Failed to read file: ' . $file); - } - } else { - $langs->load("other"); - $mesg = '
' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Order")) . '
'; - dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order"))); - } -} - -if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) { - if ($action == 'addcontact') { - if ($object->id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); } - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - $mesg = '
' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '
'; + // bascule du statut d'un contact + else if ($action == 'swapstatut') { + if ($object->id > 0) { + $result = $object->swapContactStatus(GETPOST('ligne')); } else { - $mesg = '
' . $object->error . '
'; + dol_print_error($db); } } - } - // bascule du statut d'un contact - else if ($action == 'swapstatut') { - if ($object->id > 0) { - $result = $object->swapContactStatus(GETPOST('ligne')); - } else { - dol_print_error($db); - } - } + // Efface un contact + else if ($action == 'deletecontact') { + $result = $object->delete_contact($lineid); - // Efface un contact - else if ($action == 'deletecontact') { - $result = $object->delete_contact($lineid); - - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - dol_print_error($db); + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + dol_print_error($db); + } } } } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c6214f449cb..a3403e0d9dd 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -111,71 +111,1342 @@ $permissionnote = $user->rights->facture->creer; // Used by the include of actio $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once +if (empty($reshook)) { -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) { - if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { - $mesgs [] = '
' . $langs->trans("NoCloneOptionsSpecified") . '
'; - } else { - if ($object->fetch($id) > 0) { - $result = $object->createFromClone($socid); + include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) { + if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { + $mesgs [] = '
' . $langs->trans("NoCloneOptionsSpecified") . '
'; + } else { + if ($object->fetch($id) > 0) { + $result = $object->createFromClone($socid); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); + exit(); + } else { + setEventMessage($object->error, 'errors'); + $action = ''; + } + } + } + } + + // Change status of invoice + else if ($action == 'reopen' && $user->rights->facture->creer) { + $result = $object->fetch($id); + if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced')) { + $result = $object->set_unpaid($user); if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); exit(); } else { setEventMessage($object->error, 'errors'); + } + } + } + + // Delete invoice + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) { + $result = $object->fetch($id); + $object->fetch_thirdparty(); + + $idwarehouse = GETPOST('idwarehouse'); + + $qualified_for_stock_change = 0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } else { + $qualified_for_stock_change = $object->hasProductsOrServices(1); + } + + $result = $object->delete(0, 0, $idwarehouse); + if ($result > 0) { + header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php'); + exit(); + } else { + setEventMessage($object->error, 'errors'); + $action=''; + } + } + + // Delete line + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) { + $object->fetch($id); + $object->fetch_thirdparty(); + + $result = $object->deleteline($_GET ['lineid'], $user); + if ($result > 0) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($id); // Reload to get new records + $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + if ($result >= 0) { + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + exit(); + } + } else { + setEventMessage($object->error, 'errors'); + $action = ''; + } + } + + // Delete link of credit note to invoice + else if ($action == 'unlinkdiscount' && $user->rights->facture->creer) { + $discount = new DiscountAbsolute($db); + $result = $discount->fetch($_GET ["discountid"]); + $discount->unlink_invoice(); + } + + // Validation + else if ($action == 'valid' && $user->rights->facture->creer) { + $object->fetch($id); + + // On verifie signe facture + if ($object->type == Facture::TYPE_CREDIT_NOTE) { + // Si avoir, le signe doit etre negatif + if ($object->total_ht >= 0) { + $mesgs [] = '
' . $langs->trans("ErrorInvoiceAvoirMustBeNegative") . '
'; + $action = ''; + } + } else { + // Si non avoir, le signe doit etre positif + if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0) { + $mesgs [] = '
' . $langs->trans("ErrorInvoiceOfThisTypeMustBePositive") . '
'; $action = ''; } } } -} -// Change status of invoice -else if ($action == 'reopen' && $user->rights->facture->creer) { - $result = $object->fetch($id); - if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced')) { - $result = $object->set_unpaid($user); - if ($result > 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); - exit(); - } else { - setEventMessage($object->error, 'errors'); + else if ($action == 'set_thirdparty' && $user->rights->facture->creer) { + $object->fetch($id); + $object->setValueFrom('fk_soc', $socid); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + exit(); + } + + else if ($action == 'classin' && $user->rights->facture->creer) { + $object->fetch($id); + $object->setProject($_POST['projectid']); + } + + else if ($action == 'setmode' && $user->rights->facture->creer) { + $object->fetch($id); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setinvoicedate' && $user->rights->facture->creer) + { + $object->fetch($id); + $old_date_lim_reglement = $object->date_lim_reglement; + $date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); + if (empty($date)) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); + exit; + } + $object->date=$date; + $new_date_lim_reglement = $object->calculate_date_lim_reglement(); + if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; + if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; + $result = $object->update($user); + if ($result < 0) dol_print_error($db, $object->error); + } + + else if ($action == 'setconditions' && $user->rights->facture->creer) { + $object->fetch($id); + $object->cond_reglement_code = 0; // To clean property + $object->cond_reglement_id = 0; // To clean property + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + if ($result < 0) dol_print_error($db, $object->error); + + $old_date_lim_reglement = $object->date_lim_reglement; + $new_date_lim_reglement = $object->calculate_date_lim_reglement(); + if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; + if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; + $result = $object->update($user); + if ($result < 0) dol_print_error($db, $object->error); + } + + else if ($action == 'setpaymentterm' && $user->rights->facture->creer) { + $object->fetch($id); + $object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']); + if ($object->date_lim_reglement < $object->date) { + $object->date_lim_reglement = $object->calculate_date_lim_reglement(); + setEventMessage($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), 'warnings'); + } + $result = $object->update($user); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setrevenuestamp' && $user->rights->facture->creer) { + $object->fetch($id); + $object->revenuestamp = GETPOST('revenuestamp'); + $result = $object->update($user); + $object->update_price(1); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setremisepercent' && $user->rights->facture->creer) { + $object->fetch($id); + $result = $object->set_remise($user, $_POST['remise_percent']); + } + + else if ($action == "setabsolutediscount" && $user->rights->facture->creer) { + // POST[remise_id] ou POST[remise_id_for_payment] + if (! empty($_POST["remise_id"])) { + $ret = $object->fetch($id); + if ($ret > 0) { + $result = $object->insert_discount($_POST["remise_id"]); + if ($result < 0) { + $mesgs [] = '
' . $object->error . '
'; + } + } else { + dol_print_error($db, $object->error); + } + } + if (! empty($_POST["remise_id_for_payment"])) { + require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + $discount = new DiscountAbsolute($db); + $discount->fetch($_POST["remise_id_for_payment"]); + + $result = $discount->link_to_invoice(0, $id); + if ($result < 0) { + $mesgs [] = '
' . $discount->error . '
'; + } } } -} -// Delete invoice -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) { - $result = $object->fetch($id); - $object->fetch_thirdparty(); - - $idwarehouse = GETPOST('idwarehouse'); - - $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + else if ($action == 'set_ref_client' && $user->rights->facture->creer) { + $object->fetch($id); + $object->set_ref_client($_POST['ref_client']); } - $result = $object->delete(0, 0, $idwarehouse); - if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php'); + // Classify to validated + else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) + { + $idwarehouse = GETPOST('idwarehouse'); + + $object->fetch($id); + $object->fetch_thirdparty(); + + // Check parameters + + // Check for mandatory prof id + for($i = 1; $i < 6; $i ++) + { + $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; + $idprof = 'idprof' . $i; + if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) { + if (! $error) + $langs->load("errors"); + $error ++; + + setEventMessage($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), 'errors'); + } + } + + $qualified_for_stock_change = 0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } else { + $qualified_for_stock_change = $object->hasProductsOrServices(1); + } + + // Check for warehouse + if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) { + if (! $idwarehouse || $idwarehouse == - 1) { + $error ++; + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors'); + $action = ''; + } + } + + if (! $error) + { + $result = $object->validate($user, '', $idwarehouse); + if ($result >= 0) + { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($id); // Reload to get new records + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } else { + if (count($object->errors)) setEventMessage($object->errors, 'errors'); + else setEventMessage($object->error, 'errors'); + } + } + } + + // Go back to draft status (unvalidate) + else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)) { + $idwarehouse = GETPOST('idwarehouse'); + + $object->fetch($id); + $object->fetch_thirdparty(); + + $qualified_for_stock_change = 0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } else { + $qualified_for_stock_change = $object->hasProductsOrServices(1); + } + + // Check parameters + if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) { + if (! $idwarehouse || $idwarehouse == - 1) { + $error ++; + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors'); + $action = ''; + } + } + + if (! $error) { + // On verifie si la facture a des paiements + $sql = 'SELECT pf.amount'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf'; + $sql .= ' WHERE pf.fk_facture = ' . $object->id; + + $result = $db->query($sql); + if ($result) { + $i = 0; + $num = $db->num_rows($result); + + while ($i < $num) { + $objp = $db->fetch_object($result); + $totalpaye += $objp->amount; + $i ++; + } + } else { + dol_print_error($db, ''); + } + + $resteapayer = $object->total_ttc - $totalpaye; + + // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees + $ventilExportCompta = $object->getVentilExportCompta(); + + // On verifie si aucun paiement n'a ete effectue + if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) { + $result=$object->set_draft($user, $idwarehouse); + if ($result<0) setEventMessage($object->error,'errors'); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($id); // Reload to get new records + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + } + } + + // Classify "paid" + else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) { + $object->fetch($id); + $result = $object->set_paid($user); + if ($result<0) setEventMessage($object->error,'errors'); + } // Classif "paid partialy" + else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) { + $object->fetch($id); + $close_code = $_POST["close_code"]; + $close_note = $_POST["close_note"]; + if ($close_code) { + $result = $object->set_paid($user, $close_code, $close_note); + if ($result<0) setEventMessage($object->error,'errors'); + } else { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors'); + } + } // Classify "abandoned" + else if ($action == 'confirm_canceled' && $confirm == 'yes') { + $object->fetch($id); + $close_code = $_POST["close_code"]; + $close_note = $_POST["close_note"]; + if ($close_code) { + $result = $object->set_canceled($user, $close_code, $close_note); + if ($result<0) setEventMessage($object->error,'errors'); + } else { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors'); + } + } + + // Convertir en reduc + else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer) + { + $object->fetch($id); + $object->fetch_thirdparty(); + //$object->fetch_lines(); // Already done into fetch + + // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) + $discountcheck=new DiscountAbsolute($db); + $result=$discountcheck->fetch(0,$object->id); + + $canconvert=0; + if ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 1 && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed completely and not already converted (see real condition into condition used to show button converttoreduc) + if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + if ($canconvert) + { + $db->begin(); + + // Boucle sur chaque taux de tva + $i = 0; + foreach ($object->lines as $line) { + $amount_ht [$line->tva_tx] += $line->total_ht; + $amount_tva [$line->tva_tx] += $line->total_tva; + $amount_ttc [$line->tva_tx] += $line->total_ttc; + $i ++; + } + + // Insert one discount by VAT rate category + $discount = new DiscountAbsolute($db); + if ($object->type == Facture::TYPE_CREDIT_NOTE) + $discount->description = '(CREDIT_NOTE)'; + elseif ($object->type == Facture::TYPE_DEPOSIT) + $discount->description = '(DEPOSIT)'; + else { + setEventMessage($langs->trans('CantConvertToReducAnInvoiceOfThisType'),'errors'); + } + $discount->tva_tx = abs($object->total_ttc); + $discount->fk_soc = $object->socid; + $discount->fk_facture_source = $object->id; + + $error = 0; + foreach ($amount_ht as $tva_tx => $xxx) { + $discount->amount_ht = abs($amount_ht [$tva_tx]); + $discount->amount_tva = abs($amount_tva [$tva_tx]); + $discount->amount_ttc = abs($amount_ttc [$tva_tx]); + $discount->tva_tx = abs($tva_tx); + + $result = $discount->create($user); + if ($result < 0) + { + $error++; + break; + } + } + + if (empty($error)) + { + // Classe facture + $result = $object->set_paid($user); + if ($result >= 0) + { + //$mesgs[]='OK'.$discount->id; + $db->commit(); + } + else + { + setEventMessage($object->error,'errors'); + $db->rollback(); + } + } + else + { + setEventMessage($discount->error,'errors'); + $db->rollback(); + } + } + } + + /* + * Insert new invoice in database + */ + else if ($action == 'add' && $user->rights->facture->creer) + { + if ($socid > 0) $object->socid = GETPOST('socid', 'int'); + + $db->begin(); + + $error = 0; + + // Fill array 'array_options' with data from add form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) $error ++; + + // Replacement invoice + if ($_POST['type'] == Facture::TYPE_REPLACEMENT) + { + $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($dateinvoice)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + } + + if (! ($_POST['fac_replacement'] > 0)) { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), 'errors'); + } + + if (! $error) { + // This is a replacement invoice + $result = $object->fetch($_POST['fac_replacement']); + $object->fetch_thirdparty(); + + $object->date = $dateinvoice; + $object->note_public = trim($_POST['note_public']); + $object->note = trim($_POST['note']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = $_POST['cond_reglement_id']; + $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->remise_absolue = $_POST['remise_absolue']; + $object->remise_percent = $_POST['remise_percent']; + + // Proprietes particulieres a facture de remplacement + $object->fk_facture_source = $_POST['fac_replacement']; + $object->type = Facture::TYPE_REPLACEMENT; + + $id = $object->createFromCurrent($user); + if ($id <= 0) + $mesgs [] = $object->error; + } + } + + // Credit note invoice + if ($_POST['type'] == Facture::TYPE_CREDIT_NOTE) + { + if (! ($_POST['fac_avoir'] > 0)) + { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), 'errors'); + } + + $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($dateinvoice)) + { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->trans("Date")), 'errors'); + } + + if (! $error) + { + $object->socid = GETPOST('socid','int'); + $object->number = $_POST['facnumber']; + $object->date = $dateinvoice; + $object->note_public = trim($_POST['note_public']); + $object->note = trim($_POST['note']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = 0; + $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->remise_absolue = $_POST['remise_absolue']; + $object->remise_percent = $_POST['remise_percent']; + + // Proprietes particulieres a facture avoir + $object->fk_facture_source = $_POST['fac_avoir']; + $object->type = Facture::TYPE_CREDIT_NOTE; + + $id = $object->create($user); + + if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) + { + $facture_source = new Facture($db); // fetch origin object + if ($facture_source->fetch($object->fk_facture_source)>0) + { + + foreach($facture_source->lines as $line) + { + $line->fk_facture = $object->id; + + $line->subprice =-$line->subprice; // invert price for object + $line->pa_ht = -$line->pa_ht; + $line->total_ht=-$line->total_ht; + $line->total_tva=-$line->total_tva; + $line->total_ttc=-$line->total_ttc; + $line->total_localtax1=-$line->total_localtax1; + $line->total_localtax2=-$line->total_localtax2; + + $line->insert(); + + $object->lines[] = $line; // insert new line in current object + } + + $object->update_price(1); + } + + } + + if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) { + + $facture_source = new Facture($db); // fetch origin object if not previously defined + if($facture_source->fetch($object->fk_facture_source)>0) { + $totalpaye = $facture_source->getSommePaiement(); + $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); + $totaldeposits = $facture_source->getSumDepositsUsed(); + $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); + + $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC'); + } + } + + // Add predefined lines + /* + TODO delete + for($i = 1; $i <= $NBLINES; $i ++) { + if ($_POST['idprod' . $i]) { + $product = new Product($db); + $product->fetch($_POST['idprod' . $i]); + $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); + $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); + $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); + } + }*/ + } + } + + // Standard invoice or Deposit invoice created from a Predefined invoice + if (($_POST['type'] == 0 || $_POST['type'] == 3) && $_POST['fac_rec'] > 0) + { + $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($dateinvoice)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + } + + if (! $error) + { + $object->socid = GETPOST('socid','int'); + $object->type = $_POST['type']; + $object->number = $_POST['facnumber']; + $object->date = $dateinvoice; + $object->note_public = trim($_POST['note_public']); + $object->note_private = trim($_POST['note_private']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + + // Source facture + $object->fac_rec = $_POST['fac_rec']; + + $id = $object->create($user); + } + } + + // Standard or deposit or proforma invoice + if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0) + { + if (GETPOST('socid', 'int') < 1) + { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); + } + + $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($dateinvoice)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + } + + if (! $error) + { + // Si facture standard + $object->socid = GETPOST('socid','int'); + $object->type = GETPOST('type'); + $object->number = $_POST['facnumber']; + $object->date = $dateinvoice; + $object->note_public = trim($_POST['note_public']); + $object->note_private = trim($_POST['note_private']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); + $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->amount = $_POST['amount']; + $object->remise_absolue = $_POST['remise_absolue']; + $object->remise_percent = $_POST['remise_percent']; + + $object->fetch_thirdparty(); + + // If creation from another object of another module (Example: origin=propal, originid=1) + if ($_POST['origin'] && $_POST['originid']) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $_POST['origin']; + if (preg_match('/^([^_]+)_([^_]+)/i', $_POST['origin'], $regs)) { + $element = $regs [1]; + $subelement = $regs [2]; + } + + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; + $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } + if ($element == 'inter') { + $element = $subelement = 'ficheinter'; + } + if ($element == 'shipping') { + $element = $subelement = 'expedition'; + } + + $object->origin = $_POST['origin']; + $object->origin_id = $_POST['originid']; + + // Possibility to add external linked objects with hooks + $object->linked_objects [$object->origin] = $object->origin_id; + if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { + $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + } + + $id = $object->create($user); + + if ($id > 0) + { + // If deposit invoice + if ($_POST['type'] == 3) + { + $typeamount = GETPOST('typedeposit', 'alpha'); + $valuedeposit = GETPOST('valuedeposit', 'int'); + + if ($typeamount == 'amount') + { + $amountdeposit = $valuedeposit; + } + else + { + $amountdeposit = 0; + + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add deposit lines"); + $result = $srcobject->fetch($object->origin_id); + if ($result > 0) + { + $totalamount = 0; + $lines = $srcobject->lines; + $numlines=count($lines); + for ($i=0; $i<$numlines; $i++) + { + $qualified=1; + if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option + if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...) + if ($qualified) $totalamount += $lines[$i]->total_ht; + } + + if ($totalamount != 0) { + $amountdeposit = ($totalamount * $valuedeposit) / 100; + } + } else { + $mesgs [] = $srcobject->error; + $error ++; + } + } + + $result = $object->addline( + $langs->trans('Deposit'), + $amountdeposit, // subprice + 1, // quantity + $lines [$i]->tva_tx, 0, // localtax1_tx + 0, // localtax2_tx + 0, // fk_product + 0, // remise_percent + 0, // date_start + 0, // date_end + 0, $lines [$i]->info_bits, // info_bits + 0, // info_bits + 'HT', + 0, + 0, // product_type + 1, + $lines [$i]->special_code, + $object->origin, + 0, + 0, + 0, + 0, + $langs->trans('Deposit') + ); + } + else + { + + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + { + $srcobject->fetch_lines(); + $lines = $srcobject->lines; + } + + $fk_parent_line=0; + $num=count($lines); + for ($i=0;$i<$num;$i++) + { + $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); + $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + + if ($lines [$i]->subprice < 0) + { + // Negative line, we create a discount line + $discount = new DiscountAbsolute($db); + $discount->fk_soc = $object->socid; + $discount->amount_ht = abs($lines [$i]->total_ht); + $discount->amount_tva = abs($lines [$i]->total_tva); + $discount->amount_ttc = abs($lines [$i]->total_ttc); + $discount->tva_tx = $lines [$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); + if ($discountid > 0) { + $result = $object->insert_discount($discountid); // This include link_to_invoice + } else { + $mesgs [] = $discount->error; + $error ++; + break; + } + } else { + // Positive line + $product_type = ($lines [$i]->product_type ? $lines [$i]->product_type : 0); + + // Date start + $date_start = false; + if ($lines [$i]->date_debut_prevue) + $date_start = $lines [$i]->date_debut_prevue; + if ($lines [$i]->date_debut_reel) + $date_start = $lines [$i]->date_debut_reel; + if ($lines [$i]->date_start) + $date_start = $lines [$i]->date_start; + + // Date end + $date_end = false; + if ($lines [$i]->date_fin_prevue) + $date_end = $lines [$i]->date_fin_prevue; + if ($lines [$i]->date_fin_reel) + $date_end = $lines [$i]->date_fin_reel; + if ($lines [$i]->date_end) + $date_end = $lines [$i]->date_end; + + // Reset fk_parent_line for no child products and special product + if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) { + $lines [$i]->fetch_optionals($lines [$i]->rowid); + $array_option = $lines [$i]->array_options; + } + + $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $date_start, $date_end, 0, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $object->origin, $lines [$i]->rowid, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); + + if ($result > 0) { + $lineid = $result; + } else { + $lineid = 0; + $error ++; + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines [$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) + $error ++; + } else { + $mesgs [] = $srcobject->error; + $error ++; + } + } + } else { + $mesgs [] = $object->error; + $error ++; + } + } // If some invoice's lines already known + else { + $id = $object->create($user); + + for($i = 1; $i <= $NBLINES; $i ++) { + if ($_POST['idprod' . $i]) { + $product = new Product($db); + $product->fetch($_POST['idprod' . $i]); + $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); + $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); + $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); + } + } + } + } + } + + // End of object creation, we show it + if ($id > 0 && ! $error) + { + $db->commit(); + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + exit(); + } + else + { + $db->rollback(); + $action = 'create'; + $_GET ["origin"] = $_POST["origin"]; + $_GET ["originid"] = $_POST["originid"]; + $mesgs [] = '
' . $object->error . '
'; + } + } + + // Add a new line + else if ($action == 'addline' && $user->rights->facture->creer) + { + $langs->load('errors'); + $error = 0; + + // Set if we used free entry or predefined product + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $price_ht = GETPOST('price_ht'); + if (GETPOST('prod_entry_mode') == 'free') + { + $idprod=0; + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { + $idprod=GETPOST('idprod', 'int'); + $tva_tx = ''; + } + + $qty = GETPOST('qty' . $predef); + $remise_percent = GETPOST('remise_percent' . $predef); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key . $predef]); + } + } + + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { + setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error ++; + } + if ($qty == '') { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); + $error ++; + } + + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + $ret = $object->fetch($id); + if ($ret < 0) { + dol_print_error($db, $object->error); + exit(); + } + $ret = $object->fetch_thirdparty(); + + // Clean parameters + $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); + $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); + + // Define special_code for special lines + $special_code = 0; + // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + // Ecrase $base_price_type par celui du produit + if (! empty($idprod)) { + $prod = new Product($db); + $prod->fetch($idprod); + + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); + + // Update if prices fields are defined + $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); + $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); + + // We define price for product + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + { + $pu_ht = $prod->multiprices[$object->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; + $price_min = $prod->multiprices_min[$object->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; + if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) { + if (count($prodcustprice->lines) > 0) { + $found = true; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; + }else { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + } else { + setEventMessage($prodcustprice->error,'errors'); + } + } + else + { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + + // if price ht is forced (ie: calculated by margin rate and cost price) + if (! empty($price_ht)) { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + elseif ($tva_tx != $prod->tva_tx) { + if ($price_base_type != 'HT') { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); + } else { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + } + + $desc = ''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if (empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + } else { + $desc = $prod->description; + } + + $desc = dol_concatdesc($desc, $product_desc); + + // Add custom code and origin country into description + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + $tmptxt = '('; + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + $tmptxt .= ')'; + $desc = dol_concatdesc($desc, $tmptxt); + } + + $type = $prod->type; + } else { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); + } + + // Margin + $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $buyingprice = price2num(GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $object->client); + $localtax2_tx = get_localtax($tva_tx, 2, $object->client); + + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessage($mesg, 'errors'); + } else { + // Insert line + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); + + if ($result > 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang = GETPOST('lang_id', 'alpha'); + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $ret = $object->fetch($id); // Reload to get new records + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST ['prod_entry_mode']); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + unset($_POST['dp_desc']); + unset($_POST['idprod']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + } else { + setEventMessage($object->error, 'errors'); + } + + $action = ''; + } + } + } + + elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel')) { + if (! $object->fetch($id) > 0) + dol_print_error($db); + $object->fetch_thirdparty(); + + // Clean parameters + $date_start = ''; + $date_end = ''; + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc')); + $pu_ht = GETPOST('price_ht'); + $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $vat_rate)) + $info_bits |= 0x01; + + // Define vat_rate + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->client); + $localtax2_rate = get_localtax($vat_rate, 2, $object->client); + + // Add buying price + $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $buyingprice = price2num(GETPOST('buying_price') ? GETPOST('buying_price') : ''); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key]); + } + } + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (! empty($productid)) { + $product = new Product($db); + $product->fetch($productid); + + $type = $product->type; + + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + $price_min = $product->multiprices_min [$object->client->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); + + // Check price is not lower than minimum (check is done only for standard or replacement invoices) + if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { + setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + $error ++; + } + } else { + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + + // Check parameters + if (GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; + } + } + + // Update line + if (! $error) { + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); + + if ($result >= 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $ret = $object->fetch($id); // Reload to get new records + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + } else { + setEventMessage($object->error, 'errors'); + } + } + } + + else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition exit(); - } else { - setEventMessage($object->error, 'errors'); - $action=''; } -} -// Delete line -else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); + // Modify line position (up) + else if ($action == 'up' && $user->rights->facture->creer) { + $object->fetch($id); + $object->fetch_thirdparty(); + $object->line_up($_GET ['rowid']); - $result = $object->deleteline($_GET ['lineid'], $user); - if ($result > 0) { // Define output language $outputlangs = $langs; $newlang = ''; @@ -187,1626 +1458,358 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($id); // Reload to get new records - $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '#' . $_GET ['rowid']); + exit(); + } // Modify line position (down) + else if ($action == 'down' && $user->rights->facture->creer) { + $object->fetch($id); + $object->fetch_thirdparty(); + $object->line_down($_GET ['rowid']); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); } - if ($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); - exit(); - } - } else { - setEventMessage($object->error, 'errors'); - $action = ''; - } -} + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); -// Delete link of credit note to invoice -else if ($action == 'unlinkdiscount' && $user->rights->facture->creer) { - $discount = new DiscountAbsolute($db); - $result = $discount->fetch($_GET ["discountid"]); - $discount->unlink_invoice(); -} - -// Validation -else if ($action == 'valid' && $user->rights->facture->creer) { - $object->fetch($id); - - // On verifie signe facture - if ($object->type == Facture::TYPE_CREDIT_NOTE) { - // Si avoir, le signe doit etre negatif - if ($object->total_ht >= 0) { - $mesgs [] = '
' . $langs->trans("ErrorInvoiceAvoirMustBeNegative") . '
'; - $action = ''; - } - } else { - // Si non avoir, le signe doit etre positif - if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0) { - $mesgs [] = '
' . $langs->trans("ErrorInvoiceOfThisTypeMustBePositive") . '
'; - $action = ''; - } - } -} - -else if ($action == 'set_thirdparty' && $user->rights->facture->creer) { - $object->fetch($id); - $object->setValueFrom('fk_soc', $socid); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); - exit(); -} - -else if ($action == 'classin' && $user->rights->facture->creer) { - $object->fetch($id); - $object->setProject($_POST['projectid']); -} - -else if ($action == 'setmode' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setinvoicedate' && $user->rights->facture->creer) -{ - $object->fetch($id); - $old_date_lim_reglement = $object->date_lim_reglement; - $date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); - if (empty($date)) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); - exit; - } - $object->date=$date; - $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; - if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; - $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); -} - -else if ($action == 'setconditions' && $user->rights->facture->creer) { - $object->fetch($id); - $object->cond_reglement_code = 0; // To clean property - $object->cond_reglement_id = 0; // To clean property - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) dol_print_error($db, $object->error); - - $old_date_lim_reglement = $object->date_lim_reglement; - $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; - if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; - $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); -} - -else if ($action == 'setpaymentterm' && $user->rights->facture->creer) { - $object->fetch($id); - $object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']); - if ($object->date_lim_reglement < $object->date) { - $object->date_lim_reglement = $object->calculate_date_lim_reglement(); - setEventMessage($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), 'warnings'); - } - $result = $object->update($user); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setrevenuestamp' && $user->rights->facture->creer) { - $object->fetch($id); - $object->revenuestamp = GETPOST('revenuestamp'); - $result = $object->update($user); - $object->update_price(1); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setremisepercent' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->set_remise($user, $_POST['remise_percent']); -} - -else if ($action == "setabsolutediscount" && $user->rights->facture->creer) { - // POST[remise_id] ou POST[remise_id_for_payment] - if (! empty($_POST["remise_id"])) { - $ret = $object->fetch($id); - if ($ret > 0) { - $result = $object->insert_discount($_POST["remise_id"]); - if ($result < 0) { - $mesgs [] = '
' . $object->error . '
'; - } - } else { - dol_print_error($db, $object->error); - } - } - if (! empty($_POST["remise_id_for_payment"])) { - require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; - $discount = new DiscountAbsolute($db); - $discount->fetch($_POST["remise_id_for_payment"]); - - $result = $discount->link_to_invoice(0, $id); - if ($result < 0) { - $mesgs [] = '
' . $discount->error . '
'; - } - } -} - -else if ($action == 'set_ref_client' && $user->rights->facture->creer) { - $object->fetch($id); - $object->set_ref_client($_POST['ref_client']); -} - -// Classify to validated -else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) -{ - $idwarehouse = GETPOST('idwarehouse'); - - $object->fetch($id); - $object->fetch_thirdparty(); - - // Check parameters - - // Check for mandatory prof id - for($i = 1; $i < 6; $i ++) - { - $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; - $idprof = 'idprof' . $i; - if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) { - if (! $error) - $langs->load("errors"); - $error ++; - - setEventMessage($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), 'errors'); - } - } - - $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); - } - - // Check for warehouse - if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == - 1) { - $error ++; - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors'); - $action = ''; - } - } - - if (! $error) - { - $result = $object->validate($user, '', $idwarehouse); - if ($result >= 0) - { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } else { - if (count($object->errors)) setEventMessage($object->errors, 'errors'); - else setEventMessage($object->error, 'errors'); - } - } -} - -// Go back to draft status (unvalidate) -else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)) { - $idwarehouse = GETPOST('idwarehouse'); - - $object->fetch($id); - $object->fetch_thirdparty(); - - $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); - } - - // Check parameters - if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == - 1) { - $error ++; - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors'); - $action = ''; - } - } - - if (! $error) { - // On verifie si la facture a des paiements - $sql = 'SELECT pf.amount'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf'; - $sql .= ' WHERE pf.fk_facture = ' . $object->id; - - $result = $db->query($sql); - if ($result) { - $i = 0; - $num = $db->num_rows($result); - - while ($i < $num) { - $objp = $db->fetch_object($result); - $totalpaye += $objp->amount; - $i ++; - } - } else { - dol_print_error($db, ''); - } - - $resteapayer = $object->total_ttc - $totalpaye; - - // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees - $ventilExportCompta = $object->getVentilExportCompta(); - - // On verifie si aucun paiement n'a ete effectue - if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) { - $result=$object->set_draft($user, $idwarehouse); - if ($result<0) setEventMessage($object->error,'errors'); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - } -} - -// Classify "paid" -else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) { - $object->fetch($id); - $result = $object->set_paid($user); - if ($result<0) setEventMessage($object->error,'errors'); -} // Classif "paid partialy" -else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) { - $object->fetch($id); - $close_code = $_POST["close_code"]; - $close_note = $_POST["close_note"]; - if ($close_code) { - $result = $object->set_paid($user, $close_code, $close_note); - if ($result<0) setEventMessage($object->error,'errors'); - } else { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors'); - } -} // Classify "abandoned" -else if ($action == 'confirm_canceled' && $confirm == 'yes') { - $object->fetch($id); - $close_code = $_POST["close_code"]; - $close_note = $_POST["close_note"]; - if ($close_code) { - $result = $object->set_canceled($user, $close_code, $close_note); - if ($result<0) setEventMessage($object->error,'errors'); - } else { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors'); - } -} - -// Convertir en reduc -else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer) -{ - $object->fetch($id); - $object->fetch_thirdparty(); - //$object->fetch_lines(); // Already done into fetch - - // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) - $discountcheck=new DiscountAbsolute($db); - $result=$discountcheck->fetch(0,$object->id); - - $canconvert=0; - if ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 1 && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed completely and not already converted (see real condition into condition used to show button converttoreduc) - if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) - if ($canconvert) - { - $db->begin(); - - // Boucle sur chaque taux de tva - $i = 0; - foreach ($object->lines as $line) { - $amount_ht [$line->tva_tx] += $line->total_ht; - $amount_tva [$line->tva_tx] += $line->total_tva; - $amount_ttc [$line->tva_tx] += $line->total_ttc; - $i ++; - } - - // Insert one discount by VAT rate category - $discount = new DiscountAbsolute($db); - if ($object->type == Facture::TYPE_CREDIT_NOTE) - $discount->description = '(CREDIT_NOTE)'; - elseif ($object->type == Facture::TYPE_DEPOSIT) - $discount->description = '(DEPOSIT)'; - else { - setEventMessage($langs->trans('CantConvertToReducAnInvoiceOfThisType'),'errors'); - } - $discount->tva_tx = abs($object->total_ttc); - $discount->fk_soc = $object->socid; - $discount->fk_facture_source = $object->id; - - $error = 0; - foreach ($amount_ht as $tva_tx => $xxx) { - $discount->amount_ht = abs($amount_ht [$tva_tx]); - $discount->amount_tva = abs($amount_tva [$tva_tx]); - $discount->amount_ttc = abs($amount_ttc [$tva_tx]); - $discount->tva_tx = abs($tva_tx); - - $result = $discount->create($user); - if ($result < 0) - { - $error++; - break; - } - } - - if (empty($error)) - { - // Classe facture - $result = $object->set_paid($user); - if ($result >= 0) - { - //$mesgs[]='OK'.$discount->id; - $db->commit(); - } - else - { - setEventMessage($object->error,'errors'); - $db->rollback(); - } - } - else - { - setEventMessage($discount->error,'errors'); - $db->rollback(); - } - } -} - -/* - * Insert new invoice in database -*/ -else if ($action == 'add' && $user->rights->facture->creer) -{ - if ($socid > 0) $object->socid = GETPOST('socid', 'int'); - - $db->begin(); - - $error = 0; - - // Fill array 'array_options' with data from add form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) $error ++; - - // Replacement invoice - if ($_POST['type'] == Facture::TYPE_REPLACEMENT) - { - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($dateinvoice)) - { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); - } - - if (! ($_POST['fac_replacement'] > 0)) { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), 'errors'); - } - - if (! $error) { - // This is a replacement invoice - $result = $object->fetch($_POST['fac_replacement']); - $object->fetch_thirdparty(); - - $object->date = $dateinvoice; - $object->note_public = trim($_POST['note_public']); - $object->note = trim($_POST['note']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = $_POST['cond_reglement_id']; - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; - - // Proprietes particulieres a facture de remplacement - $object->fk_facture_source = $_POST['fac_replacement']; - $object->type = Facture::TYPE_REPLACEMENT; - - $id = $object->createFromCurrent($user); - if ($id <= 0) - $mesgs [] = $object->error; - } - } - - // Credit note invoice - if ($_POST['type'] == Facture::TYPE_CREDIT_NOTE) - { - if (! ($_POST['fac_avoir'] > 0)) - { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), 'errors'); - } - - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($dateinvoice)) - { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->trans("Date")), 'errors'); - } - - if (! $error) - { - $object->socid = GETPOST('socid','int'); - $object->number = $_POST['facnumber']; - $object->date = $dateinvoice; - $object->note_public = trim($_POST['note_public']); - $object->note = trim($_POST['note']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = 0; - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; - - // Proprietes particulieres a facture avoir - $object->fk_facture_source = $_POST['fac_avoir']; - $object->type = Facture::TYPE_CREDIT_NOTE; - - $id = $object->create($user); - - if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) - { - $facture_source = new Facture($db); // fetch origin object - if ($facture_source->fetch($object->fk_facture_source)>0) - { - - foreach($facture_source->lines as $line) - { - $line->fk_facture = $object->id; - - $line->subprice =-$line->subprice; // invert price for object - $line->pa_ht = -$line->pa_ht; - $line->total_ht=-$line->total_ht; - $line->total_tva=-$line->total_tva; - $line->total_ttc=-$line->total_ttc; - $line->total_localtax1=-$line->total_localtax1; - $line->total_localtax2=-$line->total_localtax2; - - $line->insert(); - - $object->lines[] = $line; // insert new line in current object - } - - $object->update_price(1); - } - - } - - if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) { - - $facture_source = new Facture($db); // fetch origin object if not previously defined - if($facture_source->fetch($object->fk_facture_source)>0) { - $totalpaye = $facture_source->getSommePaiement(); - $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); - $totaldeposits = $facture_source->getSumDepositsUsed(); - $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); - - $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC'); - } - } - - // Add predefined lines - /* - TODO delete - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { - $product = new Product($db); - $product->fetch($_POST['idprod' . $i]); - $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); - $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); - $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); - } - }*/ - } - } - - // Standard invoice or Deposit invoice created from a Predefined invoice - if (($_POST['type'] == 0 || $_POST['type'] == 3) && $_POST['fac_rec'] > 0) - { - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($dateinvoice)) - { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); - } - - if (! $error) - { - $object->socid = GETPOST('socid','int'); - $object->type = $_POST['type']; - $object->number = $_POST['facnumber']; - $object->date = $dateinvoice; - $object->note_public = trim($_POST['note_public']); - $object->note_private = trim($_POST['note_private']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - - // Source facture - $object->fac_rec = $_POST['fac_rec']; - - $id = $object->create($user); - } - } - - // Standard or deposit or proforma invoice - if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0) - { - if (GETPOST('socid', 'int') < 1) - { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); - } - - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($dateinvoice)) - { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); - } - - if (! $error) - { - // Si facture standard - $object->socid = GETPOST('socid','int'); - $object->type = GETPOST('type'); - $object->number = $_POST['facnumber']; - $object->date = $dateinvoice; - $object->note_public = trim($_POST['note_public']); - $object->note_private = trim($_POST['note_private']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->amount = $_POST['amount']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; - - $object->fetch_thirdparty(); - - // If creation from another object of another module (Example: origin=propal, originid=1) - if ($_POST['origin'] && $_POST['originid']) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = $_POST['origin']; - if (preg_match('/^([^_]+)_([^_]+)/i', $_POST['origin'], $regs)) { - $element = $regs [1]; - $subelement = $regs [2]; - } - - // For compatibility - if ($element == 'order') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - $element = 'comm/propal'; - $subelement = 'propal'; - } - if ($element == 'contract') { - $element = $subelement = 'contrat'; - } - if ($element == 'inter') { - $element = $subelement = 'ficheinter'; - } - if ($element == 'shipping') { - $element = $subelement = 'expedition'; - } - - $object->origin = $_POST['origin']; - $object->origin_id = $_POST['originid']; - - // Possibility to add external linked objects with hooks - $object->linked_objects [$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { - $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); - } - - $id = $object->create($user); - - if ($id > 0) - { - // If deposit invoice - if ($_POST['type'] == 3) - { - $typeamount = GETPOST('typedeposit', 'alpha'); - $valuedeposit = GETPOST('valuedeposit', 'int'); - - if ($typeamount == 'amount') - { - $amountdeposit = $valuedeposit; - } - else - { - $amountdeposit = 0; - - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - - $classname = ucfirst($subelement); - $srcobject = new $classname($db); - - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add deposit lines"); - $result = $srcobject->fetch($object->origin_id); - if ($result > 0) - { - $totalamount = 0; - $lines = $srcobject->lines; - $numlines=count($lines); - for ($i=0; $i<$numlines; $i++) - { - $qualified=1; - if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option - if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...) - if ($qualified) $totalamount += $lines[$i]->total_ht; - } - - if ($totalamount != 0) { - $amountdeposit = ($totalamount * $valuedeposit) / 100; - } - } else { - $mesgs [] = $srcobject->error; - $error ++; - } - } - - $result = $object->addline( - $langs->trans('Deposit'), - $amountdeposit, // subprice - 1, // quantity - $lines [$i]->tva_tx, 0, // localtax1_tx - 0, // localtax2_tx - 0, // fk_product - 0, // remise_percent - 0, // date_start - 0, // date_end - 0, $lines [$i]->info_bits, // info_bits - 0, // info_bits - 'HT', - 0, - 0, // product_type - 1, - $lines [$i]->special_code, - $object->origin, - 0, - 0, - 0, - 0, - $langs->trans('Deposit') - ); - } - else - { - - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - - $classname = ucfirst($subelement); - $srcobject = new $classname($db); - - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); - $result = $srcobject->fetch($object->origin_id); - if ($result > 0) - { - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { - $srcobject->fetch_lines(); - $lines = $srcobject->lines; - } - - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); - - if ($lines [$i]->subprice < 0) - { - // Negative line, we create a discount line - $discount = new DiscountAbsolute($db); - $discount->fk_soc = $object->socid; - $discount->amount_ht = abs($lines [$i]->total_ht); - $discount->amount_tva = abs($lines [$i]->total_tva); - $discount->amount_ttc = abs($lines [$i]->total_ttc); - $discount->tva_tx = $lines [$i]->tva_tx; - $discount->fk_user = $user->id; - $discount->description = $desc; - $discountid = $discount->create($user); - if ($discountid > 0) { - $result = $object->insert_discount($discountid); // This include link_to_invoice - } else { - $mesgs [] = $discount->error; - $error ++; - break; - } - } else { - // Positive line - $product_type = ($lines [$i]->product_type ? $lines [$i]->product_type : 0); - - // Date start - $date_start = false; - if ($lines [$i]->date_debut_prevue) - $date_start = $lines [$i]->date_debut_prevue; - if ($lines [$i]->date_debut_reel) - $date_start = $lines [$i]->date_debut_reel; - if ($lines [$i]->date_start) - $date_start = $lines [$i]->date_start; - - // Date end - $date_end = false; - if ($lines [$i]->date_fin_prevue) - $date_end = $lines [$i]->date_fin_prevue; - if ($lines [$i]->date_fin_reel) - $date_end = $lines [$i]->date_fin_reel; - if ($lines [$i]->date_end) - $date_end = $lines [$i]->date_end; - - // Reset fk_parent_line for no child products and special product - if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) { - $lines [$i]->fetch_optionals($lines [$i]->rowid); - $array_option = $lines [$i]->array_options; - } - - $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $date_start, $date_end, 0, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $object->origin, $lines [$i]->rowid, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); - - if ($result > 0) { - $lineid = $result; - } else { - $lineid = 0; - $error ++; - break; - } - - // Defined the new fk_parent_line - if ($result > 0 && $lines [$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - } - - // Hooks - $parameters = array('objFrom' => $srcobject); - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if ($reshook < 0) - $error ++; - } else { - $mesgs [] = $srcobject->error; - $error ++; - } - } - } else { - $mesgs [] = $object->error; - $error ++; - } - } // If some invoice's lines already known - else { - $id = $object->create($user); - - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { - $product = new Product($db); - $product->fetch($_POST['idprod' . $i]); - $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); - $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); - $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); - } - } - } - } - } - - // End of object creation, we show it - if ($id > 0 && ! $error) - { - $db->commit(); - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '#' . $_GET ['rowid']); exit(); } - else - { - $db->rollback(); - $action = 'create'; - $_GET ["origin"] = $_POST["origin"]; - $_GET ["originid"] = $_POST["originid"]; - $mesgs [] = '
' . $object->error . '
'; - } -} -// Add a new line -else if ($action == 'addline' && $user->rights->facture->creer) -{ - $langs->load('errors'); - $error = 0; - - // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - if (GETPOST('prod_entry_mode') == 'free') - { - $idprod=0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { - $idprod=GETPOST('idprod', 'int'); - $tva_tx = ''; + // Link invoice to order + if (GETPOST('linkedOrder')) { + $object->fetch($id); + $object->fetch_thirdparty(); + $result = $object->add_object_linked('commande', GETPOST('linkedOrder')); } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key . $predef]); - } - } - - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { - setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' - { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; - } - if ($qty == '') { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error ++; - } - - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - $ret = $object->fetch($id); - if ($ret < 0) { - dol_print_error($db, $object->error); - exit(); - } - $ret = $object->fetch_thirdparty(); - - // Clean parameters - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); - $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); - - // Define special_code for special lines - $special_code = 0; - // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - // Ecrase $base_price_type par celui du produit - if (! empty($idprod)) { - $prod = new Product($db); - $prod->fetch($idprod); - - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - - // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); - - // We define price for product - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - { - $pu_ht = $prod->multiprices[$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; - $price_min = $prod->multiprices_min[$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) { - if (count($prodcustprice->lines) > 0) { - $found = true; - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; - }else { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - } else { - setEventMessage($prodcustprice->error,'errors'); - } - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - - // if price ht is forced (ie: calculated by margin rate and cost price) - if (! empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tva_tx != $prod->tva_tx) { - if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); - } else { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - } - - $desc = ''; - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } - - $desc = dol_concatdesc($desc, $product_desc); - - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } - - $type = $prod->type; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); - } - - // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->client); - $localtax2_tx = get_localtax($tva_tx, 2, $object->client); - - $info_bits = 0; - if ($tva_npr) - $info_bits |= 0x01; - - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); - } else { - // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); - - if ($result > 0) { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - $newlang = GETPOST('lang_id', 'alpha'); - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $ret = $object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST ['prod_entry_mode']); - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - unset($_POST['np_marginRate']); - unset($_POST['np_markRate']); - unset($_POST['dp_desc']); - unset($_POST['idprod']); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); - } else { - setEventMessage($object->error, 'errors'); - } - - $action = ''; - } - } -} - -elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel')) { - if (! $object->fetch($id) > 0) - dol_print_error($db); - $object->fetch_thirdparty(); - - // Clean parameters - $date_start = ''; - $date_end = ''; - $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description = dol_htmlcleanlastbr(GETPOST('product_desc')); - $pu_ht = GETPOST('price_ht'); - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) - $info_bits |= 0x01; - - // Define vat_rate - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $object->client); - $localtax2_rate = get_localtax($vat_rate, 2, $object->client); - - // Add buying price - $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') ? GETPOST('buying_price') : ''); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); - } - } - - // Check minimum price - $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { - $product = new Product($db); - $product->fetch($productid); - - $type = $product->type; - - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - $price_min = $product->multiprices_min [$object->client->price_level]; - - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - - // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); - $error ++; - } - } else { - $type = GETPOST('type'); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - - // Check parameters - if (GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; - } - } - - // Update line - if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); - - if ($result >= 0) { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $ret = $object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['productid']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - } else { - setEventMessage($object->error, 'errors'); - } - } -} - -else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition - exit(); -} - -// Modify line position (up) -else if ($action == 'up' && $user->rights->facture->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); - $object->line_up($_GET ['rowid']); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '#' . $_GET ['rowid']); - exit(); -} // Modify line position (down) -else if ($action == 'down' && $user->rights->facture->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); - $object->line_down($_GET ['rowid']); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '#' . $_GET ['rowid']); - exit(); -} - -// Link invoice to order -if (GETPOST('linkedOrder')) { - $object->fetch($id); - $object->fetch_thirdparty(); - $result = $object->add_object_linked('commande', GETPOST('linkedOrder')); -} - -/* - * Add file in email form - */ -if (GETPOST('addfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; - - dol_add_file_process($upload_dir_tmp, 0, 0); - $action = 'presend'; -} - -/* - * Remove file in email form - */ -if (! empty($_POST['removedfile'])) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process($_POST['removedfile'], 0); - $action = 'presend'; -} - -/* - * Send mail - */ -if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) { - $langs->load('mails'); - - $actiontypecode = ''; - $subject = ''; - $actionmsg = ''; - $actionmsg2 = ''; - - $result = $object->fetch($id); - $result = $object->fetch_thirdparty(); - - if ($result > 0) { - // $ref = dol_sanitizeFileName($object->ref); - // $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - - // if (is_readable($file)) - // { - if ($_POST['sendto']) { - // Le destinataire a ete fourni via le champ libre - $sendto = $_POST['sendto']; - $sendtoid = 0; - } elseif ($_POST['receiver'] != '-1') { - // Recipient was provided from combo list - if ($_POST['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } else // Id du contact - { - $sendto = $object->client->contact_get_property($_POST['receiver'], 'email'); - $sendtoid = $_POST['receiver']; - } - } - - if (dol_strlen($sendto)) { - $langs->load("commercial"); - - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] . '>'; - $replyto = $_POST['replytoname'] . ' <' . $_POST['replytomail'] . '>'; - $message = $_POST['message']; - $sendtocc = $_POST['sendtocc']; - $deliveryreceipt = $_POST['deliveryreceipt']; - - if ($action == 'send') { - if (dol_strlen($_POST['subject'])) - $subject = $_POST['subject']; - else - $subject = $langs->transnoentities('Bill') . ' ' . $object->ref; - $actiontypecode = 'AC_FAC'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; - if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; - } - // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } - if ($action == 'relance') { - if (dol_strlen($_POST['subject'])) - $subject = $_POST['subject']; - else - $subject = $langs->transnoentities('Relance facture ' . $object->ref); - $actiontypecode = 'AC_FAC'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; - if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; - } - // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } - - // Create form object - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles ['paths']; - $filename = $attachedfiles ['names']; - $mimetype = $attachedfiles ['mimes']; - - // Send mail - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); - if ($mailfile->error) { - $mesgs [] = '
' . $mailfile->error . '
'; - } else { - $result = $mailfile->sendfile(); - if ($result) { - $error = 0; - - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; // Long text - $object->actionmsg2 = $actionmsg2; // Short text - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface = new Interfaces($db); - $result = $interface->run_triggers('BILL_SENTBYMAIL', $object, $user, $langs, $conf); - if ($result < 0) { - $error++; - $object->errors = $interface->errors; - } - // Fin appel triggers - - if ($error) { - dol_print_error($db); - } else { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); - setEventMessage($mesg); - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id); - exit(); - } - } else { - $langs->load("other"); - $mesg = '
'; - if ($mailfile->error) { - $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); - $mesg .= '
' . $mailfile->error; - } else { - $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - $mesg .= '
'; - $mesgs [] = $mesg; - } - } - /* } - else - { - $langs->load("other"); - $mesgs[]='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; - dol_syslog('Recipient email is empty'); - }*/ - } else { - $langs->load("errors"); - $mesgs [] = '
' . $langs->trans('ErrorCantReadFile', $file) . '
'; - dol_syslog('Failed to read file: ' . $file); - } - } else { - $langs->load("other"); - $mesgs [] = '
' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Invoice")) . '
'; - dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.'); - } - - $action = 'presend'; -} - -/* - * Generate document - */ -else if ($action == 'builddoc') // En get ou en post -{ - $object->fetch($id); - $object->fetch_thirdparty(); - - // Save last template used to generate document - if (GETPOST('model')) - $object->setDocModel($user, GETPOST('model', 'alpha')); - if (GETPOST('fk_bank')) // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank'); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - dol_print_error($db, $result); - exit(); - } -} - -// Remove file in doc form -else if ($action == 'remove_file') { - if ($object->fetch($id)) { + /* + * Add file in email form + */ + if (GETPOST('addfile')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + // Set tmp user directory + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; + + dol_add_file_process($upload_dir_tmp, 0, 0); + $action = 'presend'; + } + + /* + * Remove file in email form + */ + if (! empty($_POST['removedfile'])) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + // Set tmp user directory + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; + + // TODO Delete only files that was uploaded from email form + dol_remove_file_process($_POST['removedfile'], 0); + $action = 'presend'; + } + + /* + * Send mail + */ + if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) { + $langs->load('mails'); + + $actiontypecode = ''; + $subject = ''; + $actionmsg = ''; + $actionmsg2 = ''; + + $result = $object->fetch($id); + $result = $object->fetch_thirdparty(); + + if ($result > 0) { + // $ref = dol_sanitizeFileName($object->ref); + // $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; + + // if (is_readable($file)) + // { + if ($_POST['sendto']) { + // Le destinataire a ete fourni via le champ libre + $sendto = $_POST['sendto']; + $sendtoid = 0; + } elseif ($_POST['receiver'] != '-1') { + // Recipient was provided from combo list + if ($_POST['receiver'] == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } else // Id du contact + { + $sendto = $object->client->contact_get_property($_POST['receiver'], 'email'); + $sendtoid = $_POST['receiver']; + } + } + + if (dol_strlen($sendto)) { + $langs->load("commercial"); + + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] . '>'; + $replyto = $_POST['replytoname'] . ' <' . $_POST['replytomail'] . '>'; + $message = $_POST['message']; + $sendtocc = $_POST['sendtocc']; + $deliveryreceipt = $_POST['deliveryreceipt']; + + if ($action == 'send') { + if (dol_strlen($_POST['subject'])) + $subject = $_POST['subject']; + else + $subject = $langs->transnoentities('Bill') . ' ' . $object->ref; + $actiontypecode = 'AC_FAC'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + if ($message) { + $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; + $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; + $actionmsg .= $message; + } + // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } + if ($action == 'relance') { + if (dol_strlen($_POST['subject'])) + $subject = $_POST['subject']; + else + $subject = $langs->transnoentities('Relance facture ' . $object->ref); + $actiontypecode = 'AC_FAC'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + if ($message) { + $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; + $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; + $actionmsg .= $message; + } + // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } + + // Create form object + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles = $formmail->get_attached_files(); + $filepath = $attachedfiles ['paths']; + $filename = $attachedfiles ['names']; + $mimetype = $attachedfiles ['mimes']; + + // Send mail + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); + if ($mailfile->error) { + $mesgs [] = '
' . $mailfile->error . '
'; + } else { + $result = $mailfile->sendfile(); + if ($result) { + $error = 0; + + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; // Long text + $object->actionmsg2 = $actionmsg2; // Short text + $object->fk_element = $object->id; + $object->elementtype = $object->element; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface = new Interfaces($db); + $result = $interface->run_triggers('BILL_SENTBYMAIL', $object, $user, $langs, $conf); + if ($result < 0) { + $error++; + $object->errors = $interface->errors; + } + // Fin appel triggers + + if ($error) { + dol_print_error($db); + } else { + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); + setEventMessage($mesg); + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id); + exit(); + } + } else { + $langs->load("other"); + $mesg = '
'; + if ($mailfile->error) { + $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); + $mesg .= '
' . $mailfile->error; + } else { + $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg .= '
'; + $mesgs [] = $mesg; + } + } + /* } + else + { + $langs->load("other"); + $mesgs[]='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; + dol_syslog('Recipient email is empty'); + }*/ + } else { + $langs->load("errors"); + $mesgs [] = '
' . $langs->trans('ErrorCantReadFile', $file) . '
'; + dol_syslog('Failed to read file: ' . $file); + } + } else { + $langs->load("other"); + $mesgs [] = '
' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Invoice")) . '
'; + dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.'); + } + + $action = 'presend'; + } + + /* + * Generate document + */ + else if ($action == 'builddoc') // En get ou en post + { + $object->fetch($id); $object->fetch_thirdparty(); - $langs->load("other"); - $upload_dir = $conf->facture->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + // Save last template used to generate document + if (GETPOST('model')) + $object->setDocModel($user, GETPOST('model', 'alpha')); + if (GETPOST('fk_bank')) // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank'); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + dol_print_error($db, $result); + exit(); + } + } + + // Remove file in doc form + else if ($action == 'remove_file') { + if ($object->fetch($id)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $object->fetch_thirdparty(); + + $langs->load("other"); + $upload_dir = $conf->facture->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) + setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else + setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + $action = ''; + } + } + + // Print file + else if ($action == 'print_file' and $user->rights->printipp->read) { + require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; + $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); + $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); + setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); $action = ''; } -} -// Print file -else if ($action == 'print_file' and $user->rights->printipp->read) { - require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; - $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); - $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); - setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); - $action = ''; -} + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) { + if ($action == 'addcontact') { + $result = $object->fetch($id); -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) { - if ($action == 'addcontact') { - $result = $object->fetch($id); + if ($result > 0 && $id > 0) { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } - if ($result > 0 && $id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - $mesgs [] = '
' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '
'; + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); } else { - $mesgs [] = '
' . $object->error . '
'; + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + $mesgs [] = '
' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '
'; + } else { + $mesgs [] = '
' . $object->error . '
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut') { + if ($object->fetch($id)) { + $result = $object->swapContactStatus(GETPOST('ligne')); + } else { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact') { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + dol_print_error($db); } } } - // bascule du statut d'un contact - else if ($action == 'swapstatut') { - if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); - } else { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact') { - $object->fetch($id); - $result = $object->delete_contact($lineid); - - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - dol_print_error($db); - } - } -} - -if ($action == 'update_extras') { - // Fill array 'array_options' with data from add form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) - $error ++; - - if (! $error) { - // Actions on extra fields (by external module or standard code) - // FIXME le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('invoicedao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) + if ($action == 'update_extras') { + // Fill array 'array_options' with data from add form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) $error ++; - } - if ($error) - $action = 'edit_extras'; + if (! $error) { + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('invoicedao')); + $parameters = array('id' => $object->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by + // some hooks + if (empty($reshook)) { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } else if ($reshook < 0) + $error ++; + } + + if ($error) + $action = 'edit_extras'; + } } diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 3aafa1c165b..c96ddaa4b9f 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -71,182 +71,184 @@ $hookmanager->initHooks(array('paiementcard')); $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -/* - * Actions - */ -if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) -{ - $error = 0; +if (empty($reshook)) { - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $paiement_id = 0; - $totalpayment = 0; - $atleastonepaymentnotnull = 0; - - // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); - foreach ($_POST as $key => $value) + /* + * Actions + */ + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) { - if (substr($key,0,7) == 'amount_') + $error = 0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $paiement_id = 0; + $totalpayment = 0; + $atleastonepaymentnotnull = 0; + + // Generate payment array and check if there is payment higher than invoice and payment date before invoice date + $tmpinvoice=new Facture($db); + foreach ($_POST as $key => $value) { - $cursorfacid = substr($key,7); - $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); - $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); - if ($amounts[$cursorfacid]) + if (substr($key,0,7) == 'amount_') { - // Check amount - if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) - { - $addwarning=1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { - $langs->load("errors"); - //$error++; - setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings'); - } - } + $cursorfacid = substr($key,7); + $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); + $totalpayment = $totalpayment + $amounts[$cursorfacid]; + if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result=$tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + if ($amounts[$cursorfacid]) + { + // Check amount + if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) + { + $addwarning=1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings'); + } + } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); - } - } - - // Check parameters - if (! GETPOST('paiementcode')) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors'); - $error++; - } - - if (! empty($conf->banque->enabled)) - { - // If bank module is on, account is required to enter a payment - if (GETPOST('accountid') <= 0) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); - $error++; - } - } - - if (empty($totalpayment) && empty($atleastonepaymentnotnull)) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors'); - $error++; - } - - if (empty($datepaye)) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors'); - $error++; - } -} - -/* - * Action add_paiement - */ -if ($action == 'add_paiement') -{ - if ($error) - { - $action = 'create'; - } - // Le reste propre a cette action s'affiche en bas de page. -} - -/* - * Action confirm_paiement - */ -if ($action == 'confirm_paiement' && $confirm == 'yes') -{ - $error=0; - - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - - $db->begin(); - - // Clean parameters amount if payment is for a credit note - if (GETPOST('type') == 2) - { - foreach ($amounts as $key => $value) // How payment is dispatch - { - $newvalue = price2num($value,'MT'); - $amounts[$key] = -$newvalue; - } - } - - if (! empty($conf->banque->enabled)) - { - // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement - if (GETPOST('accountid') <= 0) - { - setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); - $error++; - } - } - - // Creation of payment line - $paiement = new Paiement($db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db,$_POST['paiementcode'],'c_paiement'); - $paiement->num_paiement = $_POST['num_paiement']; - $paiement->note = $_POST['comment']; - - if (! $error) - { - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); - if ($paiement_id < 0) - { - setEventMessage($paiement->error, 'errors'); - $error++; - } - } - - if (! $error) - { - $label='(CustomerInvoicePayment)'; - if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; - $result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),GETPOST('chqemetteur'),GETPOST('chqbank')); - if ($result < 0) - { - setEventMessage($paiement->error, 'errors'); - $error++; - } - } - - if (! $error) - { - $db->commit(); - - // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card - $invoiceid=0; - foreach ($paiement->amounts as $key => $amount) - { - $facid = $key; - if (is_numeric($amount) && $amount <> 0) - { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); } } - if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$paiement_id; - header('Location: '.$loc); - exit; + + // Check parameters + if (! GETPOST('paiementcode')) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors'); + $error++; + } + + if (! empty($conf->banque->enabled)) + { + // If bank module is on, account is required to enter a payment + if (GETPOST('accountid') <= 0) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); + $error++; + } + } + + if (empty($totalpayment) && empty($atleastonepaymentnotnull)) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors'); + $error++; + } + + if (empty($datepaye)) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors'); + $error++; + } } - else + + /* + * Action add_paiement + */ + if ($action == 'add_paiement') { - $db->rollback(); + if ($error) + { + $action = 'create'; + } + // Le reste propre a cette action s'affiche en bas de page. + } + + /* + * Action confirm_paiement + */ + if ($action == 'confirm_paiement' && $confirm == 'yes') + { + $error=0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + + $db->begin(); + + // Clean parameters amount if payment is for a credit note + if (GETPOST('type') == 2) + { + foreach ($amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $amounts[$key] = -$newvalue; + } + } + + if (! empty($conf->banque->enabled)) + { + // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement + if (GETPOST('accountid') <= 0) + { + setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); + $error++; + } + } + + // Creation of payment line + $paiement = new Paiement($db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array with all payments dispatching + $paiement->paiementid = dol_getIdFromCode($db,$_POST['paiementcode'],'c_paiement'); + $paiement->num_paiement = $_POST['num_paiement']; + $paiement->note = $_POST['comment']; + + if (! $error) + { + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); + if ($paiement_id < 0) + { + setEventMessage($paiement->error, 'errors'); + $error++; + } + } + + if (! $error) + { + $label='(CustomerInvoicePayment)'; + if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; + $result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),GETPOST('chqemetteur'),GETPOST('chqbank')); + if ($result < 0) + { + setEventMessage($paiement->error, 'errors'); + $error++; + } + } + + if (! $error) + { + $db->commit(); + + // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card + $invoiceid=0; + foreach ($paiement->amounts as $key => $amount) + { + $facid = $key; + if (is_numeric($amount) && $amount <> 0) + { + if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment + else $invoiceid=$facid; + } + } + if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture.php?facid='.$invoiceid; + else $loc = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$paiement_id; + header('Location: '.$loc); + exit; + } + else + { + $db->rollback(); + } } } - /* * View */ diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index c11c1d549a9..7dd671d109f 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -89,473 +89,475 @@ $hookmanager->initHooks(array('expeditioncard')); $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($action == 'add') -{ - $error=0; +if (empty($reshook)) { - $db->begin(); - - $object->note = GETPOST('note','alpha'); - $object->origin = $origin; - $object->origin_id = $origin_id; - $object->weight = GETPOST('weight','int')==''?"NULL":GETPOST('weight','int'); - $object->sizeH = GETPOST('sizeH','int')==''?"NULL":GETPOST('sizeH','int'); - $object->sizeW = GETPOST('sizeW','int')==''?"NULL":GETPOST('sizeW','int'); - $object->sizeS = GETPOST('sizeS','int')==''?"NULL":GETPOST('sizeS','int'); - $object->size_units = GETPOST('size_units','int'); - $object->weight_units = GETPOST('weight_units','int'); - - $date_delivery = dol_mktime(GETPOST('date_deliveryhour','int'), GETPOST('date_deliverymin','int'), 0, GETPOST('date_deliverymonth','int'), GETPOST('date_deliveryday','int'), GETPOST('date_deliveryyear','int')); - - // On va boucler sur chaque ligne du document d'origine pour completer objet expedition - // avec info diverses + qte a livrer - $classname = ucfirst($object->origin); - $objectsrc = new $classname($db); - $objectsrc->fetch($object->origin_id); - - $object->socid = $objectsrc->socid; - $object->ref_customer = $objectsrc->ref_client; - $object->date_delivery = $date_delivery; // Date delivery planed - $object->fk_delivery_address = $objectsrc->fk_delivery_address; - $object->shipping_method_id = GETPOST('shipping_method_id','int'); - $object->tracking_number = GETPOST('tracking_number','alpha'); - $object->ref_int = GETPOST('ref_int','alpha'); - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); - - $num=count($objectsrc->lines); - $totalqty=0; - for ($i = 0; $i < $num; $i++) + if ($action == 'add') { - $qty = "qtyl".$i; - $j=0; - $sub_qty=array(); - $subtotalqty=0; - $idl="idl".$i; - $batch="batchl".$i."_0"; - if (isset($_POST[$batch])) { - //shipment line with batch-enable product - $qty .= '_'.$j; - while (isset($_POST[$batch])) { - $sub_qty[$j]['q']=GETPOST($qty,'int'); - $sub_qty[$j]['id_batch']=GETPOST($batch,'int'); - $subtotalqty+=$sub_qty[$j]['q']; - $j++; - $batch="batchl".$i."_".$j; - $qty = "qtyl".$i.'_'.$j; + $error=0; - } - $batch_line[$i]['detail']=$sub_qty; - $batch_line[$i]['qty']=$subtotalqty; - $batch_line[$i]['ix_l']=GETPOST($idl,'int'); - $totalqty+=$subtotalqty; - } else { - //Standard product - if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); - } - } + $db->begin(); - if ($totalqty > 0) - { - //var_dump($_POST);exit; + $object->note = GETPOST('note','alpha'); + $object->origin = $origin; + $object->origin_id = $origin_id; + $object->weight = GETPOST('weight','int')==''?"NULL":GETPOST('weight','int'); + $object->sizeH = GETPOST('sizeH','int')==''?"NULL":GETPOST('sizeH','int'); + $object->sizeW = GETPOST('sizeW','int')==''?"NULL":GETPOST('sizeW','int'); + $object->sizeS = GETPOST('sizeS','int')==''?"NULL":GETPOST('sizeS','int'); + $object->size_units = GETPOST('size_units','int'); + $object->weight_units = GETPOST('weight_units','int'); + + $date_delivery = dol_mktime(GETPOST('date_deliveryhour','int'), GETPOST('date_deliverymin','int'), 0, GETPOST('date_deliverymonth','int'), GETPOST('date_deliveryday','int'), GETPOST('date_deliveryyear','int')); + + // On va boucler sur chaque ligne du document d'origine pour completer objet expedition + // avec info diverses + qte a livrer + $classname = ucfirst($object->origin); + $objectsrc = new $classname($db); + $objectsrc->fetch($object->origin_id); + + $object->socid = $objectsrc->socid; + $object->ref_customer = $objectsrc->ref_client; + $object->date_delivery = $date_delivery; // Date delivery planed + $object->fk_delivery_address = $objectsrc->fk_delivery_address; + $object->shipping_method_id = GETPOST('shipping_method_id','int'); + $object->tracking_number = GETPOST('tracking_number','alpha'); + $object->ref_int = GETPOST('ref_int','alpha'); + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); + + $num=count($objectsrc->lines); + $totalqty=0; for ($i = 0; $i < $num; $i++) { $qty = "qtyl".$i; - if (! isset($batch_line[$i])) { - if (GETPOST($qty,'int') > 0) - { - $ent = "entl".$i; - $idl = "idl".$i; - $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); - if ($entrepot_id < 0) $entrepot_id=''; + $j=0; + $sub_qty=array(); + $subtotalqty=0; + $idl="idl".$i; + $batch="batchl".$i."_0"; + if (isset($_POST[$batch])) { + //shipment line with batch-enable product + $qty .= '_'.$j; + while (isset($_POST[$batch])) { + $sub_qty[$j]['q']=GETPOST($qty,'int'); + $sub_qty[$j]['id_batch']=GETPOST($batch,'int'); + $subtotalqty+=$sub_qty[$j]['q']; + $j++; + $batch="batchl".$i."_".$j; + $qty = "qtyl".$i.'_'.$j; - $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); - if ($ret < 0) - { - $mesg='
'.$object->error.'
'; - $error++; - } - } - } else { - if ($batch_line[$i]['qty']>0) { - $ret=$object->addline_batch($batch_line[$i]); - if ($ret < 0) - { - $mesg='
'.$object->error.'
'; - $error++; - } - } - } + } + $batch_line[$i]['detail']=$sub_qty; + $batch_line[$i]['qty']=$subtotalqty; + $batch_line[$i]['ix_l']=GETPOST($idl,'int'); + $totalqty+=$subtotalqty; + } else { + //Standard product + if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); + } + } + + if ($totalqty > 0) + { + //var_dump($_POST);exit; + for ($i = 0; $i < $num; $i++) + { + $qty = "qtyl".$i; + if (! isset($batch_line[$i])) { + if (GETPOST($qty,'int') > 0) + { + $ent = "entl".$i; + $idl = "idl".$i; + $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); + if ($entrepot_id < 0) $entrepot_id=''; + + $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); + if ($ret < 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } else { + if ($batch_line[$i]['qty']>0) { + $ret=$object->addline_batch($batch_line[$i]); + if ($ret < 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } + } + + if (! $error) + { + $ret=$object->create($user); + if ($ret <= 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } + else + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Qty")).'
'; + $error++; } if (! $error) { - $ret=$object->create($user); - if ($ret <= 0) - { - $mesg='
'.$object->error.'
'; - $error++; - } - } - } - else - { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Qty")).'
'; - $error++; - } - - if (! $error) - { - $db->commit(); - header("Location: fiche.php?id=".$object->id); - exit; - } - else - { - $db->rollback(); - $_GET["commande_id"]=GETPOST('commande_id','int'); - $action='create'; - } -} - -/* - * Build a receiving receipt - */ -else if ($action == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) -{ - $result = $object->create_delivery($user); - if ($result > 0) - { - header("Location: ".DOL_URL_ROOT.'/livraison/fiche.php?id='.$result); - exit; - } - else - { - $mesg=$object->error; - } -} - -else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->valider) -{ - $object->fetch_thirdparty(); - - $result = $object->valid($user); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($id); // Reload to get new records - $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); - } - if ($result < 0) - { - dol_print_error($db,$result); - exit; - } -} - -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer) -{ - $result = $object->delete(); - if ($result > 0) - { - header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); - exit; - } - else - { - $langs->load("errors"); - setEventMessage($langs->trans($object->error),'errors'); - } -} - -else if ($action == 'reopen' && $user->rights->expedition->valider) -{ - $result = $object->setStatut(0); - if ($result < 0) - { - $mesg = $object->error; - } -} - -else if ($action == 'setdate_livraison' && $user->rights->expedition->creer) -{ - //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datedelivery=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'), GETPOST('liv_year','int')); - - $object->fetch($id); - $result=$object->set_date_livraison($user,$datedelivery); - if ($result < 0) - { - $mesg='
'.$object->error.'
'; - } -} - -// Action update description of emailing -else if ($action == 'settrackingnumber' || $action == 'settrackingurl' -|| $action == 'settrueWeight' -|| $action == 'settrueWidth' -|| $action == 'settrueHeight' -|| $action == 'settrueDepth' -|| $action == 'setshipping_method_id') -{ - $error=0; - - if ($action == 'settrackingnumber') $object->tracking_number = trim(GETPOST('trackingnumber','alpha')); - if ($action == 'settrackingurl') $object->tracking_url = trim(GETPOST('trackingurl','int')); - if ($action == 'settrueWeight') { - $object->trueWeight = trim(GETPOST('trueWeight','int')); - $object->weight_units = GETPOST('weight_units','int'); - } - if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth','int')); - if ($action == 'settrueHeight'){ - $object->trueHeight = trim(GETPOST('trueHeight','int')); - $object->size_units = GETPOST('size_units','int'); - } - if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth','int')); - if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id','int')); - - if (! $error) - { - if ($object->update($user) >= 0) - { + $db->commit(); header("Location: fiche.php?id=".$object->id); exit; } - setEventMessage($object->error,'errors'); + else + { + $db->rollback(); + $_GET["commande_id"]=GETPOST('commande_id','int'); + $action='create'; + } } - $action=""; -} - -// Build document -else if ($action == 'builddoc') // En get ou en post -{ - - // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->client->default_lang; - if (! empty($newlang)) + /* + * Build a receiving receipt + */ + else if ($action == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + $result = $object->create_delivery($user); + if ($result > 0) + { + header("Location: ".DOL_URL_ROOT.'/livraison/fiche.php?id='.$result); + exit; + } + else + { + $mesg=$object->error; + } } - $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); - if ($result <= 0) + + else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->valider) { - dol_print_error($db,$result); - exit; + $object->fetch_thirdparty(); + + $result = $object->valid($user); + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $ret=$object->fetch($id); // Reload to get new records + $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); + } + if ($result < 0) + { + dol_print_error($db,$result); + exit; + } } -} -// Delete file in doc form -elseif ($action == 'remove_file') -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $upload_dir = $conf->expedition->dir_output . "/sending"; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); -} - -/* - * Add file in email form -*/ -if (GETPOST('addfile','alpha')) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - dol_add_file_process($upload_dir_tmp,0,0); - $action ='presend'; -} - -/* - * Remove file in email form -*/ -if (GETPOST('removedfile','alpha')) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process(GETPOST('removedfile','int'),0); - $action ='presend'; -} - -/* - * Send mail -*/ -if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile','alpha') && ! GETPOST('cancel','alpha')) -{ - $langs->load('mails'); - -// $ref = dol_sanitizeFileName($object->ref); -// $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; - -// if (is_readable($file)) -// { - if (GETPOST('sendto','alpha')) - { - // Le destinataire a ete fourni via le champ libre - $sendto = GETPOST('sendto','alpha'); - $sendtoid = 0; - } - elseif (GETPOST('receiver','alpha') != '-1') - { - // Recipient was provided from combo list - if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $object->client->contact_get_property(GETPOST('receiver','alpha'),'email'); - $sendtoid = GETPOST('receiver','alpha'); - } - } - - if (dol_strlen($sendto)) - { - $langs->load("commercial"); - - $from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>'; - $replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>'; - $message = GETPOST('message'); - $sendtocc = GETPOST('sendtocc','alpha'); - $deliveryreceipt = GETPOST('deliveryreceipt','alpha'); - - if ($action == 'send') - { - if (dol_strlen(GETPOST('subject','alpha'))) $subject=GETPOST('subject','alpha'); - else $subject = $langs->transnoentities('Shipping').' '.$object->ref; - $actiontypecode='AC_SHIP'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; - if ($message) - { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; - } - $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } - - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $attachedfiles=$formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - // Send mail - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); - if ($mailfile->error) - { - $mesg='
'.$mailfile->error.'
'; - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - $error=0; - - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2 = $actionmsg2; - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('SHIPPING_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $object->errors=$interface->errors; - } - // Fin appel triggers - - if ($error) - { - dol_print_error($db); - } - else - { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); - setEventMessage($mesg); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } - else - { - $langs->load("other"); - $mesg='
'; - if ($mailfile->error) - { - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $mesg.='
'.$mailfile->error; - } - else - { - $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - $mesg.='
'; - } - } - } - else - { - $langs->load("other"); - $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; - $action='presend'; - dol_syslog('Recipient email is empty'); - } -/* } + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer) + { + $result = $object->delete(); + if ($result > 0) + { + header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); + exit; + } else { $langs->load("errors"); - $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; - dol_syslog('Failed to read file: '.$file); - }*/ -} + setEventMessage($langs->trans($object->error),'errors'); + } + } -else if ($action == 'classifybilled') -{ - $object->fetch($id); - $object->set_billed(); -} + else if ($action == 'reopen' && $user->rights->expedition->valider) + { + $result = $object->setStatut(0); + if ($result < 0) + { + $mesg = $object->error; + } + } + else if ($action == 'setdate_livraison' && $user->rights->expedition->creer) + { + //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datedelivery=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'), GETPOST('liv_year','int')); + + $object->fetch($id); + $result=$object->set_date_livraison($user,$datedelivery); + if ($result < 0) + { + $mesg='
'.$object->error.'
'; + } + } + + // Action update description of emailing + else if ($action == 'settrackingnumber' || $action == 'settrackingurl' + || $action == 'settrueWeight' + || $action == 'settrueWidth' + || $action == 'settrueHeight' + || $action == 'settrueDepth' + || $action == 'setshipping_method_id') + { + $error=0; + + if ($action == 'settrackingnumber') $object->tracking_number = trim(GETPOST('trackingnumber','alpha')); + if ($action == 'settrackingurl') $object->tracking_url = trim(GETPOST('trackingurl','int')); + if ($action == 'settrueWeight') { + $object->trueWeight = trim(GETPOST('trueWeight','int')); + $object->weight_units = GETPOST('weight_units','int'); + } + if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth','int')); + if ($action == 'settrueHeight'){ + $object->trueHeight = trim(GETPOST('trueHeight','int')); + $object->size_units = GETPOST('size_units','int'); + } + if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth','int')); + if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id','int')); + + if (! $error) + { + if ($object->update($user) >= 0) + { + header("Location: fiche.php?id=".$object->id); + exit; + } + setEventMessage($object->error,'errors'); + } + + $action=""; + } + + // Build document + else if ($action == 'builddoc') // En get ou en post + { + + // Save last template used to generate document + if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + } + + // Delete file in doc form + elseif ($action == 'remove_file') + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $upload_dir = $conf->expedition->dir_output . "/sending"; + $file = $upload_dir . '/' . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + } + + /* + * Add file in email form + */ + if (GETPOST('addfile','alpha')) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + dol_add_file_process($upload_dir_tmp,0,0); + $action ='presend'; + } + + /* + * Remove file in email form + */ + if (GETPOST('removedfile','alpha')) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + // TODO Delete only files that was uploaded from email form + dol_remove_file_process(GETPOST('removedfile','int'),0); + $action ='presend'; + } + + /* + * Send mail + */ + if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile','alpha') && ! GETPOST('cancel','alpha')) + { + $langs->load('mails'); + + // $ref = dol_sanitizeFileName($object->ref); + // $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; + + // if (is_readable($file)) + // { + if (GETPOST('sendto','alpha')) + { + // Le destinataire a ete fourni via le champ libre + $sendto = GETPOST('sendto','alpha'); + $sendtoid = 0; + } + elseif (GETPOST('receiver','alpha') != '-1') + { + // Recipient was provided from combo list + if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } + else // Id du contact + { + $sendto = $object->client->contact_get_property(GETPOST('receiver','alpha'),'email'); + $sendtoid = GETPOST('receiver','alpha'); + } + } + + if (dol_strlen($sendto)) + { + $langs->load("commercial"); + + $from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>'; + $replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>'; + $message = GETPOST('message'); + $sendtocc = GETPOST('sendtocc','alpha'); + $deliveryreceipt = GETPOST('deliveryreceipt','alpha'); + + if ($action == 'send') + { + if (dol_strlen(GETPOST('subject','alpha'))) $subject=GETPOST('subject','alpha'); + else $subject = $langs->transnoentities('Shipping').' '.$object->ref; + $actiontypecode='AC_SHIP'; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + if ($message) + { + $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; + $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; + $actionmsg.=$message; + } + $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } + + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + + // Send mail + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); + if ($mailfile->error) + { + $mesg='
'.$mailfile->error.'
'; + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + $error=0; + + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('SHIPPING_SENTBYMAIL',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $object->errors=$interface->errors; + } + // Fin appel triggers + + if ($error) + { + dol_print_error($db); + } + else + { + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); + setEventMessage($mesg); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } + else + { + $langs->load("other"); + $mesg='
'; + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='
'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg.='
'; + } + } + } + else + { + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; + $action='presend'; + dol_syslog('Recipient email is empty'); + } + /* } + else + { + $langs->load("errors"); + $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; + dol_syslog('Failed to read file: '.$file); + }*/ + } + + else if ($action == 'classifybilled') + { + $object->fetch($id); + $object->set_billed(); + } +} /* * View diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index bb84e279ba9..b6a4c5a7925 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -68,164 +68,166 @@ $hookmanager->initHooks(array('paymentsupplier')); $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -/* - * Actions - */ -if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) -{ - $error = 0; +if (empty($reshook)) { - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $paiement_id = 0; - $totalpayment = 0; - $atleastonepaymentnotnull = 0; - - // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new FactureFournisseur($db); - foreach ($_POST as $key => $value) + /* + * Actions + */ + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) { - if (substr($key,0,7) == 'amount_') + $error = 0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $paiement_id = 0; + $totalpayment = 0; + $atleastonepaymentnotnull = 0; + + // Generate payment array and check if there is payment higher than invoice and payment date before invoice date + $tmpinvoice=new FactureFournisseur($db); + foreach ($_POST as $key => $value) { - $cursorfacid = substr($key,7); - $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); - $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); - if ($amounts[$cursorfacid]) + if (substr($key,0,7) == 'amount_') { - // Check amount - if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) - { - $addwarning=1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { - $langs->load("errors"); - //$error++; - setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings'); - } + $cursorfacid = substr($key,7); + $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); + $totalpayment = $totalpayment + $amounts[$cursorfacid]; + if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result=$tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + if ($amounts[$cursorfacid]) + { + // Check amount + if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) + { + $addwarning=1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings'); + } + } + + $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); } - - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); } - } - // Check parameters - if ($_POST['paiementid'] <= 0) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors'); - $error++; - } - - if (! empty($conf->banque->enabled)) - { - // If bank module is on, account is required to enter a payment - if (GETPOST('accountid') <= 0) + // Check parameters + if ($_POST['paiementid'] <= 0) { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors'); + $error++; + } + + if (! empty($conf->banque->enabled)) + { + // If bank module is on, account is required to enter a payment + if (GETPOST('accountid') <= 0) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); + $error++; + } + } + + if (empty($totalpayment) && empty($atleastonepaymentnotnull)) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors'); + $error++; + } + + if (empty($datepaye)) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors'); $error++; } } - if (empty($totalpayment) && empty($atleastonepaymentnotnull)) + /* + * Action add_paiement + */ + if ($action == 'add_paiement') { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors'); - $error++; - } - - if (empty($datepaye)) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors'); - $error++; - } -} - -/* - * Action add_paiement - */ -if ($action == 'add_paiement') -{ - if ($error) - { - $action = 'create'; - } - // Le reste propre a cette action s'affiche en bas de page. -} - - -/* - * Action confirm_paiement - */ -if ($action == 'confirm_paiement' && $confirm == 'yes') -{ - $error=0; - - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - - if (! $error) - { - $db->begin(); - - // Creation de la ligne paiement - $paiement = new PaiementFourn($db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array of amounts - $paiement->paiementid = $_POST['paiementid']; - $paiement->num_paiement = $_POST['num_paiement']; - $paiement->note = $_POST['comment']; - if (! $error) + if ($error) { - $paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0)); - if ($paiement_id < 0) - { - setEventMessage($paiement->error, 'errors'); - $error++; - } + $action = 'create'; } + // Le reste propre a cette action s'affiche en bas de page. + } + + + /* + * Action confirm_paiement + */ + if ($action == 'confirm_paiement' && $confirm == 'yes') + { + $error=0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); if (! $error) { - $result=$paiement->addPaymentToBank($user,'payment_supplier','(SupplierInvoicePayment)',$_POST['accountid'],'',''); - if ($result < 0) - { - setEventMessage($paiement->error, 'errors'); - $error++; - } - } + $db->begin(); - if (! $error) - { - $db->commit(); - - // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card - $invoiceid=0; - foreach ($paiement->amounts as $key => $amount) + // Creation de la ligne paiement + $paiement = new PaiementFourn($db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array of amounts + $paiement->paiementid = $_POST['paiementid']; + $paiement->num_paiement = $_POST['num_paiement']; + $paiement->note = $_POST['comment']; + if (! $error) { - $facid = $key; - if (is_numeric($amount) && $amount <> 0) + $paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0)); + if ($paiement_id < 0) { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + setEventMessage($paiement->error, 'errors'); + $error++; } } - if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement_id; - header('Location: '.$loc); - exit; - } - else - { - $db->rollback(); + + if (! $error) + { + $result=$paiement->addPaymentToBank($user,'payment_supplier','(SupplierInvoicePayment)',$_POST['accountid'],'',''); + if ($result < 0) + { + setEventMessage($paiement->error, 'errors'); + $error++; + } + } + + if (! $error) + { + $db->commit(); + + // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card + $invoiceid=0; + foreach ($paiement->amounts as $key => $amount) + { + $facid = $key; + if (is_numeric($amount) && $amount <> 0) + { + if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment + else $invoiceid=$facid; + } + } + if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$invoiceid; + else $loc = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement_id; + header('Location: '.$loc); + exit; + } + else + { + $db->rollback(); + } } } } - /* * View */ diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index b4ceb2ae1b0..c98b855cdf9 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -54,40 +54,41 @@ $hookmanager->initHooks(array('suppliercard')); $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -/* - * Action - */ +if (empty($reshook)) { + /* + * Action + */ -if ($action == 'setsupplieraccountancycode') -{ - $cancelbutton = GETPOST('cancel'); + if ($action == 'setsupplieraccountancycode') + { + $cancelbutton = GETPOST('cancel'); - if (!$cancelbutton) { + if (!$cancelbutton) { - $result = $object->fetch($id); - $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; - $result = $object->update($object->id, $user, 1, 0, 1); - if ($result < 0) { - $mesg = join(',', $object->errors); + $result = $object->fetch($id); + $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; + $result = $object->update($object->id, $user, 1, 0, 1); + if ($result < 0) { + $mesg = join(',', $object->errors); + } + $action = ""; } - $action = ""; + } + // conditions de reglement + if ($action == 'setconditions' && $user->rights->societe->creer) + { + $object->fetch($id); + $result=$object->setPaymentTerms(GETPOST('cond_reglement_supplier_id','int')); + if ($result < 0) dol_print_error($db,$object->error); + } + // mode de reglement + if ($action == 'setmode' && $user->rights->societe->creer) + { + $object->fetch($id); + $result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int')); + if ($result < 0) dol_print_error($db,$object->error); } } -// conditions de reglement -if ($action == 'setconditions' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->setPaymentTerms(GETPOST('cond_reglement_supplier_id','int')); - if ($result < 0) dol_print_error($db,$object->error); -} -// mode de reglement -if ($action == 'setmode' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int')); - if ($result < 0) dol_print_error($db,$object->error); -} - /* * View diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 1e8c7b7cd9a..24c8122a3a0 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -76,13 +76,13 @@ $modulepart='produit'; $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if (empty($reshook)) { + /* + * Action envoie fichier + */ -/* - * Action envoie fichier - */ - -include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; - + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_pre_headers.tpl.php'; +} /* * View diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 527615cc7c4..c5ebe50049a 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -83,125 +83,125 @@ $parameters=array('socid'=>$socid, 'id_prod'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); -if ($action == 'remove_pf') -{ - $product = new ProductFournisseur($db); - if ($product->fetch($id) > 0) +if (empty($reshook)) { + if ($action == 'remove_pf') { - if ($rowid) + $product = new ProductFournisseur($db); + if ($product->fetch($id) > 0) { - $result=$product->remove_product_fournisseur_price($rowid); - $action = ''; - $mesg = '
'.$langs->trans("PriceRemoved").'.
'; + if ($rowid) + { + $result=$product->remove_product_fournisseur_price($rowid); + $action = ''; + $mesg = '
'.$langs->trans("PriceRemoved").'.
'; + } } } -} -if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel")) -{ - $id_fourn=GETPOST("id_fourn"); - if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn"); - $ref_fourn=GETPOST("ref_fourn"); - if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn"); - $quantity=GETPOST("qty"); - $remise_percent=price2num(GETPOST('remise_percent','alpha')); - $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ; - $tva_tx = str_replace('*','', GETPOST('tva_tx','alpha')); - $tva_tx = price2num($tva_tx); + if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel")) + { + $id_fourn=GETPOST("id_fourn"); + if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn"); + $ref_fourn=GETPOST("ref_fourn"); + if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn"); + $quantity=GETPOST("qty"); + $remise_percent=price2num(GETPOST('remise_percent','alpha')); + $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ; + $tva_tx = str_replace('*','', GETPOST('tva_tx','alpha')); + $tva_tx = price2num($tva_tx); - if ($tva_tx == '') - { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("VATRateForSupplierProduct")).'
'; - } - if (empty($quantity)) - { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'
'; - } - if (empty($ref_fourn)) - { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")).'
'; - } - if ($id_fourn <= 0) - { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")).'
'; - } - if ($_POST["price"] < 0 || $_POST["price"] == '') - { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'
'; - } - - $product = new ProductFournisseur($db); - $result=$product->fetch($id); - if ($result <= 0) - { - $error++; - $mesg=$product->error; - } - - if (! $error) - { - $db->begin(); - - if (! $error) + if ($tva_tx == '') + { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("VATRateForSupplierProduct")).'
'; + } + if (empty($quantity)) { - $ret=$product->add_fournisseur($user, $id_fourn, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice - if ($ret == -3) - { - $error++; + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'
'; + } + if (empty($ref_fourn)) + { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")).'
'; + } + if ($id_fourn <= 0) + { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")).'
'; + } + if ($_POST["price"] < 0 || $_POST["price"] == '') + { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'
'; + } - $product->fetch($product->product_id_already_linked); - $productLink = $product->getNomUrl(1,'supplier'); - - $mesg='
'.$langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct",$productLink).'
'; - } - else if ($ret < 0) - { - $error++; - $mesg='
'.$product->error.'
'; - } + $product = new ProductFournisseur($db); + $result=$product->fetch($id); + if ($result <= 0) + { + $error++; + $mesg=$product->error; } if (! $error) - { - $supplier=new Fournisseur($db); - $result=$supplier->fetch($id_fourn); - if (isset($_POST['ref_fourn_price_id'])) - $product->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); + { + $db->begin(); - $ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, $npr); - if ($ret < 0) + if (! $error) { - $error++; - $mesg='
'.$product->error.'
'; + $ret=$product->add_fournisseur($user, $id_fourn, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice + if ($ret == -3) + { + $error++; + + $product->fetch($product->product_id_already_linked); + $productLink = $product->getNomUrl(1,'supplier'); + + $mesg='
'.$langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct",$productLink).'
'; + } + else if ($ret < 0) + { + $error++; + $mesg='
'.$product->error.'
'; + } } - } - if (! $error) - { - $db->commit(); - $action=''; - } - else - { - $db->rollback(); - } - } + if (! $error) + { + $supplier=new Fournisseur($db); + $result=$supplier->fetch($id_fourn); + if (isset($_POST['ref_fourn_price_id'])) + $product->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); + + $ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, $npr); + if ($ret < 0) + { + $error++; + $mesg='
'.$product->error.'
'; + } + } + + if (! $error) + { + $db->commit(); + $action=''; + } + else + { + $db->rollback(); + } + } + } + + if (GETPOST('cancel') == $langs->trans("Cancel")) + { + $action = ''; + header("Location: fournisseurs.php?id=".$_GET["id"]); + exit; + } } -if (GETPOST('cancel') == $langs->trans("Cancel")) -{ - $action = ''; - header("Location: fournisseurs.php?id=".$_GET["id"]); - exit; -} - - - /* * view */ diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 38562557e3a..0dbf21ce881 100755 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -61,58 +61,59 @@ $hookmanager->initHooks(array('resource_card')); $parameters=array('resource_id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if (empty($reshook)) { -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ + /******************************************************************* + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + ********************************************************************/ -if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write ) -{ - $error=0; - - if (empty($ref)) + if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write ) { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
'; - } + $error=0; - if (! $error) - { - $res = $object->fetch($id); - if ( $res > 0 ) + if (empty($ref)) { - $object->ref = $ref; - $object->description = $description; - $object->fk_code_type_resource = $fk_code_type_resource; - - $result=$object->update($user); - if ($result > 0) + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
'; + } + + if (! $error) + { + $res = $object->fetch($id); + if ( $res > 0 ) { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; + $object->ref = $ref; + $object->description = $description; + $object->fk_code_type_resource = $fk_code_type_resource; + + $result=$object->update($user); + if ($result > 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + setEventMessage('
'.$object->error.'
'); + $action='edit'; + } + } else { - setEventMessage('
'.$object->error.'
'); + setEventMessage($object->error,'errors'); $action='edit'; } - } - else + else { - setEventMessage($object->error,'errors'); $action='edit'; } } - else - { - $action='edit'; - } } - /*************************************************** * VIEW * From dacec491ff56cc21c784deb11c54d46359c38131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:37:49 +0100 Subject: [PATCH 098/152] Fix: [ bug #1783 ] SQL error when enabling 3rd party module with PostgreSQL and MySQL strict mode ON --- ChangeLog | 2 +- htdocs/core/class/menubase.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..ab27963fd2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules - +- Fix: [ bug #1783 ] SQL error when enabling 3rd party module with PostgreSQL and MySQL strict mode ON ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. - Fix: bug 1588 : relative discount. diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index c04697acd39..2f4049ee460 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -152,7 +152,7 @@ class Menubase $sql.= " '".$this->fk_menu."',"; $sql.= " ".($this->fk_mainmenu?"'".$this->fk_mainmenu."'":"null").","; $sql.= " ".($this->fk_leftmenu?"'".$this->fk_leftmenu."'":"null").","; - $sql.= " '".$this->position."',"; + $sql.= " '".(int) $this->position."',"; $sql.= " '".$this->db->escape($this->url)."',"; $sql.= " '".$this->db->escape($this->target)."',"; $sql.= " '".$this->db->escape($this->titre)."',"; From 003aa5ee4433059b1d68ec7e147996bafd467051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:41:31 +0100 Subject: [PATCH 099/152] Fix: [ bug #1717 ] Sorting unpaid invoices by amount received brings due amount --- ChangeLog | 1 + htdocs/compta/facture/impayees.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..83a107cb6e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules +- Fix: [ bug #1717 ] Sorting unpaid invoices by amount received brings due amount ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index d009216bc86..467d2b0636a 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -535,7 +535,7 @@ if ($resql) print_liste_field_titre($langs->trans("Taxes"),$_SERVER["PHP_SELF"],"f.tva","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder); if (empty($mode)) { From 78905c6af1bd95dd957c4426bb341074b88ff77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 20:29:51 +0100 Subject: [PATCH 100/152] =?UTF-8?q?Fix:=20[=20bug=20#1784=20]=20=C2=AB=20M?= =?UTF-8?q?essage=20page=20de=20connexion=20=C2=BB=20n'appara=C3=AEt=20pas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 1 + htdocs/core/tpl/login.tpl.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..a6231b139ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules +- Fix: [ bug #1784 ] « Message page de connexion » n'apparaît pas ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 82748a69b05..f508a595d23 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -203,7 +203,7 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file -
+
Date: Sun, 18 Jan 2015 00:57:03 +0100 Subject: [PATCH 101/152] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3388bbdbfe7..683c2c419f0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2335,8 +2335,11 @@ class Facture extends CommonInvoice } /** + * Update invoice line with percentage + * * @param FactureLigne $line Invoice line * @param int $percent + * @return void */ function update_percent($line, $percent) { @@ -3451,6 +3454,7 @@ class Facture extends CommonInvoice /** * Checks if the invoice is the first of a cycle * + * @return boolean */ function is_first() { @@ -3460,6 +3464,7 @@ class Facture extends CommonInvoice /** * Returns an array containing the previous situations as Facture objects * + * @return mixed -1 if error, array of previous situations */ function get_prev_sits() { @@ -3514,7 +3519,6 @@ class Facture extends CommonInvoice * @return int 0 or 1 if OK, -1 if error * */ - function is_last_in_cycle() { $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; @@ -4096,7 +4100,6 @@ class FactureLigne extends CommonInvoiceLine * * @return int >= 0 */ - function get_prev_progress() { if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { From 6237f68e74e0689ad4d19fa9ae9ca47a1463b46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 18 Jan 2015 01:07:32 +0100 Subject: [PATCH 102/152] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 683c2c419f0..a6cf04715f2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2338,7 +2338,7 @@ class Facture extends CommonInvoice * Update invoice line with percentage * * @param FactureLigne $line Invoice line - * @param int $percent + * @param int $percent Percentage * @return void */ function update_percent($line, $percent) From 17b14eed88bfb2cf9073b34f2948cbe9ee8b7016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 18 Jan 2015 02:55:59 +0100 Subject: [PATCH 103/152] Updated bug title --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a6231b139ce..d71dc3e7a01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules -- Fix: [ bug #1784 ] « Message page de connexion » n'apparaît pas +- Fix: [ bug #1784 ] MOTD doesn't show up in Amarok theme ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. From 71e5cf07c6de693e4e775e912b783f613696ddc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 18 Jan 2015 03:12:19 +0100 Subject: [PATCH 104/152] Fix: [ bug #1735 ] Rights to delete expense notes no longer there - cannot delete expense notes --- htdocs/core/modules/modDeplacement.class.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index 75d3ab328c8..c536553ac4b 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -95,17 +95,17 @@ class modDeplacement extends DolibarrModules $this->rights[3][3] = 0; $this->rights[3][4] = 'supprimer'; - $this->rights[3][0] = 174; - $this->rights[3][1] = 'Lire toutes les notes de frais'; - $this->rights[3][2] = 'd'; - $this->rights[3][3] = 0; - $this->rights[3][4] = 'readall'; + $this->rights[4][0] = 174; + $this->rights[4][1] = 'Lire toutes les notes de frais'; + $this->rights[4][2] = 'd'; + $this->rights[4][3] = 0; + $this->rights[4][4] = 'readall'; - $this->rights[6][0] = 178; - $this->rights[6][1] = 'Exporter les notes de frais et deplacements'; - $this->rights[6][2] = 'd'; - $this->rights[6][3] = 0; - $this->rights[6][4] = 'export'; + $this->rights[5][0] = 178; + $this->rights[5][1] = 'Exporter les notes de frais et deplacements'; + $this->rights[5][2] = 'd'; + $this->rights[5][3] = 0; + $this->rights[5][4] = 'export'; // Exports $r=0; From 48c6897f758fa93f33c9ab62eb05ae3a738c52b4 Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Sun, 18 Jan 2015 03:20:35 +0100 Subject: [PATCH 105/152] Store per entity SMTP configuration --- htdocs/admin/mails.php | 12 ++++++------ htdocs/install/mysql/data/llx_const.sql | 6 +++--- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 8 ++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index b39760c6907..e3908ad19d7 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -65,12 +65,12 @@ if ($action == 'update' && empty($_POST["cancel"])) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity); // Send mode parameters - dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',0); - if (isset($_POST["MAIN_MAIL_SMTP_PORT"])) dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',0); - if (isset($_POST["MAIN_MAIL_SMTP_SERVER"])) dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',0); - if (isset($_POST["MAIN_MAIL_SMTPS_ID"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',0); - if (isset($_POST["MAIN_MAIL_SMTPS_PW"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',0); - if (isset($_POST["MAIN_MAIL_EMAIL_TLS"])) dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',0); + dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',$conf->entity); // Content parameters dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity); diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 0c0a98355c0..3b627f3d99b 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -40,13 +40,13 @@ insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_FILE','DOL_DATA_ROOT/dolibarr.log','chaine','Directory where to write log file',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_LEVEL','7','chaine','Level of debug info to show',0,0); -insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_SMTP_SERVER','','chaine','Host or ip address for SMTP server',0,0); -insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_SMTP_PORT','','chaine','Port for SMTP server',0,0); - insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_UPLOAD_DOC','2048','chaine','Max size for file upload (0 means no upload allowed)',0,0); -- Hidden but specific to one entity insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MONNAIE','EUR','chaine','Monnaie',0,1); + +insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_SMTP_SERVER','','chaine','Host or ip address for SMTP server',0,1); +insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_SMTP_PORT','','chaine','Port for SMTP server',0,1); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_MAIL_EMAIL_FROM','robot@domain.com','chaine','EMail emetteur pour les emails automatiques Dolibarr',0,1); -- diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 02265ff86c8..d3f269d6dbe 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -37,3 +37,11 @@ ALTER TABLE llx_facture ADD situation_counter tinyint UNSIGNED; ALTER TABLE llx_facture ADD situation_final boolean; ALTER TABLE llx_facturedet ADD situation_percent real; ALTER TABLE llx_facturedet ADD fk_prev_id integer; + +-- Convert SMTP config to main entity, so new entities don't get the old values +UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SENDMODE"; +UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTP_PORT"; +UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTP_SERVER"; +UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTPS_ID"; +UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTPS_PW"; +UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_EMAIL_TLS"; \ No newline at end of file From be3527abd1cf2ca90ed9bc612cb2e84d686f5593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 18 Jan 2015 03:23:00 +0100 Subject: [PATCH 106/152] Fixed some errors of Bookkeeping class --- .../accountancy/class/bookkeeping.class.php | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 6291790d008..a3a760b0570 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -221,7 +221,7 @@ class BookKeeping * Insert line into bookkeeping * * @param User $user User who inserted operation - * @return $result Result + * @return int <0 KO >0 OK */ function create($user='') { @@ -276,8 +276,9 @@ class BookKeeping } $now = dol_now(); - if (empty($this->date_create)) - $this->date_create = $now(); + if (empty($this->date_create)) { + $this->date_create = $now; + } $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, "; $sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,"; @@ -330,23 +331,19 @@ class BookKeeping $sql .= " WHERE import_key = '" . $importkey . "'"; $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = "Error " . $this->db->lasterror(); - } - // Commit or rollback - if ($error) { + if (! $resql) { + $this->errors[] = "Error " . $this->db->lasterror(); foreach ( $this->errors as $errmsg ) { dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; - } else { - $this->db->commit(); - return 1; + return - 1; } + + $this->db->commit(); + return 1; } /** @@ -595,16 +592,13 @@ class BookKeeping $this->db->begin(); - if (! $error) - { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user); - if ($result < 0) $error++; - // End call triggers - } - } +// if (! $notrigger) +// { +// // Call trigger +// $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user); +// if ($result < 0) $error++; +// // End call triggers +// } if (! $error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; From 2396f03093171f06342abd1e3825c3b3cf259d77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 11:21:43 +0100 Subject: [PATCH 107/152] Add PHP 5.6 into travis tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 98ebd9ceea3..f65d575f924 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ php: - "5.3" - "5.4" - "5.5" + - "5.6" env: - DB=mysql From 1681e3b03d8cbe064d33115d2a1b128860790574 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 11:36:15 +0100 Subject: [PATCH 108/152] Fix: Not allowed types (http://wiki.dolibarr.org/index.php/Langages_et_normes#Structure_des_tables_et_champs) --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 02265ff86c8..cea731b9dc9 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -32,8 +32,8 @@ ALTER TABLE llx_product_fournisseur_price ADD fk_price_expression integer DEFAUL insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 2131, 213, '5', '0', 'VAT 5%', 1); -- Add situation invoices -ALTER TABLE llx_facture ADD situation_cycle_ref smallint UNSIGNED; -ALTER TABLE llx_facture ADD situation_counter tinyint UNSIGNED; -ALTER TABLE llx_facture ADD situation_final boolean; +ALTER TABLE llx_facture ADD situation_cycle_ref integer; +ALTER TABLE llx_facture ADD situation_counter integer; +ALTER TABLE llx_facture ADD situation_final integer; ALTER TABLE llx_facturedet ADD situation_percent real; ALTER TABLE llx_facturedet ADD fk_prev_id integer; From f3a313645263ae33fe3d634de8534ac92907614d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 18 Jan 2015 11:38:45 +0100 Subject: [PATCH 109/152] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c4b025878c5..aa1f79cfb11 100755 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2666,7 +2666,7 @@ class Form * * @return string HTML select */ - function load_situation_invoices($selected = '', $socid) + function load_situation_invoices($selected = '', $socid = '') { global $langs; From b53b8d2e45ab6d532705a5c4c46d27d3271c24f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 11:48:52 +0100 Subject: [PATCH 110/152] Fixed: Backward compatibility --- htdocs/comm/action/class/actioncomm.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fb7195fdd68..b58123578dd 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -138,6 +138,13 @@ class ActionComm extends CommonObject if ($this->elementtype=='commande') $this->elementtype='order'; if ($this->elementtype=='contrat') $this->elementtype='contract'; + if (! is_array($this->userassigned)) // For backward compatibility + { + $tmpid=$this->userassigned; + $this->userassigned=array(); + $this->userassigned[$tmpid]=array('id'=>$tmpid); + } + $userownerid=$this->userownerid; $userdoneid=$this->userdoneid; From 012c571a6c7efcb82730ec32356c18038c52304a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 11:48:52 +0100 Subject: [PATCH 111/152] Fixed: Backward compatibility --- htdocs/comm/action/class/actioncomm.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index dd7819f7dbb..f8e02de72a7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -138,6 +138,13 @@ class ActionComm extends CommonObject if ($this->elementtype=='commande') $this->elementtype='order'; if ($this->elementtype=='contrat') $this->elementtype='contract'; + if (! is_array($this->userassigned)) // For backward compatibility + { + $tmpid=$this->userassigned; + $this->userassigned=array(); + $this->userassigned[$tmpid]=array('id'=>$tmpid); + } + $userownerid=$this->userownerid; $userdoneid=$this->userdoneid; From c8db8f001bc747b7660145595e669a52208e8d6b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 18 Jan 2015 12:06:05 +0100 Subject: [PATCH 112/152] fix travis --- htdocs/projet/class/project.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 6be870543e5..4eef74b0dc1 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1002,6 +1002,7 @@ class Project extends CommonObject * @param bool $clone_project_file clone file of project * @param bool $clone_task_file clone file of task (if task are copied) * @param bool $clone_note clone note of project + * @param bool $move_date move task date on clone * @param bool $notrigger no trigger flag * @return int New id of clone */ @@ -1011,7 +1012,7 @@ class Project extends CommonObject $error=0; - dol_syslog("createFromClone clone_contact=".$clone_contact." clone_task=".$clone_task." clone_project_file=".$clone_project_file." clone_note=".$clone_note); + dol_syslog("createFromClone clone_contact=".$clone_contact." clone_task=".$clone_task." clone_project_file=".$clone_project_file." clone_note=".$clone_note." move_date=".$move_date,LOG_DEBUG); $now = dol_mktime(0,0,0,idate('m',dol_now()),idate('d',dol_now()),idate('Y',dol_now())); From 6a294eb02a43ff65c49fbb4c7558b776c2926ed0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 12:29:55 +0100 Subject: [PATCH 113/152] Fixed: Better fix for backward compatibility --- htdocs/comm/action/class/actioncomm.class.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index dd7819f7dbb..2116b4c2530 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -118,6 +118,13 @@ class ActionComm extends CommonObject $error=0; $now=dol_now(); + // Check parameters + if (empty($this->userownerid)) + { + $this->errors[]='ErrorPropertyUserowneridNotDefined'; + return -1; + } + // Clean parameters $this->label=dol_trunc(trim($this->label),128); $this->location=dol_trunc(trim($this->location),128); @@ -137,12 +144,13 @@ class ActionComm extends CommonObject if ($this->elementtype=='facture') $this->elementtype='invoice'; if ($this->elementtype=='commande') $this->elementtype='order'; if ($this->elementtype=='contrat') $this->elementtype='contract'; - + $userownerid=$this->userownerid; $userdoneid=$this->userdoneid; - // Be sure assigned user array is not empty. - if (count($this->userassigned) == 0) $this->userassigned = array('id'=>$userownerid); + // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). + if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned)) + $this->userassigned = array($userownerid=>array('id'=>$userownerid)); if (! $this->type_id || ! $this->type_code) { @@ -229,6 +237,12 @@ class ActionComm extends CommonObject { foreach($this->userassigned as $key => $val) { + if (! is_array($val)) // For backward compatibility when val=id + { + $tmpid=$val; + $val=array('id'=>$val); + } + $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".($val['mandatory']?$val['mandatory']:'0').", ".($val['transparency']?$val['transparency']:'0').", ".($val['answer_status']?$val['answer_status']:'0').")"; From d45750d914d82ece73d9fbe7df9f995ffb3462c8 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sun, 18 Jan 2015 13:07:39 +0100 Subject: [PATCH 114/152] Ignore content of directory custom Conflicts: htdocs/custom/.gitignore --- htdocs/custom/.gitignore | 8 ++++---- htdocs/custom/index.html | 0 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 htdocs/custom/index.html diff --git a/htdocs/custom/.gitignore b/htdocs/custom/.gitignore index ed069fdfd81..89ebd12182c 100644 --- a/htdocs/custom/.gitignore +++ b/htdocs/custom/.gitignore @@ -1,4 +1,4 @@ -/a* -/b* -/c* -/d* +/* +!.gitignore +!README.md +!index.html \ No newline at end of file diff --git a/htdocs/custom/index.html b/htdocs/custom/index.html new file mode 100644 index 00000000000..e69de29bb2d From 839f73d5687966e80e6d337c3aab5ce48b051e3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 14:57:25 +0100 Subject: [PATCH 115/152] Update doc --- build/makepack-howto.txt | 4 +--- scripts/odt2pdf/odt2pdf.sh | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index 40b0e5180bc..9e5004f4ba7 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -11,7 +11,6 @@ beta version of Dolibarr, step by step. - Update version/info in /ChangeLog - Update version number with x.y.z-w in htdocs/filefunc.inc.php - Update version number with x.y.z-w in build/debian/changelog -- Update version number with x.y.z-w in build/exe/doliwamp/doliwamp.iss - Update version number with x.y.z-w in build/rpm/*.spec - Commit all changes. - Add a Tag (x.y.betaz_YYYYMMDD) and push it: git push --tags @@ -30,10 +29,9 @@ This files describe steps made by Dolibarr packaging team to make a complete release of Dolibarr, step by step. - Check all files are commited. -- Update version/info in ChangeLog +- Update version/info in ChangeLog. To generate a changelog, you can do "git log x.y.z..HEAD --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^Fix\|New\|Sec'" - Update version number with x.y.z in htdocs/filefunc.inc.php - Update version number with x.y.z in build/debian/changelog -- Update version number with x.y.z in build/exe/doliwamp/doliwamp.iss - Update version number with x.y.z in build/rpm/*.spec - Commit all changes. diff --git a/scripts/odt2pdf/odt2pdf.sh b/scripts/odt2pdf/odt2pdf.sh index 9d9bf18a8c7..c7c768a1244 100755 --- a/scripts/odt2pdf/odt2pdf.sh +++ b/scripts/odt2pdf/odt2pdf.sh @@ -1,8 +1,12 @@ #!/bin/bash # @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com # @copyright GPL License 2013 - Florian HEnry - florian.henry@open-concept.pro - # +# Convert an ODT into a PDF using "jodconverter" tool. +# Dolibarr variable MAIN_ODT_AS_PDF must be defined to have this script called after ODT generation. +# Dolibarr variable MAIN_DOL_SCRIPTS_ROOT must be defined to path of script directories (otherwise dolibarr will try to guess). + + #if [ -f "$1.odt" ] # then # soffice --invisible --convert-to pdf:writer_pdf_Export --outdir $2 "$1.odt" From 22c253cfc192266082b2cec41a7219750d28f0ea Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 18 Jan 2015 16:02:31 +0100 Subject: [PATCH 116/152] add extrafield type, check box from table --- ChangeLog | 1 + htdocs/core/class/extrafields.class.php | 209 +++++++++++++++++- htdocs/core/tpl/admin_extrafields_add.tpl.php | 30 +-- .../core/tpl/admin_extrafields_edit.tpl.php | 6 +- htdocs/langs/en_US/admin.lang | 4 +- htdocs/langs/fr_FR/admin.lang | 2 + 6 files changed, 230 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bac5ca622b..0f4f3b83a1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ English Dolibarr ChangeLog -------------------------------------------------------------- ***** ChangeLog for 3.8 compared to 3.7.* ***** - New: Add Option to not change date on cloning project +- New: Add check list from table for extrafield type ***** ChangeLog for 3.8 compared to 3.7.* ***** diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 30c97e9f1ef..364307468a7 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -72,7 +72,7 @@ class ExtraFields 'separate' => 'ExtrafieldSeparator', 'checkbox' => 'ExtrafieldCheckBox', 'radio' => 'ExtrafieldRadio', - + 'chkbxlst' => 'ExtrafieldCheckBoxFromList', ); /** @@ -171,7 +171,7 @@ class ExtraFields }elseif($type=='mail') { $typedb='varchar'; $lengthdb='128'; - } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox')){ + } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){ $typedb='text'; $lengthdb=''; } else { @@ -373,7 +373,7 @@ class ExtraFields }elseif($type=='mail') { $typedb='varchar'; $lengthdb='128'; - } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox')) { + } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) { $typedb='text'; $lengthdb=''; } else { @@ -864,6 +864,140 @@ class ExtraFields $out.='/>'.$val.'
'; } } + elseif ($type == 'chkbxlst') + { + $value_arr = explode(',', $value); + + if (is_array($param['options'])) { + $param_list = array_keys($param['options']); + $InfoFieldList = explode(":", $param_list[0]); + // 0 : tableName + // 1 : label field name + // 2 : key fields name (if differ of rowid) + // 3 : key field parent (for dependent lists) + // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value + $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid'); + + if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) { + list ( $parentName, $parentField ) = explode('|', $InfoFieldList[3]); + $keyList .= ', ' . $parentField; + } + if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) { + if (strpos($InfoFieldList[4], 'extra.') !== false) { + $keyList = 'main.' . $InfoFieldList[2] . ' as rowid'; + } else { + $keyList = $InfoFieldList[2] . ' as rowid'; + } + } + + $fields_label = explode('|', $InfoFieldList[1]); + if (is_array($fields_label)) { + $keyList .= ', '; + $keyList .= implode(', ', $fields_label); + } + + $sqlwhere = ''; + $sql = 'SELECT ' . $keyList; + $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; + if (! empty($InfoFieldList[4])) { + // We have to join on extrafield table + if (strpos($InfoFieldList[4], 'extra') !== false) { + $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; + $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4]; + } else { + $sqlwhere .= ' WHERE ' . $InfoFieldList[4]; + } + } else { + $sqlwhere .= ' WHERE 1'; + } + if (in_array($InfoFieldList[0], array ( + 'tablewithentity' + ))) + $sqlwhere .= ' AND entity = ' . $conf->entity; // Some tables may have field, some other not. For the moment we disable it. + // $sql.=preg_replace('/^ AND /','',$sqlwhere); + // print $sql; + $sql .= $sqlwhere; + dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ( $i < $num ) { + $labeltoshow = ''; + $obj = $this->db->fetch_object($resql); + + // Several field into label (eq table:code|libelle:rowid) + $fields_label = explode('|', $InfoFieldList[1]); + if (is_array($fields_label)) { + $notrans = true; + foreach ( $fields_label as $field_toshow ) { + $labeltoshow .= $obj->$field_toshow . ' '; + } + } else { + $labeltoshow = $obj->$InfoFieldList[1]; + } + $labeltoshow = dol_trunc($labeltoshow, 45); + + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + foreach ( $fields_label as $field_toshow ) { + $translabel = $langs->trans($obj->$field_toshow); + if ($translabel != $obj->$field_toshow) { + $labeltoshow = dol_trunc($translabel, 18) . ' '; + } else { + $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; + } + } + $out .= 'rowid . '"'; + + $out .= 'checked="checked"'; + + $out .= '/>' . $labeltoshow . '
'; + } else { + if (! $notrans) { + $translabel = $langs->trans($obj->$InfoFieldList[1]); + if ($translabel != $obj->$InfoFieldList[1]) { + $labeltoshow = dol_trunc($translabel, 18); + } else { + $labeltoshow = dol_trunc($obj->$InfoFieldList[1], 18); + } + } + if (empty($labeltoshow)) + $labeltoshow = '(not defined)'; + + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + $out .= 'rowid . '"'; + + $out .= 'checked="checked"'; + $out .= ''; + + $out .= '/>' . $labeltoshow . '
'; + } + + if (! empty($InfoFieldList[3])) { + $parent = $parentName . ':' . $obj->{$parentField}; + } + + $out .= 'rowid . '"'; + + $out .= ((is_array($value_arr) && in_array($obj->rowid, $value_arr)) ? ' checked="checked" ' : ''); + ; + $out .= ''; + + $out .= '/>' . $labeltoshow . '
'; + } + + $i ++; + } + $this->db->free($resql); + } else { + print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; + } + } + $out .= ''; + } /* Add comments if ($type == 'date') $out.=' (YYYY-MM-DD)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; @@ -1019,6 +1153,73 @@ class ExtraFields } } } + elseif ($type == 'chkbxlst') + { + $value_arr = explode(',', $value); + + $param_list = array_keys($params['options']); + $InfoFieldList = explode(":", $param_list[0]); + + $selectkey = "rowid"; + $keyList = 'rowid'; + + if (count($InfoFieldList) >= 3) { + $selectkey = $InfoFieldList[2]; + $keyList = $InfoFieldList[2] . ' as rowid'; + } + + $fields_label = explode('|', $InfoFieldList[1]); + if (is_array($fields_label)) { + $keyList .= ', '; + $keyList .= implode(', ', $fields_label); + } + + $sql = 'SELECT ' . $keyList; + $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; + if (strpos($InfoFieldList[4], 'extra') !== false) { + $sql .= ' as main'; + } + // $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; + // $sql.= ' AND entity = '.$conf->entity; + + dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst',LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $value = ''; // value was used, so now we reste it to use it to build final output + + while ( $obj = $this->db->fetch_object($resql) ) { + + // Several field into label (eq table:code|libelle:rowid) + $fields_label = explode('|', $InfoFieldList[1]); + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + if (is_array($fields_label) && count($fields_label) > 1) { + foreach ( $fields_label as $field_toshow ) { + $translabel = ''; + if (! empty($obj->$field_toshow)) { + $translabel = $langs->trans($obj->$field_toshow); + } + if ($translabel != $field_toshow) { + $value .= dol_trunc($translabel, 18) . '
'; + } else { + $value .= $obj->$field_toshow . '
'; + } + } + } else { + $translabel = ''; + if (! empty($obj->$InfoFieldList[1])) { + $translabel = $langs->trans($obj->$InfoFieldList[1]); + } + if ($translabel != $obj->$InfoFieldList[1]) { + $value .= dol_trunc($translabel, 18) . '
'; + } else { + $value .= $obj->$InfoFieldList[1] . '
'; + } + } + } + } + } else + dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); + } else { $showsize=round($size); @@ -1074,7 +1275,7 @@ class ExtraFields // Clean parameters $value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); } - else if (in_array($key_type,array('checkbox'))) + else if (in_array($key_type,array('checkbox','chkbxlst'))) { $value_arr=GETPOST("options_".$key); if (!empty($value_arr)) { diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 56cca5af04f..8f14bff797f 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -39,19 +39,20 @@ } ?> - if (type == 'date') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } - else if (type == 'datetime') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } - else if (type == 'double') { size.val('24,8').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } - else if (type == 'int') { size.val('10').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } - else if (type == 'text') { size.val('2000').removeAttr('disabled'); unique.attr('disabled','disabled').removeAttr('checked'); jQuery("#value_choice").hide(); } - else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); } - else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();} - else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();} - else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();} - else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();} - else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();} - else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();} - else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();} + if (type == 'date') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } + else if (type == 'datetime') { size.val('').attr('disabled','disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} + else if (type == 'double') { size.val('24,8').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} + else if (type == 'int') { size.val('10').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} + else if (type == 'text') { size.val('2000').removeAttr('disabled'); unique.attr('disabled','disabled').removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } + else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } + else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} + else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} + else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();} + else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();} + else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();} + else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();} + else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} + else if (type == 'chkbxlst') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide(); jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();} else size.val('').attr('disabled','disabled'); } init_typeoffields(''); @@ -90,7 +91,8 @@ textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0)?> -textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?> +textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?> +textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0)?> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 493634c84a5..9cf186de39f 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -57,7 +57,7 @@ $pos=$extrafields->attribute_pos[$attrname]; $alwayseditable=$extrafields->attribute_alwayseditable[$attrname]; $param=$extrafields->attribute_param[$attrname]; -if((($type == 'select') || ($type == 'checkbox') ||(($type == 'radio'))) && is_array($param)) +if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) { $param_chain = ''; foreach ($param['options'] as $key => $value) @@ -68,7 +68,7 @@ if((($type == 'select') || ($type == 'checkbox') ||(($type == 'radio'))) && is_a } } } -elseif ($type== 'sellist') +elseif (($type== 'sellist') || ($type == 'chkbxlst')) { $paramlist=array_keys($param['options']); $param_chain = $paramlist[0]; @@ -89,7 +89,7 @@ elseif ($type== 'sellist') trans("Position"); ?> diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0b328e705a7..2dda463b91c 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -382,10 +382,12 @@ ExtrafieldSelectList = Select from table ExtrafieldSeparator=Separator ExtrafieldCheckBox=Checkbox ExtrafieldRadio=Radio button +ExtrafieldCheckBoxFromList= Checkbox from table ExtrafieldParamHelpselect=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
...

In order to have the list depending on another :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... -ExtrafieldParamHelpsellist=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelpsellist=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelpchkbxlst=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter LibraryToBuildPDF=Library used to build PDF WarningUsingFPDF=Warning: Your conf.php contains directive dolibarr_pdf_force_fpdf=1. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.
To solve this and have a full support of PDF generation, please download TCPDF library, then comment or remove the line $dolibarr_pdf_force_fpdf=1, and add instead $dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir' LocalTaxDesc=Some countries apply 2 or 3 taxes on each invoice line. If this is the case, choose type for second and third tax and its rate. Possible type are:
1 : local tax apply on products and services without vat (vat is not applied on local tax)
2 : local tax apply on products and services before vat (vat is calculated on amount + localtax)
3 : local tax apply on products without vat (vat is not applied on local tax)
4 : local tax apply on products before vat (vat is calculated on amount + localtax)
5 : local tax apply on services without vat (vat is not applied on local tax)
6 : local tax apply on services before vat (vat is calculated on amount + localtax) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 4397bb313fa..4e783fafce1 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -382,10 +382,12 @@ ExtrafieldSelectList = Liste issue d'une table ExtrafieldSeparator=Séparateur de champ ExtrafieldCheckBox=Case à cocher ExtrafieldRadio=Bouton radio +ExtrafieldCheckBoxFromList= Case à cocher issue d'une table ExtrafieldParamHelpselect=La liste doit être de la forme clef,valeur

par exemple :
1,valeur1
2,valeur2
3,valeur3
...

Pour que la liste soit dépendante d'une autre :
1,valeur1|code_liste_parent:clef_parent
2,valeur2|code_liste_parent:clef_parent ExtrafieldParamHelpcheckbox=La liste doit être de la forme clef,valeur

par exemple :
1,valeur1
2,valeur2
3,valeur3
... ExtrafieldParamHelpradio=La liste doit être de la forme clef,valeur

par exemple :
1,valeur1
2,valeur2
3,valeur3
... ExtrafieldParamHelpsellist=La liste vient d'une table
Syntaxe:
nom_de_table:nom_de_champ:id_champ::filtre
Exemple :
c_typent:libelle:id::filter

filter peux être un test simple (exemple active=1 pour ne proposer que les valeur active)
si vous voulez faire un filtre sur des attributs supplémentaires, utilisez la syntax extra.champ=... (où champ est la code de l'attribut supplémentaire)

Pour que la liste soit dépendante d'une autre :
c_typent:libelle:id:code_liste_parent|colonne_parent:filter +ExtrafieldParamHelpchkbxlst=Les cases à cocher viennent d'une table
Syntaxe:
nom_de_table:nom_de_champ:id_champ::filtre
Exemple :
c_typent:libelle:id::filter

filter peux être un test simple (exemple active=1 pour ne proposer que les valeur active)
si vous voulez faire un filtre sur des attributs supplémentaires, utilisez la syntax extra.champ=... (où champ est la code de l'attribut supplémentaire)

Pour que la liste soit dépendante d'une autre :
c_typent:libelle:id:code_liste_parent|colonne_parent:filter LibraryToBuildPDF=Bibliothèque utilisée pour la génération des PDF WarningUsingFPDF=Attention : votre fichier conf.php contient la directive dolibarr_pdf_force_fpdf=1. Cela signifie que vous utilisez la librairie FPDF pour générer vos fichiers PDF. Cette librairie est ancienne et ne couvre pas de nombreuses fonctionnalités (Unicode, transparence des images, langues cyrilliques, arabes ou asiatiques...), aussi vous pouvez rencontrer des problèmes durant la génération des PDF.
Pour résoudre cela et avoir une prise en charge complète de PDF, vous pouvez télécharger la bibliothèque TCPDF puis commenter ou supprimer la ligne $dolibarr_pdf_force_fpdf=1, et ajouter à la place $dolibarr_lib_TCPDF_PATH='chemin_vers_TCPDF' LocalTaxDesc=Certains pays appliquent 2 voire 3 taux sur chaque ligne de facture. Si c'est le cas, choisissez le type du deuxième et troisième taux et sa valeur. Les types possibles sont:
1 : taxe locale sur les produits et services hors tva (la tva n'est pas appliquée sur la taxe locale)
2 : taxe locale sur les produits et services avant tva (la tva est appliquée sur le montant + la taxe locale)
3 : taxe locale uniquement sur les produits hors tva (la tva n'est pas appliquée sur la taxe locale)
4 : taxe locale uniquement sur les produits avant tva (la tva est appliquée sur le montant + la taxe locale)
5 : taxe locale uniquement sur les services hors tva (la tva n'est pas appliquée sur la taxe locale)
6 : taxe locale uniquement sur les service avant tva (la tva est appliquée sur le montant + la taxe locale) From b171975d186d44ce0124bded8eedb825e2657997 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 18 Jan 2015 16:08:10 +0100 Subject: [PATCH 117/152] Fix travis --- htdocs/compta/facture/class/facture.class.php | 15 +++++++++------ htdocs/core/class/html.form.class.php | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3388bbdbfe7..c6558247215 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2335,8 +2335,12 @@ class Facture extends CommonInvoice } /** + * Update_percent + * * @param FactureLigne $line Invoice line * @param int $percent + * + * @return void */ function update_percent($line, $percent) { @@ -2545,9 +2549,9 @@ class Facture extends CommonInvoice /** - * Return amount (with tax) of all credit notes and deposits invoices used by invoice + * Return amount (with tax) of all credit notes and deposits invoices used by invoice * - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ function getSumCreditNotesUsed() { @@ -2567,9 +2571,9 @@ class Facture extends CommonInvoice } /** - * Return amount (with tax) of all deposits invoices used by invoice + * Return amount (with tax) of all deposits invoices used by invoice * - * @return int <0 if KO, Sum of deposits amount otherwise + * @return int <0 if KO, Sum of deposits amount otherwise */ function getSumDepositsUsed() { @@ -3460,6 +3464,7 @@ class Facture extends CommonInvoice /** * Returns an array containing the previous situations as Facture objects * + * @return array array of prev_sits */ function get_prev_sits() { @@ -3514,7 +3519,6 @@ class Facture extends CommonInvoice * @return int 0 or 1 if OK, -1 if error * */ - function is_last_in_cycle() { $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; @@ -4096,7 +4100,6 @@ class FactureLigne extends CommonInvoiceLine * * @return int >= 0 */ - function get_prev_progress() { if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c4b025878c5..72220f0a4e0 100755 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2666,7 +2666,7 @@ class Form * * @return string HTML select */ - function load_situation_invoices($selected = '', $socid) + function load_situation_invoices($selected = '', $socid=null) { global $langs; From 0b18ce5fc413944a97913eefa6321dd2c478ae85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 18 Jan 2015 16:16:46 +0100 Subject: [PATCH 118/152] PHPDoc + missing return statements --- htdocs/adherents/class/adherent.class.php | 10 +++++++--- htdocs/adherents/class/adherent_type.class.php | 10 +++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 8c8c2d604ca..8b1a456ee79 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -45,7 +45,10 @@ class Adherent extends CommonObject var $mesgs; var $id; + var $ref; + public $ref_ext; + var $civility_id; var $firstname; var $lastname; @@ -107,6 +110,7 @@ class Adherent extends CommonObject var $oldcopy; // To contains a clone of this when we need to save old properties of object + public $entity; /** * Constructor @@ -1237,7 +1241,7 @@ class Adherent extends CommonObject /** * Insert subscription into database and eventually add links to banks, mailman, etc... * - * @param timestamp $date Date of effect of subscription + * @param int $date Date of effect of subscription * @param double $montant Amount of subscription (0 accepted for some members) * @param int $accountid Id bank account * @param string $operation Type operation (if Id bank account provided) @@ -1245,7 +1249,7 @@ class Adherent extends CommonObject * @param string $num_chq Numero cheque (if Id bank account provided) * @param string $emetteur_nom Name of cheque writer * @param string $emetteur_banque Name of bank of cheque - * @param timestamp $datesubend Date end subscription + * @param int $datesubend Date end subscription * @return int rowid of record added, <0 if KO */ function cotisation($date, $montant, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0) @@ -1601,7 +1605,7 @@ class Adherent extends CommonObject * * @param int $statut Id statut * @param int $need_subscription 1 si type adherent avec cotisation, 0 sinon - * @param timestamp $date_end_subscription Date fin adhesion + * @param int $date_end_subscription Date fin adhesion * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 2d5f3d835be..5c340de1fdf 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -60,7 +60,7 @@ class AdherentType extends CommonObject * Fonction qui permet de creer le status de l'adherent * * @param User $user User making creation - * @return >0 if OK, < 0 if KO + * @return int >0 if OK, < 0 if KO */ function create($user) { @@ -248,13 +248,13 @@ class AdherentType extends CommonObject $i++; } } - return $projets; } else { print $this->db->error(); } + return $projets; } @@ -287,7 +287,7 @@ class AdherentType extends CommonObject /** * getMailOnValid * - * @return Return mail model + * @return string Return mail model */ function getMailOnValid() { @@ -306,7 +306,7 @@ class AdherentType extends CommonObject /** * getMailOnSubscription * - * @return Return mail model + * @return string Return mail model */ function getMailOnSubscription() { @@ -325,7 +325,7 @@ class AdherentType extends CommonObject /** * getMailOnResiliate * - * @return Return mail model + * @return string Return mail model */ function getMailOnResiliate() { From d6778b9ed60a4c0ad286cdb22f2c76afe77e3b38 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 18 Jan 2015 16:25:43 +0100 Subject: [PATCH 119/152] fix travis --- htdocs/compta/facture/class/facture.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c6558247215..58720101874 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2338,7 +2338,7 @@ class Facture extends CommonInvoice * Update_percent * * @param FactureLigne $line Invoice line - * @param int $percent + * @param int $percent percent * * @return void */ @@ -3455,6 +3455,7 @@ class Facture extends CommonInvoice /** * Checks if the invoice is the first of a cycle * + * @return boolean ($this->situation_counter == 1) */ function is_first() { From fb186d6ef8a403b49a0bdefccc68ee1c27534180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 18 Jan 2015 16:26:26 +0100 Subject: [PATCH 120/152] Added delay between mails in Newsletter module --- ChangeLog | 1 + htdocs/admin/mailing.php | 9 +++++++++ htdocs/comm/mailing/card.php | 5 ++++- htdocs/langs/en_US/admin.lang | 1 + scripts/emailings/mailing-send.php | 5 +++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6691ddb2007..06f01bc0e11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ For users: MARGIN_PMP_AS_DEFAULT_BUY_PRICE to replace with first supplier price. - Introduce option MAIN_HTML_TITLE to start to control format of html title content. - Add extrafields on bank account cards. +- Added delay between mails in Newsletter module For translators: - Update language files. diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 22a6531fad6..8c080999e6c 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -48,11 +48,14 @@ if ($action == 'setvalue') $mailerror = GETPOST('MAILING_EMAIL_ERRORSTO','alpha'); $checkread = GETPOST('value','alpha'); $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha'); + $mailingdelay = GETPOST('MAILING_DELAY', 'int'); $res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; $res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; + $res=dolibarr_set_const($db, "MAILING_DELAY",$mailingdelay,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; // Create temporary encryption key if nedded $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY",$checkread_key,'chaine',0,'',$conf->entity); @@ -124,6 +127,12 @@ print ''; +$var=!$var; +print ''; +print $langs->trans("MailingDelay").''; +print ''; +print ''; + // Constant to add salt into the unsubscribe and check read tag. // It is also used as a security key parameter. $var=!$var; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index ca4c27bfdbc..821fadb94c9 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -323,7 +323,10 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes') } } - + if (!empty($conf->global->MAILING_DELAY)) { + sleep($conf->global->MAILING_DELAY); + } + //test if CHECK READ change statut prospect contact } else diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0b328e705a7..03180d37b69 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1393,6 +1393,7 @@ RSSUrlExample=An interesting RSS feed MailingSetup=EMailing module setup MailingEMailFrom=Sender EMail (From) for emails sent by emailing module MailingEMailError=Return EMail (Errors-to) for emails with errors +MailingDelay=Seconds to wait after sending next message ##### Notification ##### NotificationSetup=EMail notification module setup NotificationEMailFrom=Sender EMail (From) for emails sent for notifications diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 1de66b491ed..e7b32b2d3bc 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -245,6 +245,11 @@ if ($resql) $error++; } } + + if (!empty($conf->global->MAILING_DELAY)) { + sleep($conf->global->MAILING_DELAY); + } + } } else From 55b8c28100f9398963c09ff1418ad88b973b1b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 18 Jan 2015 16:28:42 +0100 Subject: [PATCH 121/152] Corrected weird typo --- htdocs/core/class/html.formfile.class.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 34f6418de34..4f1de4cfbb0 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -307,10 +307,6 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/core/modules/societe/modules_societe.class.php'; $modellist=ModeleThirdPartyDoc::liste_modeles($this->db); } - } - else if ($modulepart == 'agenda') - { - null; } else if ($modulepart == 'propal') { @@ -442,7 +438,7 @@ class FormFile { $modellist=''; } - else + else if ($modulepart != 'agenda') { // For normalized standard modules $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); From e872c40cc7a94e978a02fa1fd9df6995a52d35c9 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 18 Jan 2015 16:44:53 +0100 Subject: [PATCH 122/152] fix class actioncomm for travis and feature userassigned --- htdocs/comm/action/class/actioncomm.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b58123578dd..31cad75cffd 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -144,13 +144,12 @@ class ActionComm extends CommonObject $this->userassigned=array(); $this->userassigned[$tmpid]=array('id'=>$tmpid); } - $userownerid=$this->userownerid; $userdoneid=$this->userdoneid; // Be sure assigned user array is not empty. - if (count($this->userassigned) == 0) $this->userassigned = array('id'=>$userownerid); - + if (count($this->userassigned) == 0) $this->userassigned[] = array('id'=>$userownerid); + if (! $this->type_id || ! $this->type_code) { $key=empty($this->type_id)?$this->type_code:$this->type_id; From 1dd76e2ec0b54e8ceb8cb76b93285b70755ab258 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 19:15:23 +0100 Subject: [PATCH 123/152] Avoid request if possible --- htdocs/societe/class/societe.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 430d929320f..3dadf8b4eaf 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1999,6 +1999,8 @@ class Societe extends CommonObject { $contact_property=''; + if (empty($rowid)) return ''; + $sql = "SELECT rowid, email, phone_mobile, lastname, firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; $sql.= " WHERE rowid = '".$rowid."'"; From 28148f8637a948a635cf79370f2656db31112539 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 20:49:57 +0100 Subject: [PATCH 124/152] Fixed: Bad sql requests --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index d5ac52fd4aa..f9e00505f0a 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -47,11 +47,11 @@ ALTER TABLE llx_product_fournisseur_price ADD fk_price_expression integer DEFAUL insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 2131, 213, '5', '0', 'VAT 5%', 1); -- Add situation invoices -ALTER TABLE llx_facture ADD situation_cycle_ref integer; -ALTER TABLE llx_facture ADD situation_counter integer; -ALTER TABLE llx_facture ADD situation_final integer; -ALTER TABLE llx_facturedet ADD situation_percent real; -ALTER TABLE llx_facturedet ADD fk_prev_id integer; +ALTER TABLE llx_facture ADD COLUMN situation_cycle_ref integer; +ALTER TABLE llx_facture ADD COLUMN situation_counter integer; +ALTER TABLE llx_facture ADD COLUMN situation_final integer; +ALTER TABLE llx_facturedet ADD COLUMN situation_percent real; +ALTER TABLE llx_facturedet ADD COLUMN fk_prev_id integer; -- Convert SMTP config to main entity, so new entities don't get the old values UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SENDMODE"; From f96fdc7d0a2838f1dc0ac7aaf592a23b6e5030ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 21:04:39 +0100 Subject: [PATCH 125/152] Regression solved --- htdocs/compta/facture/class/facture.class.php | 4 +-- htdocs/core/lib/price.lib.php | 4 ++- test/phpunit/PricesTest.php | 30 +++++++++---------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 278d8ca70e4..f28f4bdd348 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2027,7 +2027,7 @@ class Facture extends CommonInvoice * @param int $fk_prev_id Previous situation line id reference * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=0, $fk_prev_id='') + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=100, $fk_prev_id='') { global $mysoc, $conf, $langs; @@ -2336,7 +2336,7 @@ class Facture extends CommonInvoice /** * Update invoice line with percentage - * + * * @param FactureLigne $line Invoice line * @param int $percent Percentage * @return void diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index aa3a1e11a46..aac29ad5256 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -49,7 +49,7 @@ * @param int $type 0/1=Product/service * @param Societe $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc. * @param array $localtaxes_array Array with localtaxes info (loaded by getLocalTaxesFromRate function). - * @param float $progress Situation invoices progress + * @param float $progress Situation invoices progress (value from 0 to 100, 100 by default) * @return result[ 0=total_ht, * 1=total_vat, * 2=total_ttc, @@ -97,6 +97,8 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; + dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress); + // Now we search localtaxes information ourself (rates and types). $localtax1_type=0; $localtax2_type=0; diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index c01a3701177..9b46f8cc1d6 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -1,20 +1,20 @@ * -* 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. -* + * 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 . * or see http://www.gnu.org/ -*/ + */ /** * \file test/phpunit/PricesTest.php @@ -215,9 +215,9 @@ class PricesTest extends PHPUnit_Framework_TestCase $newlocalobject=new Facture($this->savdb); $newlocalobject->fetch($invoiceid); - $this->assertEquals(2.48,$newlocalobject->total_ht); - $this->assertEquals(0.24,$newlocalobject->total_tva); - $this->assertEquals(2.72,$newlocalobject->total_ttc); + $this->assertEquals(2.48,$newlocalobject->total_ht, "testUpdatePrice test1"); + $this->assertEquals(0.24,$newlocalobject->total_tva, "testUpdatePrice test2"); + $this->assertEquals(2.72,$newlocalobject->total_ttc, "testUpdatePrice test3"); // Two lines of 1.24 give 2.48 HT and 2.73 TTC with global vat rounding mode @@ -231,7 +231,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $newlocalobject=new Facture($this->savdb); $newlocalobject->fetch($invoiceid); - $this->assertEquals(2.48,$newlocalobject->total_ht); + $this->assertEquals(2.48,$newlocalobject->total_ht, "testUpdatePrice test4"); //$this->assertEquals(0.25,$newlocalobject->total_tva); //$this->assertEquals(2.73,$newlocalobject->total_ttc); } From 69bb4b7b0bbf826de823a711bb99e2d799663a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 18 Jan 2015 23:00:26 +0100 Subject: [PATCH 126/152] Use account defined in invoice for pdf doc --- htdocs/compta/facture.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index d64a849e663..c4ea066f801 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1577,8 +1577,11 @@ if (empty($reshook)) // Save last template used to generate document if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha')); - if (GETPOST('fk_bank')) // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank'); + if (GETPOST('fk_bank')) { // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank'); + } else { + $object->fk_bank = $object->fk_account; + } // Define output language $outputlangs = $langs; From 47baf232d4b94b3d793d4a533f7971337dcbe05e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 23:02:53 +0100 Subject: [PATCH 127/152] Fix: A method must not change value of original property. --- htdocs/compta/facture/class/facture.class.php | 39 +++++++------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f28f4bdd348..1b9f08414c1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -202,17 +202,6 @@ class Facture extends CommonInvoice if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; - if (empty($this->situation_cycle_ref)) { - $this->situation_cycle_ref = 'null'; - } - - if (empty($this->situation_counter)) { - $this->situation_counter = 'null'; - } - - if (empty($this->situation_final)) { - $this->situation_final = '0'; - } dol_syslog(get_class($this)."::create user=".$user->id); @@ -290,23 +279,23 @@ class Facture extends CommonInvoice $sql.= ", '".$this->type."'"; $sql.= ", '".$socid."'"; $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL'); - $sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL'); + $sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL'); + $sql.= ", ".($this->remise_percent>0?$this->remise_percent:'NULL'); $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ",".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ",".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ",".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); - $sql.= ",".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); + $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); + $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); + $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); + $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); - $sql.= ",".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); - $sql.= ",".($user->id > 0 ? "'".$user->id."'":"null"); - $sql.= ",".($this->fk_project?$this->fk_project:"null"); - $sql.= ','.$this->cond_reglement_id; - $sql.= ",".$this->mode_reglement_id; + $sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); + $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); + $sql.= ", ".($this->fk_project?$this->fk_project:"null"); + $sql.= ", ".$this->cond_reglement_id; + $sql.= ", ".$this->mode_reglement_id; $sql.= ", '".$this->db->idate($datelim)."', '".$this->modelpdf."'"; - $sql.= ", ".$this->situation_cycle_ref; - $sql.= ", ".$this->situation_counter; - $sql.= ", ".$this->situation_final; + $sql.= ", ".$this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"; + $sql.= ", ".$this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"; + $sql.= ", ".$this->situation_final?$this->situation_final:0; $sql.=")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); From 35546245379cfdc229e6b9baa298999c90289b25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jan 2015 23:32:13 +0100 Subject: [PATCH 128/152] Fix: A method must not change value of original property. --- htdocs/compta/facture/class/facture.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1b9f08414c1..a1fe6ee1c4d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -293,9 +293,9 @@ class Facture extends CommonInvoice $sql.= ", ".$this->cond_reglement_id; $sql.= ", ".$this->mode_reglement_id; $sql.= ", '".$this->db->idate($datelim)."', '".$this->modelpdf."'"; - $sql.= ", ".$this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"; - $sql.= ", ".$this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"; - $sql.= ", ".$this->situation_final?$this->situation_final:0; + $sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"); + $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); + $sql.= ", ".($this->situation_final?$this->situation_final:0); $sql.=")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); From fdaa930507ff78011d990fa8e0f1f94422ac0a26 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Jan 2015 01:58:48 +0100 Subject: [PATCH 129/152] Solve phpunit. Fix database field format --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 6 +++--- htdocs/install/mysql/tables/llx_facture.sql | 6 +++--- test/phpunit/FactureTest.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index f9e00505f0a..13f367c51fa 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -47,9 +47,9 @@ ALTER TABLE llx_product_fournisseur_price ADD fk_price_expression integer DEFAUL insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 2131, 213, '5', '0', 'VAT 5%', 1); -- Add situation invoices -ALTER TABLE llx_facture ADD COLUMN situation_cycle_ref integer; -ALTER TABLE llx_facture ADD COLUMN situation_counter integer; -ALTER TABLE llx_facture ADD COLUMN situation_final integer; +ALTER TABLE llx_facture ADD COLUMN situation_cycle_ref smallint; +ALTER TABLE llx_facture ADD COLUMN situation_counter smallint; +ALTER TABLE llx_facture ADD COLUMN situation_final smallint; ALTER TABLE llx_facturedet ADD COLUMN situation_percent real; ALTER TABLE llx_facturedet ADD COLUMN fk_prev_id integer; diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 144cd349dd6..eada5b46c2e 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -78,8 +78,8 @@ create table llx_facture import_key varchar(14), extraparams varchar(255), -- for stock other parameters with json format - situation_cycle_ref smallint UNSIGNED, -- situation cycle reference - situation_counter tinyint UNSIGNED, -- situation counter - situation_final boolean -- is the situation final ? + situation_cycle_ref smallint, -- situation cycle reference + situation_counter smallint, -- situation counter + situation_final smallint -- is the situation final ? )ENGINE=innodb; diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index c68014e9606..3248be7104c 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -216,7 +216,7 @@ class FactureTest extends PHPUnit_Framework_TestCase $newlocalobject=new Facture($this->savdb); $newlocalobject->initAsSpecimen(); $this->changeProperties($newlocalobject); - $this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc')), array()); // Actual, Expected + $this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final')), array()); // Actual, Expected return $localobject; } From 667565f04fd2c19d10eca7263613289b6d06bf12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Jan 2015 02:38:24 +0100 Subject: [PATCH 130/152] Fix missing table in migration script --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 13f367c51fa..cb70f85a32c 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -59,4 +59,14 @@ UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTP_PORT UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTP_SERVER"; UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTPS_ID"; UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_SMTPS_PW"; -UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_EMAIL_TLS"; \ No newline at end of file +UPDATE llx_const SET entity = 1 WHERE entity = 0 AND name = "MAIN_MAIL_EMAIL_TLS"; + + +create table llx_bank_account_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + From a4561ab4ad8c388774f7d8dce9d7ddbd6ce06359 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 19 Jan 2015 09:41:31 +0100 Subject: [PATCH 131/152] merge --- htdocs/comm/action/class/actioncomm.class.php | 5 +- htdocs/compta/facture/class/facture.class.php | 91 ++++++++++--------- 2 files changed, 49 insertions(+), 47 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 0934e42db1f..7c828f4fa59 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -151,13 +151,14 @@ class ActionComm extends CommonObject $this->userassigned=array(); $this->userassigned[$tmpid]=array('id'=>$tmpid); } + $userownerid=$this->userownerid; $userdoneid=$this->userdoneid; // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned)) $this->userassigned = array($userownerid=>array('id'=>$userownerid)); - + if (! $this->type_id || ! $this->type_code) { $key=empty($this->type_id)?$this->type_code:$this->type_id; @@ -243,7 +244,7 @@ class ActionComm extends CommonObject { foreach($this->userassigned as $key => $val) { - if (! is_array($val)) // For backward compatibility when valid + if (! is_array($val)) // For backward compatibility when val=id { $tmpid=$val; $val=array('id'=>$val); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0a1f3118c77..a1fe6ee1c4d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -279,17 +279,17 @@ class Facture extends CommonInvoice $sql.= ", '".$this->type."'"; $sql.= ", '".$socid."'"; $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL'); - $sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL'); + $sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL'); + $sql.= ", ".($this->remise_percent>0?$this->remise_percent:'NULL'); $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ",".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ",".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ",".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); - $sql.= ",".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); + $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); + $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); + $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); + $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); - $sql.= ",".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); - $sql.= ",".($user->id > 0 ? "'".$user->id."'":"null"); - $sql.= ",".($this->fk_project?$this->fk_project:"null"); + $sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); + $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); + $sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".$this->cond_reglement_id; $sql.= ", ".$this->mode_reglement_id; $sql.= ", '".$this->db->idate($datelim)."', '".$this->modelpdf."'"; @@ -2537,9 +2537,9 @@ class Facture extends CommonInvoice /** - * Return amount (with tax) of all credit notes and deposits invoices used by invoice + * Return amount (with tax) of all credit notes and deposits invoices used by invoice * - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ function getSumCreditNotesUsed() { @@ -2559,9 +2559,9 @@ class Facture extends CommonInvoice } /** - * Return amount (with tax) of all deposits invoices used by invoice + * Return amount (with tax) of all deposits invoices used by invoice * - * @return int <0 if KO, Sum of deposits amount otherwise + * @return int <0 if KO, Sum of deposits amount otherwise */ function getSumDepositsUsed() { @@ -2600,52 +2600,53 @@ class Facture extends CommonInvoice if (! empty($conf->global->FACTURE_ADDON)) { - $mybool=false; + $mybool=false; - $file = $conf->global->FACTURE_ADDON.".php"; - $classname = $conf->global->FACTURE_ADDON; - // Include file with class + $file = $conf->global->FACTURE_ADDON.".php"; + $classname = $conf->global->FACTURE_ADDON; + + // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/facture/"); - // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; - } - - // For compatibility - if (! $mybool) - { - $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; - $classname = "mod_facture_".$conf->global->FACTURE_ADDON; - $classname = preg_replace('/\-.*$/','',$classname); - // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/facture/"; // Load file with numbering class (if found) $mybool|=@include_once $dir.$file; } - } - if (! $mybool) - { - dol_print_error('',"Failed to include file ".$file); - return ''; - } + // For compatibility + if (! $mybool) + { + $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; + $classname = "mod_facture_".$conf->global->FACTURE_ADDON; + $classname = preg_replace('/\-.*$/','',$classname); + // Include file with class + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot."/core/modules/facture/"; + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + } - $obj = new $classname(); - $numref = ""; + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } + + $obj = new $classname(); + $numref = ""; $numref = $obj->getNextValue($soc,$this,$mode); - if ($numref != "") - { - return $numref; - } - else - { + if ($numref != "") + { + return $numref; + } + else + { dol_print_error($db,"Facture::getNextNumRef ".$obj->error); return ""; } From 388697b73eeae0ee4685eddc83ff98c25cd58240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Jan 2015 18:55:55 +0100 Subject: [PATCH 132/152] Use getNomUrl on every list to uniformize display --- htdocs/comm/card.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index a775408e9a8..42478175dfa 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -531,11 +531,13 @@ if ($id > 0) $objp = $db->fetch_object($resql); $var=!$var; print ""; - print ''.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.''."\n"; - if ( ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 ) - { - print " ".img_warning(); - } + print ''; + $propal_static->id=$objp->propalid; + $propal_static->ref=$objp->ref; + print $propal_static->getNomUrl(1); + if ( ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 ) { + print " ".img_warning(); + } print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; print ''.price($objp->total_ht).''; print ''.$propal_static->LibStatut($objp->fk_statut,5).''; @@ -606,7 +608,10 @@ if ($id > 0) $objp = $db->fetch_object($resql); $var=!$var; print ""; - print ''.img_object($langs->trans("ShowOrder"),"order").' '.$objp->ref."\n"; + print ''; + $commande_static->id=$objp->cid; + $commande_static->ref=$objp->ref; + print $commande_static->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->dc),'day')."\n"; print ''.price($objp->total_ht).''; print ''.$commande_static->LibStatut($objp->fk_statut,$objp->facture,5).''; From e82301e001a3014204a7f32e798bfb29428dcd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Jan 2015 19:07:34 +0100 Subject: [PATCH 133/152] Update card.php --- htdocs/fourn/card.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 205d1a89ea6..154800125bf 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -367,7 +367,11 @@ if ($object->id > 0) $var=!$var; print ""; - print ''.img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref.''; + print ''; + $orderstatic->id=$obj->rowid; + $orderstatic->ref=$obj->ref; + print $orderstatic->getNomUrl(1); + print ''; print ''; if ($obj->dc) { From 1fc9517200ad6f69414478ff05ba6df967deeae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Jan 2015 19:18:57 +0100 Subject: [PATCH 134/152] Use css badge --- htdocs/fourn/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 205d1a89ea6..192bdff9abb 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -299,7 +299,7 @@ if ($object->id > 0) print ''; print ''; print '
'.$langs->trans("ProductsAndServices").''; - print ''.$langs->trans("All").' ('.$object->nbOfProductRefs().')'; + print ''.$langs->trans("All").' '.$object->nbOfProductRefs().''; print '
'; } @@ -355,7 +355,7 @@ if ($object->id > 0) print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("LastOrders",($num<$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' ('.$num.')'.$langs->trans("AllOrders").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; print ''; @@ -422,7 +422,7 @@ if ($object->id > 0) print ''; print ''; - print ''; + print '
'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans('AllBills').' ('.$num.')
'; print ''; print '
'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans('AllBills').' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; print ''; From 2d911e1a8f2897e1e34900458616b772b7dd41f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Jan 2015 20:19:36 +0100 Subject: [PATCH 135/152] Update card.php --- htdocs/comm/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index a775408e9a8..b0ae3beef6b 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -519,7 +519,7 @@ if ($id > 0) print ''; print ''; - print '
'; + print ''; print ''; @@ -592,7 +592,7 @@ if ($id > 0) print '
'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' ('.$num.')'; print ''; print '
'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; print ''; - print '
'; + print ''; print ''; } $i = 0; @@ -706,7 +706,7 @@ if ($id > 0) print '
'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' ('.$num.')'; print ''; //if($num2 > 0) print ''; //else print ''; @@ -647,7 +647,7 @@ if ($id > 0) print ''; print ''; + print '
'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').''.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').''.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'
'; - print '
'.$langs->trans("LastContracts",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllContracts").' ('.$num.')
'.$langs->trans("AllContracts").' '.$num.'
'; print ''; - print ''; + print ''; print ''; $var=!$var; } @@ -769,7 +769,7 @@ if ($id > 0) $tableaushown=1; print ''; - print '
'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllInterventions").' ('.$num.')
'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllInterventions").' '.$num.'
'; + print ''; print ''; From 0a41a025aed155dfeaa94e83b78f348346f79925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Jan 2015 20:35:29 +0100 Subject: [PATCH 136/152] Update index.php --- htdocs/commande/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 0d2815a6d67..40b39ccb666 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -303,7 +303,7 @@ if (! empty($conf->commande->enabled)) print '
'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' ('.$num.')'; print ''; print '
'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; print ''; - print ''; + print ''; if ($num) { @@ -374,7 +374,7 @@ if (! empty($conf->commande->enabled)) print '
'.$langs->trans("OrdersToProcess").' ('.$num.')
'.$langs->trans("OrdersToProcess").' '.$num.'
'; print ''; - print ''; + print ''; if ($num) { From fb9f53010fc08af62a64f03f29996dc4f9052288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Jan 2015 20:36:38 +0100 Subject: [PATCH 137/152] Update index.php --- htdocs/fourn/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 9da28281779..29f12fed38f 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -126,7 +126,7 @@ if (! empty($conf->fournisseur->enabled)) { print '
'.$langs->trans("OnProcessOrders").' ('.$num.')
'.$langs->trans("OnProcessOrders").' '.$num.'
'; print ''; - print ''; + print ''; $i = 0; $var = true; @@ -183,7 +183,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { print '
'.$langs->trans("DraftOrders").' ('.$num.')
'.$langs->trans("DraftOrders").' '.$num.'
'; print ''; - print ''; + print ''; $i = 0; $tot_ttc = 0; $var = True; From 229f7888caac4b93638db34f8b2cff03bcc99f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Jan 2015 20:38:33 +0100 Subject: [PATCH 138/152] Update index.php --- htdocs/comm/propal/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index de51cf63104..a0e8a3409ab 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -313,7 +313,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $var=true; print '
'.$langs->trans("DraftBills").' ('.$num.')
'.$langs->trans("DraftBills").' '.$num.'
'; - print ''; + print ''; $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) @@ -399,7 +399,7 @@ if (! empty($conf->propal->enabled)) print '
'.$langs->trans("ProposalsOpened").' ('.$num.')
'.$langs->trans("ProposalsOpened").' '.$num.'
'; print ''; - print ''; + print ''; if ($num) { @@ -471,7 +471,7 @@ if (! empty($conf->propal->enabled)) print '
'.$langs->trans("ProposalsToProcess").' ('.$num.')
'.$langs->trans("ProposalsToProcess").' '.$num.'
'; print ''; - print ''; + print ''; if ($num) { From 5ec0b32ab0625f2dd7e603da75249c8233b79b16 Mon Sep 17 00:00:00 2001 From: jean Date: Tue, 20 Jan 2015 17:26:32 +0100 Subject: [PATCH 139/152] add left joins on llx_c_actiocomm --- htdocs/core/lib/company.lib.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 0851fb0b7c1..7fbac977d79 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -937,9 +937,10 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) $sql.= " u.login, u.rowid"; if (get_class($object) == 'Adherent') $sql.= ", m.lastname, m.firstname"; if (get_class($object) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; if (get_class($object) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; if (get_class($object) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id "; $sql.= " WHERE u.rowid = a.fk_user_author"; $sql.= " AND a.entity IN (".getEntity('agenda', 1).")"; if (get_class($object) == 'Adherent') { @@ -949,7 +950,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) } if (get_class($object) == 'Societe' && $object->id) $sql.= " AND a.fk_soc = ".$object->id; if (! empty($objcon->id)) $sql.= " AND a.fk_contact = ".$objcon->id; - $sql.= " AND c.id=a.fk_action"; + // $sql.= " AND c.id=a.fk_action"; $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; $sql.= " ORDER BY a.datep DESC, a.id DESC"; @@ -1076,16 +1077,17 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) $sql.= " u.login, u.rowid as user_id"; if (get_class($object) == 'Adherent') $sql.= ", m.lastname, m.firstname"; if (get_class($object) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; if (get_class($object) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; if (get_class($object) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id "; $sql.= " WHERE u.rowid = a.fk_user_author"; $sql.= " AND a.entity IN (".getEntity('agenda', 1).")"; if (get_class($object) == 'Adherent') $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; if (get_class($object) == 'Adherent' && $object->id) $sql.= " AND a.fk_element = ".$object->id; if (get_class($object) == 'Societe' && $object->id) $sql.= " AND a.fk_soc = ".$object->id; if (is_object($objcon) && $objcon->id) $sql.= " AND a.fk_contact = ".$objcon->id; - $sql.= " AND c.id=a.fk_action"; + // $sql.= " AND c.id=a.fk_action"; $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; $sql.= " ORDER BY a.datep DESC, a.id DESC"; From 3ab6ac601eb6ff3b6a1a7dcf713c3810a63ed29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Jan 2015 17:55:20 +0100 Subject: [PATCH 140/152] Type of supplier invoice was broken --- htdocs/core/class/commoninvoice.class.php | 42 +++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 991601a4fbd..6087a5a0adb 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -30,6 +30,36 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ abstract class CommonInvoice extends CommonObject { + /** + * Standard invoice + */ + const TYPE_STANDARD = 0; + + /** + * Replacement invoice + */ + const TYPE_REPLACEMENT = 1; + + /** + * Credit note invoice + */ + const TYPE_CREDIT_NOTE = 2; + + /** + * Deposit invoice + */ + const TYPE_DEPOSIT = 3; + + /** + * Proforma invoice + */ + const TYPE_PROFORMA = 4; + + /** + * Situation invoice + */ + const TYPE_SITUATION = 5; + /** * Return amount of payments already done * @@ -145,12 +175,12 @@ abstract class CommonInvoice extends CommonObject function getLibType() { global $langs; - if ($this->type == Facture::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); - if ($this->type == Facture::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); - if ($this->type == Facture::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); - if ($this->type == Facture::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); - if ($this->type == Facture::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); - if ($this->type == Facture::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); + if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); + if ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); + if ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); + if ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); + if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); + if ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); return $langs->trans("Unknown"); } From 1b0dd671b392833e15006d9310eaf00e085d9d3c Mon Sep 17 00:00:00 2001 From: frederic34 Date: Tue, 20 Jan 2015 20:45:38 +0100 Subject: [PATCH 141/152] Add tooltip in getNomUrl link --- htdocs/adherents/class/adherent.class.php | 9 ++-- .../adherents/class/adherent_type.class.php | 4 +- htdocs/adherents/class/cotisation.class.php | 4 +- htdocs/categories/class/categorie.class.php | 4 +- htdocs/comm/action/class/actioncomm.class.php | 7 ++-- htdocs/comm/propal/class/propal.class.php | 30 ++++++------- htdocs/commande/class/commande.class.php | 6 +-- htdocs/compta/bank/class/account.class.php | 11 ++--- .../deplacement/class/deplacement.class.php | 4 +- htdocs/compta/dons/class/don.class.php | 4 +- .../facture/class/facture-rec.class.php | 4 +- htdocs/compta/facture/class/facture.class.php | 2 +- .../compta/localtax/class/localtax.class.php | 4 +- .../cheque/class/remisecheque.class.php | 5 ++- .../compta/paiement/class/paiement.class.php | 3 +- .../class/bonprelevement.class.php | 7 ++-- .../salaries/class/paymentsalary.class.php | 4 +- .../sociales/class/chargesociales.class.php | 5 ++- .../class/paymentsocialcontribution.class.php | 5 ++- htdocs/compta/tva/class/tva.class.php | 4 +- htdocs/contact/class/contact.class.php | 7 ++-- htdocs/contrat/class/contrat.class.php | 8 ++-- htdocs/core/class/discount.class.php | 8 ++-- htdocs/ecm/class/ecmdirectory.class.php | 15 +++---- htdocs/expedition/class/expedition.class.php | 4 +- htdocs/fichinter/class/fichinter.class.php | 4 +- .../class/fournisseur.commande.class.php | 4 +- .../fourn/class/fournisseur.facture.class.php | 8 ++-- htdocs/fourn/class/paiementfourn.class.php | 18 ++++---- htdocs/holiday/class/holiday.class.php | 5 +-- htdocs/livraison/class/livraison.class.php | 4 +- htdocs/product/class/product.class.php | 42 ++++++++----------- htdocs/product/stock/class/entrepot.class.php | 7 ++-- htdocs/projet/class/project.class.php | 23 +++++----- htdocs/projet/class/task.class.php | 4 +- htdocs/resource/class/resource.class.php | 4 +- htdocs/societe/class/address.class.php | 3 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/user/class/user.class.php | 8 ++-- 39 files changed, 153 insertions(+), 151 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index b7c65c3bbeb..7c65e1a5cb1 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1559,25 +1559,26 @@ class Adherent extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowMember").': '.$this->ref; + $linkclose = '" title="'.$label.'" class="classfortooltip">'; if ($option == 'card') { - $lien = ''; + $lien = ''; + $lien = ''; + $lien = 'trans("ShowTypeCard",$this->libelle); - $lien = ''; + $lien = ''; $lienfin=''; $picto='group'; - $label=$langs->trans("ShowTypeCard",$this->libelle); if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/adherents/class/cotisation.class.php b/htdocs/adherents/class/cotisation.class.php index 660be1f397a..48970abace4 100644 --- a/htdocs/adherents/class/cotisation.class.php +++ b/htdocs/adherents/class/cotisation.class.php @@ -264,12 +264,12 @@ class Cotisation extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowSubscription").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='payment'; - $label=$langs->trans("ShowSubscription"); if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 31b08437aef..7e29f6ccf38 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1274,9 +1274,9 @@ class Categorie extends CommonObject global $langs; $result=''; - - $lien = ''; $label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label); + + $lien = ''; $lienfin=''; $picto='category'; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 7c828f4fa59..25a9803e63e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -897,11 +897,12 @@ class ActionComm extends CommonObject global $conf,$langs; $result=''; - if ($option=='birthday') $lien = ''; - else $lien = ''; - $lienfin=''; $label=$this->label; if (empty($label)) $label=$this->libelle; // For backward compatibility + $linkclose = '" title="'.$label.'" class="classfortooltip">'; + if ($option=='birthday') $lien = ''; + $label=$langs->trans("ShowPropal").': '.$this->ref; + $linkclose = '" title="'.$label.'" class="classfortooltip">'; + if ($option == '') { + $lien = ''; + if ($option == 'compta') { // deprecated + $lien = ''; + if ($option == 'expedition') { + $lien = ''; + if ($option == 'document') { + $lien = 'ref; - if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); - if ($withpicto && $withpicto != 2) $result.=' '; + + if ($withpicto) + $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); + if ($withpicto && $withpicto != 2) + $result.=' '; $result.=$lien.$this->ref.$lienfin; return $result; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 8a7005c9fea..7e10a1e8da6 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2884,12 +2884,12 @@ class Commande extends CommonOrder if ($short) return $url; - $linkstart = ''; - $linkend=''; - $picto='order'; $label=$langs->trans("ShowOrder").': '.$this->ref; + $linkstart = ''; + $linkend=''; + if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result.=' '; $result.=$linkstart.$this->ref.$linkend; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 685daadc833..b2e3dc79f78 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -935,15 +935,16 @@ class Account extends CommonObject global $langs; $result=''; + $linkclose = '" title="'.$this->label.'" class="classfortooltip">'; if (empty($mode)) { - $lien = ''; + $lien = ''; + $lien = ''; + $label=$langs->trans("ShowTransaction").': '.$this->rowid; + $lien = ''; $lienfin=''; - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowTransaction"), 'account', 'class="classfortooltip"').$lienfin.' '); + if ($withpicto) $result.=($lien.img_object($label, 'account', 'class="classfortooltip"').$lienfin.' '); $result.=$lien.$this->rowid.$lienfin; if ($option == 'showall' || $option == 'showconciliated') $result.=' ('; diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index bb0e7d3506b..e7a3350f2f3 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -357,13 +357,13 @@ class Deplacement extends CommonObject global $langs; $result=''; + $label=$langs->trans("Show").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='trip'; - $label=$langs->trans("Show").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index 4d7c8931e31..c2f800f4a13 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -711,13 +711,13 @@ class Don extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowDonation").': '.$this->id; - $lien = ''; + $lien = ''; $lienfin=''; $picto='generic'; - $label=$langs->trans("ShowDonation").': '.$this->id; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 71634aaa3ad..1a8e22a14bc 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -558,13 +558,13 @@ class FactureRec extends Facture global $langs; $result=''; + $label=$langs->trans("ShowInvoice").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='bill'; - $label=$langs->trans("ShowInvoice").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a1fe6ee1c4d..03b927d28a3 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -865,7 +865,7 @@ class Facture extends CommonInvoice if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; if ($moretitle) $label.=' - '.$moretitle; - $linkstart=''; + $linkstart=''; $linkend=''; if ($withpicto) $result.=($linkstart.img_object(($max?dol_trunc($label,$max):$label), $picto, 'class="classfortooltip"').$linkend); diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 85da8e05476..e6c3c6e0942 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -585,12 +585,12 @@ class Localtax extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowVatPayment").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='payment'; - $label=$langs->trans("ShowVatPayment").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 9db0591ee33..a1d3c53052c 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -769,11 +769,12 @@ class RemiseCheque extends CommonObject global $langs; $result=''; + $label = $langs->trans("ShowCheckReceipt").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowCheckReceipt"), 'payment', 'class="classfortooltip"').$lienfin); + if ($withpicto) $result.=($lien.img_object($label, 'payment', 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index d2256926e1a..b303420dd15 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -748,8 +748,9 @@ class Paiement extends CommonObject global $langs; $result=''; + $label = $langs->trans("ShowPayment").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment"), 'payment', 'class="classfortooltip"').$lienfin); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index db4c436dfa6..3a30cf690d3 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1118,17 +1118,18 @@ class BonPrelevement extends CommonObject global $langs; $result=''; + $label = $langs->trans("ShowWithdraw").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; if ($option == 'xxx') { - $lien = ''; + $lien = ''; $lienfin=''; } - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowWithdraw"), 'payment', 'class="classfortooltip"').$lienfin.' '); + if ($withpicto) $result.=($lien.img_object($label, 'payment', 'class="classfortooltip"').$lienfin.' '); $result.=$lien.$this->ref.$lienfin; return $result; } diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 635ed77541f..1e2d437793c 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -486,12 +486,12 @@ class PaymentSalary extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowSalaryPayment").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='payment'; - $label=$langs->trans("ShowSalaryPayment").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 4e7211c75b1..d0fe9b11ea3 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -420,11 +420,12 @@ class ChargeSociales extends CommonObject $result=''; if (empty($this->ref)) $this->ref=$this->lib; + $label = $langs->trans("ShowSocialContribution").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowSocialContribution").': '.$this->lib, 'bill', 'class="classfortooltip"').$lienfin.' '); + if ($withpicto) $result.=($lien.img_object($label, 'bill', 'class="classfortooltip"').$lienfin.' '); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin; return $result; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index a94afc98f6e..55316e15b22 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -585,13 +585,14 @@ class PaymentSocialContribution extends CommonObject $result=''; if (empty($this->ref)) $this->ref=$this->lib; + $label = $langs->trans("ShowPayment").': '.$this->ref; if (!empty($this->id)) { - $lien = ''; + $lien = ''; $lienfin=''; - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment").': '.$this->ref, 'payment', 'class="classfortooltip"').$lienfin.' '); + if ($withpicto) $result.=($lien.img_object($label, 'payment', 'class="classfortooltip"').$lienfin.' '); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin; } diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 96db35f915b..4730d72e596 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -638,12 +638,12 @@ class Tva extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowVatPayment").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='payment'; - $label=$langs->trans("ShowVatPayment").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index cbc813968d1..40be02a3ef1 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -887,17 +887,18 @@ class Contact extends CommonObject global $langs; $result=''; + $label = $langs->trans("ShowContact").': '.$this->getFullName($langs); - $lien = ''; + $lien = ''; $lienfin=''; if ($option == 'xxx') { - $lien = ''; + $lien = ''; $lienfin=''; } - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowContact").': '.$this->getFullName($langs), 'contact', 'class="classfortooltip"').$lienfin.' '); + if ($withpicto) $result.=($lien.img_object($label, 'contact', 'class="classfortooltip"').$lienfin.' '); $result.=$lien.($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)).$lienfin; return $result; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 1417047b269..00dce5b3336 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1682,13 +1682,13 @@ class Contrat extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowContract").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='contract'; - $label=$langs->trans("ShowContract").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; @@ -2211,13 +2211,13 @@ class ContratLigne extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowContractOfService").': '.$this->label; - $lien = ''; + $lien = ''; $lienfin=''; $picto='contract'; - $label=$langs->trans("ShowContractOfService").': '.$this->label; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 98b1309149e..8861bf556ba 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -435,17 +435,17 @@ class DiscountAbsolute if ($option == 'invoice') { - $lien = ''; - $lienfin=''; $label=$langs->trans("ShowDiscount").': '.$this->ref_facture_source; + $lien = ''; + $lienfin=''; $ref=$this->ref_facture_source; $picto='bill'; } if ($option == 'discount') { - $lien = ''; - $lienfin=''; $label=$langs->trans("Discount"); + $lien = ''; + $lienfin=''; $ref=$langs->trans("Discount"); $picto='generic'; } diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index a4379250914..b4821dc2895 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -414,19 +414,20 @@ class EcmDirectory // extends CommonObject global $langs; $result=''; + //$newref=str_replace('_',' ',$this->ref); + $newref=$this->ref; + $newlabel=$langs->trans("ShowECMSection").': '.$newref; + $linkclose='"'.($more?' '.$more:'').' title="'.$newlabel.'" class="classfortooltip">'; - $lien = ''; - if ($option == 'index') $lien = ''; - if ($option == 'indexexpanded') $lien = ''; - if ($option == 'indexnotexpanded') $lien = ''; + $lien = 'ref); - $newref=$this->ref; - $newlabel=$langs->trans("ShowECMSection").': '.$newref; if ($withpicto) $result.=($lien.img_object($newlabel, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 74d5251a191..e0ce7ef9316 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1217,16 +1217,16 @@ class Expedition extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowSending").': '.$this->ref; $url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id; if ($short) return $url; - $linkstart = ''; + $linkstart = ''; $linkend=''; $picto='sending'; - $label=$langs->trans("ShowSending").': '.$this->ref; if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 0f91e976da8..eca71601e7d 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -547,13 +547,13 @@ class Fichinter extends CommonObject global $langs; $result=''; + $label=$langs->trans("Show").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='intervention'; - $label=$langs->trans("Show").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 77f131b912b..c2743a8e3ad 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -531,12 +531,12 @@ class CommandeFournisseur extends CommonOrder global $langs; $result=''; + $label=$langs->trans("ShowOrder").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='order'; - $label=$langs->trans("ShowOrder").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 7370bc3769a..5034204154a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1472,19 +1472,19 @@ class FactureFournisseur extends CommonInvoice global $langs; $result=''; + $label=$langs->trans("ShowInvoice").': '.$this->ref; + if ($this->ref_supplier) $label.=' / '.$this->ref_supplier; if ($option == 'document') { - $lien = ''; + $lien = ''; $lienfin=''; } else { - $lien = ''; + $lien = ''; $lienfin=''; } - $label=$langs->trans("ShowInvoice").': '.$this->ref; - if ($this->ref_supplier) $label.=' / '.$this->ref_supplier; $ref=$this->ref; if (empty($ref)) $ref=$this->id; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 443216d899d..3c3f9abba76 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -487,17 +487,17 @@ class PaiementFourn extends Paiement global $langs; $result=''; + $text=$this->ref; // Sometimes ref contains label + if (preg_match('/^\((.*)\)$/i',$text,$reg)) { + // Label generique car entre parentheses. On l'affiche en le traduisant + if ($reg[1]=='paiement') $reg[1]='Payment'; + $text=$langs->trans($reg[1]); + } + $label = $langs->trans("ShowPayment").': '.$text; - $lien = ''; - $lienfin=''; + $lien = ''; + $lienfin=''; - $text=$this->ref; // Sometimes ref contains label - if (preg_match('/^\((.*)\)$/i',$text,$reg)) - { - // Label g诩rique car entre parenth粥s. On l'affiche en le traduisant - if ($reg[1]=='paiement') $reg[1]='Payment'; - $text=$langs->trans($reg[1]); - } if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment"), 'payment', 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 1a3e9f7ecd3..43c074a5781 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -658,14 +658,13 @@ class Holiday extends CommonObject global $langs; $result=''; + $label=$langs->trans("Show").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='holiday'; - $label=$langs->trans("Show").': '.$this->ref; - if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index dfad1c7e7b8..2de166e4837 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -660,13 +660,13 @@ class Livraison extends CommonObject $result=''; $urlOption=''; + $label=$langs->trans("ShowReceiving").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='sending'; - $label=$langs->trans("ShowReceiving").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 294c8d1610e..a2b34eb2862 100755 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2812,33 +2812,27 @@ class Product extends CommonObject global $langs; $result=''; + $newref=$this->ref; + if ($maxlength) $newref=dol_trunc($newref,$maxlength,'middle'); + if ($this->type == 0) $label = $langs->trans("ShowProduct").': '.$this->ref.' '.$this->label; + if ($this->type == 1) $label = $langs->trans("ShowService").': '.$this->ref.' '.$this->label; + $linkclose = '" title="'.$label.'" class="classfortooltip">'; - if ($option == 'supplier') - { - $lien = ''; - $lienfin=''; - } - else if ($option == 'stock') - { - $lien = ''; + if ($option == 'supplier') { + $lien = ''; + } else if ($option == 'composition') { + $lien = ''; } - else if ($option == 'composition') - { - $lien = ''; - $lienfin=''; - } - else if ($option == 'category') - { - $lien = ''; - } - else - { - $lien = ''; - $lienfin=''; - } - $newref=$this->ref; - if ($maxlength) $newref=dol_trunc($newref,$maxlength,'middle'); if ($withpicto) { if ($this->type == 0) $result.=($lien.img_object($langs->trans("ShowProduct").' '.$this->label, 'product', 'class="classfortooltip"').$lienfin.' '); diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index c0627015be3..a04d1c02881 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -512,11 +512,12 @@ class Entrepot extends CommonObject global $langs; $result=''; + $label = $langs->trans("ShowStock").': '.$this->libelle; - $lien=''; - $lienfin=''; + $lien=''; + $lienfin=''; - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowStock"), 'stock', 'class="classfortooltip"').$lienfin.' '); + if ($withpicto) $result.=($lien.img_object($label, 'stock', 'class="classfortooltip"').$lienfin.' '); $result.=$lien.$this->libelle.$lienfin; return $result; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 4eef74b0dc1..88b71cecc19 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -789,25 +789,22 @@ class Project extends CommonObject $result = ''; $lien = ''; $lienfin = ''; + $label = $langs->trans("ShowProject") . ': ' . $this->ref . ($this->title ? ' - ' . $this->title : ''); + $linkclose = '" title="'.$label.'" class="classfortooltip">'; - if ($option != 'nolink') - { - if (preg_match('/\.php$/',$option)) - { - $lien = ''; - $lienfin = ''; - } - else - { - $lien = ''; - $lienfin = ''; - } + if ($option != 'nolink') { + if (preg_match('/\.php$/',$option)) { + $lien = ''; + } } $picto = 'projectpub'; if (!$this->public) $picto = 'project'; - $label = $langs->trans("ShowProject") . ': ' . $this->ref . ($this->title ? ' - ' . $this->title : ''); if ($withpicto) $result.=($lien . img_object($label, $picto, 'class="classfortooltip"') . $lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 786caafb7ec..497dabdc69f 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -505,13 +505,13 @@ class Task extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowTask").': '.$this->ref.($this->label?' - '.$this->label:''); - $lien = ''; + $lien = ''; $lienfin=''; $picto='projecttask'; - $label=$langs->trans("ShowTask").': '.$this->ref.($this->label?' - '.$this->label:''); if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/resource/class/resource.class.php b/htdocs/resource/class/resource.class.php index deea00f9c99..fec44b3e2b7 100644 --- a/htdocs/resource/class/resource.class.php +++ b/htdocs/resource/class/resource.class.php @@ -869,10 +869,11 @@ class Resource extends CommonObject global $langs; $result=''; + $label=$langs->trans("ShowResource").': '.$this->ref; if ($option == '') { - $lien = ''; + $lien = ''; $picto='resource@resource'; $label=$langs->trans("ShowResource").': '.$this->ref; @@ -880,7 +881,6 @@ class Resource extends CommonObject $lienfin=''; - $label=$langs->trans("ShowResource").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php index 55511922385..ac1e28a0657 100644 --- a/htdocs/societe/class/address.class.php +++ b/htdocs/societe/class/address.class.php @@ -422,8 +422,9 @@ class Address global $langs; $result=''; + $label = $langs->trans("ShowAddress").': '.$this->label; - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowAddress").': '.$this->label, 'address', 'class="classfortooltip"').$lienfin.' '); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8f2e64874c6..bcf5ae3104a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1749,7 +1749,7 @@ class Societe extends CommonObject } // Add type of canvas - $lien.=(!empty($this->canvas)?'&canvas='.$this->canvas:'').'">'; + $lien.=(!empty($this->canvas)?'&canvas='.$this->canvas:'').'" title="'.$name.'" class="classfortooltip">'; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowCompany").': '.$name, 'company', 'class="classfortooltip"').$lienfin); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 9ea4f3de9c5..c5733d5724f 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1786,13 +1786,13 @@ class User extends CommonObject global $langs; $result=''; + $label = $langs->trans("ShowUser").': '.$this->getFullName($langs,'','',24); - $lien = ''; + $lien = ''; $lienfin=''; - if ($withpicto) - { - $result.=($lien.img_object($langs->trans("ShowUser"), 'user', 'class="classfortooltip"').$lienfin); + if ($withpicto) { + $result.=($lien.img_object($label, 'user', 'class="classfortooltip"').$lienfin); if ($withpicto != 2) $result.=' '; } $result.=$lien.$this->getFullName($langs,'','',24).$lienfin; From f4161b457bf351c176e80ba557d8f878fd2586f2 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Wed, 21 Jan 2015 01:06:04 +0100 Subject: [PATCH 142/152] Add dol_escape_htmltag and start to adapt boxes --- htdocs/adherents/class/adherent.class.php | 2 +- .../adherents/class/adherent_type.class.php | 2 +- htdocs/adherents/class/cotisation.class.php | 2 +- htdocs/categories/class/categorie.class.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 4 +- htdocs/comm/index.php | 9 +- htdocs/comm/propal/class/propal.class.php | 4 +- htdocs/commande/class/commande.class.php | 4 +- htdocs/compta/bank/class/account.class.php | 4 +- .../deplacement/class/deplacement.class.php | 2 +- htdocs/compta/dons/class/don.class.php | 2 +- .../facture/class/facture-rec.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- .../compta/localtax/class/localtax.class.php | 2 +- .../cheque/class/remisecheque.class.php | 2 +- .../compta/paiement/class/paiement.class.php | 2 +- .../class/bonprelevement.class.php | 4 +- .../salaries/class/paymentsalary.class.php | 2 +- .../sociales/class/chargesociales.class.php | 2 +- .../class/paymentsocialcontribution.class.php | 2 +- htdocs/compta/tva/class/tva.class.php | 2 +- htdocs/contact/class/contact.class.php | 4 +- htdocs/contrat/class/contrat.class.php | 4 +- htdocs/core/boxes/box_actions.php | 91 +-- htdocs/core/boxes/box_activity.php | 610 +++++++++++------- htdocs/core/boxes/box_bookmarks.php | 84 +-- htdocs/core/boxes/box_clients.php | 31 +- htdocs/core/boxes/box_commandes.php | 111 ++-- htdocs/core/boxes/box_comptes.php | 134 ++-- htdocs/core/boxes/box_contacts.php | 88 ++- htdocs/core/boxes/box_contracts.php | 94 +-- htdocs/core/boxes/box_external_rss.php | 42 +- htdocs/core/boxes/box_factures.php | 99 +-- htdocs/core/boxes/box_factures_fourn.php | 110 ++-- htdocs/core/boxes/modules_boxes.php | 16 +- htdocs/core/class/discount.class.php | 10 +- htdocs/ecm/class/ecmdirectory.class.php | 4 +- htdocs/expedition/class/expedition.class.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 2 +- .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 4 +- htdocs/fourn/class/paiementfourn.class.php | 2 +- htdocs/holiday/class/holiday.class.php | 2 +- htdocs/livraison/class/livraison.class.php | 2 +- htdocs/product/class/product.class.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 2 +- htdocs/projet/class/project.class.php | 2 +- htdocs/projet/class/task.class.php | 2 +- htdocs/resource/class/resource.class.php | 2 +- htdocs/societe/class/address.class.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/user/class/user.class.php | 4 +- 52 files changed, 964 insertions(+), 661 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7c65e1a5cb1..70b0fb00b4c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1560,7 +1560,7 @@ class Adherent extends CommonObject $result=''; $label=$langs->trans("ShowMember").': '.$this->ref; - $linkclose = '" title="'.$label.'" class="classfortooltip">'; + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; if ($option == 'card') { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 44333f58322..a8ab42b6301 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -272,7 +272,7 @@ class AdherentType extends CommonObject $result=''; $label=$langs->trans("ShowTypeCard",$this->libelle); - $lien = ''; + $lien = ''; $lienfin=''; $picto='group'; diff --git a/htdocs/adherents/class/cotisation.class.php b/htdocs/adherents/class/cotisation.class.php index 48970abace4..c7faf97e748 100644 --- a/htdocs/adherents/class/cotisation.class.php +++ b/htdocs/adherents/class/cotisation.class.php @@ -266,7 +266,7 @@ class Cotisation extends CommonObject $result=''; $label=$langs->trans("ShowSubscription").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='payment'; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 7e29f6ccf38..efcee0d756d 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1276,7 +1276,7 @@ class Categorie extends CommonObject $result=''; $label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label); - $lien = ''; + $lien = ''; $lienfin=''; $picto='category'; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 25a9803e63e..d7f63d31872 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -898,8 +898,8 @@ class ActionComm extends CommonObject $result=''; $label=$this->label; - if (empty($label)) $label=$this->libelle; // For backward compatibility - $linkclose = '" title="'.$label.'" class="classfortooltip">'; + if (empty($label)) $label=$this->libelle; // For backward compatibility + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; if ($option=='birthday') $lien = 'rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -172,6 +172,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; print ''; print '
'.$langs->trans("OnProcessOrders").' ('.$num.')
'.$langs->trans("OnProcessOrders").' '.$num.'
'; $propalstatic->id=$obj->rowid; $propalstatic->ref=$obj->ref; + $propalstatic->ref_client=$obj->ref_client; print $propalstatic->getNomUrl(1); print ''; @@ -209,7 +210,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); - $sql = "SELECT c.rowid, c.ref, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -239,6 +240,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print '
'; $orderstatic->id=$obj->rowid; $orderstatic->ref=$obj->ref; + $orderstatic->ref_client=$obj->ref_client; print $orderstatic->getNomUrl(1); print ''; @@ -467,7 +469,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); - $sql = "SELECT s.nom as name, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql = "SELECT s.nom as name, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -503,6 +505,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $propalstatic->id=$obj->propalid; $propalstatic->ref=$obj->ref; + $propalstatic->ref_client=$obj->ref_client; print ''; print '"; + print "\n"; } print "\n"; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 8861bf556ba..a8862ab5ed2 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -433,18 +433,16 @@ class DiscountAbsolute $result=''; - if ($option == 'invoice') - { + if ($option == 'invoice') { $label=$langs->trans("ShowDiscount").': '.$this->ref_facture_source; - $lien = ''; + $lien = ''; $lienfin=''; $ref=$this->ref_facture_source; $picto='bill'; } - if ($option == 'discount') - { + if ($option == 'discount') { $label=$langs->trans("Discount"); - $lien = ''; + $lien = ''; $lienfin=''; $ref=$langs->trans("Discount"); $picto='generic'; diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index b4821dc2895..5edd4c3ce11 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -417,13 +417,13 @@ class EcmDirectory // extends CommonObject //$newref=str_replace('_',' ',$this->ref); $newref=$this->ref; $newlabel=$langs->trans("ShowECMSection").': '.$newref; - $linkclose='"'.($more?' '.$more:'').' title="'.$newlabel.'" class="classfortooltip">'; + $linkclose='"'.($more?' '.$more:'').' title="'.dol_escape_htmltag($newlabel, 1).'" class="classfortooltip">'; $lien = ''; + $linkstart = ''; $linkend=''; $picto='sending'; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index eca71601e7d..58c0efdda9a 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -549,7 +549,7 @@ class Fichinter extends CommonObject $result=''; $label=$langs->trans("Show").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='intervention'; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c2743a8e3ad..ef25be9469f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -533,7 +533,7 @@ class CommandeFournisseur extends CommonOrder $result=''; $label=$langs->trans("ShowOrder").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='order'; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 5034204154a..842fe9fcf0b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1477,12 +1477,12 @@ class FactureFournisseur extends CommonInvoice if ($option == 'document') { - $lien = ''; + $lien = ''; $lienfin=''; } else { - $lien = ''; + $lien = ''; $lienfin=''; } diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 3c3f9abba76..3cd3ec0496c 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -495,7 +495,7 @@ class PaiementFourn extends Paiement } $label = $langs->trans("ShowPayment").': '.$text; - $lien = ''; + $lien = ''; $lienfin=''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 43c074a5781..280efd4addc 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -660,7 +660,7 @@ class Holiday extends CommonObject $result=''; $label=$langs->trans("Show").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='holiday'; diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 2de166e4837..ccde9484b0d 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -663,7 +663,7 @@ class Livraison extends CommonObject $label=$langs->trans("ShowReceiving").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='sending'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a2b34eb2862..a889136de01 100755 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2816,7 +2816,7 @@ class Product extends CommonObject if ($maxlength) $newref=dol_trunc($newref,$maxlength,'middle'); if ($this->type == 0) $label = $langs->trans("ShowProduct").': '.$this->ref.' '.$this->label; if ($this->type == 1) $label = $langs->trans("ShowService").': '.$this->ref.' '.$this->label; - $linkclose = '" title="'.$label.'" class="classfortooltip">'; + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; if ($option == 'supplier') { $lien = 'libelle; - $lien=''; + $lien=''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($label, 'stock', 'class="classfortooltip"').$lienfin.' '); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 88b71cecc19..d423bc48ae1 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -790,7 +790,7 @@ class Project extends CommonObject $lien = ''; $lienfin = ''; $label = $langs->trans("ShowProject") . ': ' . $this->ref . ($this->title ? ' - ' . $this->title : ''); - $linkclose = '" title="'.$label.'" class="classfortooltip">'; + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; if ($option != 'nolink') { if (preg_match('/\.php$/',$option)) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 497dabdc69f..5dde5e21b88 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -507,7 +507,7 @@ class Task extends CommonObject $result=''; $label=$langs->trans("ShowTask").': '.$this->ref.($this->label?' - '.$this->label:''); - $lien = ''; + $lien = ''; $lienfin=''; $picto='projecttask'; diff --git a/htdocs/resource/class/resource.class.php b/htdocs/resource/class/resource.class.php index fec44b3e2b7..498291c1cc1 100644 --- a/htdocs/resource/class/resource.class.php +++ b/htdocs/resource/class/resource.class.php @@ -873,7 +873,7 @@ class Resource extends CommonObject if ($option == '') { - $lien = ''; + $lien = ''; $picto='resource@resource'; $label=$langs->trans("ShowResource").': '.$this->ref; diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php index ac1e28a0657..06be3f501fb 100644 --- a/htdocs/societe/class/address.class.php +++ b/htdocs/societe/class/address.class.php @@ -424,7 +424,7 @@ class Address $result=''; $label = $langs->trans("ShowAddress").': '.$this->label; - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowAddress").': '.$this->label, 'address', 'class="classfortooltip"').$lienfin.' '); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index bcf5ae3104a..ab28cace102 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1749,7 +1749,7 @@ class Societe extends CommonObject } // Add type of canvas - $lien.=(!empty($this->canvas)?'&canvas='.$this->canvas:'').'" title="'.$name.'" class="classfortooltip">'; + $lien.=(!empty($this->canvas)?'&canvas='.$this->canvas:'').'" title="'.dol_escape_htmltag($name, 1).'" class="classfortooltip">'; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowCompany").': '.$name, 'company', 'class="classfortooltip"').$lienfin); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index c5733d5724f..11eaa8afb45 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1788,12 +1788,12 @@ class User extends CommonObject $result=''; $label = $langs->trans("ShowUser").': '.$this->getFullName($langs,'','',24); - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) { $result.=($lien.img_object($label, 'user', 'class="classfortooltip"').$lienfin); - if ($withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=' '; } $result.=$lien.$this->getFullName($langs,'','',24).$lienfin; return $result; From 6f3d9200bf889cdfaf0cc4cd97fd0702ece7de8b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 22 Jan 2015 07:15:14 +0100 Subject: [PATCH 143/152] Correct link --- dev/initdata/mysqldump_dolibarr_3.7.0.sql | 4 ++-- htdocs/compta/bank/ligne.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/initdata/mysqldump_dolibarr_3.7.0.sql b/dev/initdata/mysqldump_dolibarr_3.7.0.sql index 97b066a80cf..b18a9a20b4a 100644 --- a/dev/initdata/mysqldump_dolibarr_3.7.0.sql +++ b/dev/initdata/mysqldump_dolibarr_3.7.0.sql @@ -735,7 +735,7 @@ CREATE TABLE `llx_bank_url` ( LOCK TABLES `llx_bank_url` WRITE; /*!40000 ALTER TABLE `llx_bank_url` DISABLE KEYS */; -INSERT INTO `llx_bank_url` VALUES (1,4,1,'/dolibarrnew/compta/paiement/fiche.php?id=','(paiement)','payment'),(2,4,9,'/dolibarrnew/compta/fiche.php?socid=','Client salon invidivdu','company'),(3,5,2,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(4,5,2,'/comm/fiche.php?socid=','Belin SARL','company'),(5,6,3,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(6,6,2,'/comm/fiche.php?socid=','Belin SARL','company'),(9,8,5,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(10,8,7,'/comm/fiche.php?socid=','Generic customer','company'),(17,12,4,'/compta/payment_sc/fiche.php?id=','(paiement)','payment_sc'),(18,12,4,'/compta/charges.php?id=','Assurance Chomage (fff)','sc'),(19,13,6,'/dolibarrnew/compta/paiement/fiche.php?id=','(paiement)','payment'),(20,13,7,'/dolibarrnew/comm/fiche.php?socid=','Generic customer','company'),(21,14,8,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(22,14,2,'/comm/fiche.php?socid=','Belin SARL','company'),(23,15,9,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(24,15,10,'/comm/fiche.php?socid=','Smith Vick','company'),(25,16,17,'/dolibarrnew/compta/paiement/fiche.php?id=','(paiement)','payment'),(26,16,10,'/dolibarrnew/comm/fiche.php?socid=','Smith Vick','company'),(27,17,18,'/dolibarrnew/compta/paiement/fiche.php?id=','(paiement)','payment'),(28,17,10,'/dolibarrnew/comm/fiche.php?socid=','Smith Vick','company'),(29,18,19,'/dolibarrnew/compta/paiement/fiche.php?id=','(paiement)','payment'),(30,18,10,'/dolibarrnew/comm/fiche.php?socid=','Smith Vick','company'),(31,19,20,'/dolibarrnew/compta/paiement/fiche.php?id=','(paiement)','payment'),(32,19,10,'/dolibarrnew/comm/fiche.php?socid=','Smith Vick','company'),(33,20,21,'/dolibarrnew/compta/paiement/fiche.php?id=','(paiement)','payment'),(34,20,10,'/dolibarrnew/comm/fiche.php?socid=','Smith Vick','company'),(35,21,23,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(36,21,1,'/comm/fiche.php?socid=','ABC and Co','company'),(37,22,24,'/dolibarrnew/compta/paiement/fiche.php?id=','(paiement)','payment'),(38,22,12,'/dolibarrnew/comm/fiche.php?socid=','Dupont Alain','company'),(39,23,25,'/dolibarrnew/compta/paiement/fiche.php?id=','(paiement)','payment'),(40,23,10,'/dolibarrnew/comm/fiche.php?socid=','Smith Vick','company'),(41,24,26,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(42,24,1,'/comm/fiche.php?socid=','ABC and Co','company'),(43,25,27,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(44,25,18,'/comm/fiche.php?socid=','doe john','company'),(45,26,29,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(46,26,1,'/comm/fiche.php?socid=','ABC and Co','company'),(47,27,30,'/compta/paiement/fiche.php?id=','(paiement)','payment'),(48,27,1,'/comm/fiche.php?socid=','ABC and Co','company'),(49,28,32,'/dolibarr_new/compta/paiement/fiche.php?id=','(paiement)','payment'),(50,28,1,'/dolibarr_new/comm/fiche.php?socid=','ABC and Co','company'),(51,29,33,'/dolibarr_new/compta/paiement/fiche.php?id=','(paiement)','payment'),(52,29,1,'/dolibarr_new/comm/fiche.php?socid=','ABC and Co','company'); +INSERT INTO `llx_bank_url` VALUES (1,4,1,'/dolibarrnew/compta/paiement/card.php?id=','(paiement)','payment'),(2,4,9,'/dolibarrnew/compta/card.php?socid=','Client salon invidivdu','company'),(3,5,2,'/compta/paiement/card.php?id=','(paiement)','payment'),(4,5,2,'/comm/card.php?socid=','Belin SARL','company'),(5,6,3,'/compta/paiement/card.php?id=','(paiement)','payment'),(6,6,2,'/comm/card.php?socid=','Belin SARL','company'),(9,8,5,'/compta/paiement/card.php?id=','(paiement)','payment'),(10,8,7,'/comm/card.php?socid=','Generic customer','company'),(17,12,4,'/compta/payment_sc/card.php?id=','(paiement)','payment_sc'),(18,12,4,'/compta/charges.php?id=','Assurance Chomage (fff)','sc'),(19,13,6,'/dolibarrnew/compta/paiement/card.php?id=','(paiement)','payment'),(20,13,7,'/dolibarrnew/comm/card.php?socid=','Generic customer','company'),(21,14,8,'/compta/paiement/card.php?id=','(paiement)','payment'),(22,14,2,'/comm/card.php?socid=','Belin SARL','company'),(23,15,9,'/compta/paiement/card.php?id=','(paiement)','payment'),(24,15,10,'/comm/card.php?socid=','Smith Vick','company'),(25,16,17,'/dolibarrnew/compta/paiement/card.php?id=','(paiement)','payment'),(26,16,10,'/dolibarrnew/comm/card.php?socid=','Smith Vick','company'),(27,17,18,'/dolibarrnew/compta/paiement/card.php?id=','(paiement)','payment'),(28,17,10,'/dolibarrnew/comm/card.php?socid=','Smith Vick','company'),(29,18,19,'/dolibarrnew/compta/paiement/card.php?id=','(paiement)','payment'),(30,18,10,'/dolibarrnew/comm/card.php?socid=','Smith Vick','company'),(31,19,20,'/dolibarrnew/compta/paiement/card.php?id=','(paiement)','payment'),(32,19,10,'/dolibarrnew/comm/card.php?socid=','Smith Vick','company'),(33,20,21,'/dolibarrnew/compta/paiement/card.php?id=','(paiement)','payment'),(34,20,10,'/dolibarrnew/comm/card.php?socid=','Smith Vick','company'),(35,21,23,'/compta/paiement/card.php?id=','(paiement)','payment'),(36,21,1,'/comm/card.php?socid=','ABC and Co','company'),(37,22,24,'/dolibarrnew/compta/paiement/card.php?id=','(paiement)','payment'),(38,22,12,'/dolibarrnew/comm/card.php?socid=','Dupont Alain','company'),(39,23,25,'/dolibarrnew/compta/paiement/card.php?id=','(paiement)','payment'),(40,23,10,'/dolibarrnew/comm/card.php?socid=','Smith Vick','company'),(41,24,26,'/compta/paiement/card.php?id=','(paiement)','payment'),(42,24,1,'/comm/card.php?socid=','ABC and Co','company'),(43,25,27,'/compta/paiement/card.php?id=','(paiement)','payment'),(44,25,18,'/comm/card.php?socid=','doe john','company'),(45,26,29,'/compta/paiement/card.php?id=','(paiement)','payment'),(46,26,1,'/comm/card.php?socid=','ABC and Co','company'),(47,27,30,'/compta/paiement/card.php?id=','(paiement)','payment'),(48,27,1,'/comm/card.php?socid=','ABC and Co','company'),(49,28,32,'/dolibarr_new/compta/paiement/card.php?id=','(paiement)','payment'),(50,28,1,'/dolibarr_new/comm/card.php?socid=','ABC and Co','company'),(51,29,33,'/dolibarr_new/compta/paiement/card.php?id=','(paiement)','payment'),(52,29,1,'/dolibarr_new/comm/card.php?socid=','ABC and Co','company'); /*!40000 ALTER TABLE `llx_bank_url` ENABLE KEYS */; UNLOCK TABLES; @@ -4965,7 +4965,7 @@ CREATE TABLE `llx_menu` ( LOCK TABLES `llx_menu` WRITE; /*!40000 ALTER TABLE `llx_menu` DISABLE KEYS */; -INSERT INTO `llx_menu` VALUES (19289,'all',1,'cashdesk','top','cashdesk',0,NULL,NULL,100,'/cashdesk/index.php?user=__LOGIN__','pointofsale','CashDeskMenu','cashdesk',NULL,NULL,'1','$conf->cashdesk->enabled',0,'2012-12-08 13:11:09'),(87422,'smartphone',1,NULL,'top','home',0,NULL,NULL,1,'/index.php?mainmenu=home&leftmenu=','','Home','',-1,'','','1',2,'2013-02-24 18:29:15'),(87423,'smartphone',1,NULL,'top','companies',0,NULL,NULL,2,'/societe/index.php?mainmenu=companies&leftmenu=','','ThirdParties','companies',-1,'','$user->rights->societe->lire || $user->rights->societe->contact->lire','$conf->societe->enabled || $conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(87424,'smartphone',1,NULL,'top','products',0,NULL,NULL,3,'/product/index.php?mainmenu=products&leftmenu=','','Products/Services','products',-1,'','$user->rights->produit->lire||$user->rights->service->lire','$conf->product->enabled || $conf->service->enabled',0,'2013-02-24 18:29:15'),(87426,'smartphone',1,NULL,'top','commercial',0,NULL,NULL,5,'/comm/index.php?mainmenu=commercial&leftmenu=','','Commercial','commercial',-1,'','$user->rights->societe->lire || $user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87427,'smartphone',1,NULL,'top','accountancy',0,NULL,NULL,6,'/compta/index.php?mainmenu=accountancy&leftmenu=','','MenuFinancial','compta',-1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->commande->lire || $user->rights->facture->lire','$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled',2,'2013-02-24 18:29:15'),(87428,'smartphone',1,NULL,'top','project',0,NULL,NULL,7,'/projet/index.php?mainmenu=project&leftmenu=','','Projects','projects',-1,'','$user->rights->projet->lire','$conf->projet->enabled',0,'2013-02-24 18:29:15'),(87429,'smartphone',1,NULL,'top','tools',0,NULL,NULL,8,'/core/tools.php?mainmenu=tools&leftmenu=','','Tools','other',-1,'','$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run','$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled',2,'2013-02-24 18:29:15'),(87432,'smartphone',1,NULL,'top','shop',0,NULL,NULL,11,'/boutique/index.php?mainmenu=shop&leftmenu=','','OSCommerce','shop',-1,'','','! empty($conf->boutique->enabled)',0,'2013-02-24 18:29:15'),(87434,'smartphone',1,NULL,'top','members',0,NULL,NULL,15,'/adherents/index.php?mainmenu=members&leftmenu=','','Members','members',-1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(87435,'smartphone',1,NULL,'top','bank',0,NULL,NULL,6,'/compta/bank/index.php?mainmenu=bank&leftmenu=bank','','MenuBankCash','banks',-1,'','$user->rights->banque->lire || $user->rights->prelevement->bons->lire','$conf->banque->enabled || $conf->prelevement->enabled',2,'2013-02-24 18:29:15'),(87521,'smartphone',1,NULL,'left','home',87422,NULL,NULL,0,'/admin/index.php?leftmenu=setup','','Setup','admin',0,'','','$user->admin',2,'2013-02-24 18:29:15'),(87522,'smartphone',1,NULL,'left','home',87521,NULL,NULL,1,'/admin/company.php?leftmenu=setup','','MenuCompanySetup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87523,'smartphone',1,NULL,'left','home',87521,NULL,NULL,4,'/admin/ihm.php?leftmenu=setup','','GUISetup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87524,'smartphone',1,NULL,'left','home',87521,NULL,NULL,2,'/admin/modules.php?leftmenu=setup','','Modules','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87525,'smartphone',1,NULL,'left','home',87521,NULL,NULL,5,'/admin/boxes.php?leftmenu=setup','','Boxes','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87526,'smartphone',1,NULL,'left','home',87521,NULL,NULL,3,'/admin/menus.php?leftmenu=setup','','Menus','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87527,'smartphone',1,NULL,'left','home',87521,NULL,NULL,6,'/admin/delais.php?leftmenu=setup','','Alerts','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87529,'smartphone',1,NULL,'left','home',87521,NULL,NULL,7,'/admin/perms.php?leftmenu=setup','','Security','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87530,'smartphone',1,NULL,'left','home',87521,NULL,NULL,9,'/admin/mails.php?leftmenu=setup','','Emails','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87531,'smartphone',1,NULL,'left','home',87521,NULL,NULL,8,'/admin/limits.php?leftmenu=setup','','MenuLimits','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87532,'smartphone',1,NULL,'left','home',87521,NULL,NULL,10,'/admin/dict.php?leftmenu=setup','','DictionarySetup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87533,'smartphone',1,NULL,'left','home',87521,NULL,NULL,11,'/admin/const.php?leftmenu=setup','','OtherSetup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87621,'smartphone',1,NULL,'left','home',87422,NULL,NULL,1,'/admin/system/index.php?leftmenu=system','','SystemInfo','admin',0,'','','$user->admin',2,'2013-02-24 18:29:15'),(87622,'smartphone',1,NULL,'left','home',87621,NULL,NULL,0,'/admin/system/dolibarr.php?leftmenu=system','','Dolibarr','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87623,'smartphone',1,NULL,'left','home',87622,NULL,NULL,1,'/admin/system/constall.php?leftmenu=system','','AllParameters','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87624,'smartphone',1,NULL,'left','home',87622,NULL,NULL,4,'/admin/system/about.php?leftmenu=system','','About','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87625,'smartphone',1,NULL,'left','home',87621,NULL,NULL,1,'/admin/system/os.php?leftmenu=system','','OS','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87626,'smartphone',1,NULL,'left','home',87621,NULL,NULL,2,'/admin/system/web.php?leftmenu=system','','WebServer','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87627,'smartphone',1,NULL,'left','home',87621,NULL,NULL,3,'/admin/system/phpinfo.php?leftmenu=system','','Php','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87628,'smartphone',1,NULL,'left','home',87622,NULL,NULL,3,'/admin/triggers.php?leftmenu=system','','Triggers','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87629,'smartphone',1,NULL,'left','home',87622,NULL,NULL,2,'/admin/system/modules.php?leftmenu=system','','Modules','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87631,'smartphone',1,NULL,'left','home',87621,NULL,NULL,4,'/admin/system/database.php?leftmenu=system','','Database','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87632,'smartphone',1,NULL,'left','home',87631,NULL,NULL,0,'/admin/system/database-tables.php?leftmenu=system','','Tables','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87721,'smartphone',1,NULL,'left','home',87422,NULL,NULL,2,'/admin/tools/index.php?leftmenu=admintools','','SystemTools','admin',0,'','','$user->admin',2,'2013-02-24 18:29:15'),(87722,'smartphone',1,NULL,'left','home',87721,NULL,NULL,0,'/admin/tools/dolibarr_export.php?leftmenu=admintools','','Backup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87723,'smartphone',1,NULL,'left','home',87721,NULL,NULL,1,'/admin/tools/dolibarr_import.php?leftmenu=admintools','','Restore','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87724,'smartphone',1,NULL,'left','home',87721,NULL,NULL,6,'/admin/tools/purge.php?leftmenu=admintools','','Purge','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87725,'smartphone',1,NULL,'left','home',87721,NULL,NULL,3,'/admin/tools/eaccelerator.php?leftmenu=admintools','','EAccelerator','admin',1,'','','1 && function_exists(\'eaccelerator_info\')',2,'2013-02-24 18:29:15'),(87726,'smartphone',1,NULL,'left','home',87721,NULL,NULL,2,'/admin/tools/update.php?leftmenu=admintools','','MenuUpgrade','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87727,'smartphone',1,NULL,'left','home',87721,NULL,NULL,4,'/admin/tools/listevents.php?leftmenu=admintools','','Audit','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87728,'smartphone',1,NULL,'left','home',87721,NULL,NULL,7,'/support/index.php?leftmenu=admintools','_blank','HelpCenter','help',1,'','','1',2,'2013-02-24 18:29:15'),(87729,'smartphone',1,NULL,'left','home',87721,NULL,NULL,5,'/admin/tools/listsessions.php?leftmenu=admintools','','Sessions','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87821,'smartphone',1,NULL,'left','home',87422,NULL,NULL,3,'/user/home.php?leftmenu=users','','MenuUsersAndGroups','users',0,'','','1',2,'2013-02-24 18:29:15'),(87822,'smartphone',1,NULL,'left','home',87821,NULL,NULL,0,'/user/index.php?leftmenu=users','','Users','users',1,'','$user->rights->user->user->lire || $user->admin','1',2,'2013-02-24 18:29:15'),(87823,'smartphone',1,NULL,'left','home',87822,NULL,NULL,0,'/user/fiche.php?leftmenu=users&action=create','','NewUser','users',2,'','$user->rights->user->user->creer || $user->admin','1',2,'2013-02-24 18:29:15'),(87824,'smartphone',1,NULL,'left','home',87821,NULL,NULL,1,'/user/group/index.php?leftmenu=users','','Groups','users',1,'','($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin','1',2,'2013-02-24 18:29:15'),(87825,'smartphone',1,NULL,'left','home',87824,NULL,NULL,0,'/user/group/fiche.php?leftmenu=users&action=create','','NewGroup','users',2,'','($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin','1',2,'2013-02-24 18:29:15'),(87921,'smartphone',1,NULL,'left','companies',87423,NULL,NULL,0,'/societe/societe.php','','ThirdParty','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87922,'smartphone',1,NULL,'left','companies',87921,NULL,NULL,0,'/societe/soc.php?action=create','','MenuNewThirdParty','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87924,'smartphone',1,NULL,'left','companies',87921,NULL,NULL,5,'/fourn/liste.php?leftmenu=suppliers','','ListSuppliersShort','suppliers',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(87925,'smartphone',1,NULL,'left','companies',87924,NULL,NULL,0,'/societe/soc.php?leftmenu=supplier&action=create&type=f','','NewSupplier','suppliers',2,'','$user->rights->societe->creer','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(87927,'smartphone',1,NULL,'left','companies',87921,NULL,NULL,3,'/comm/prospect/list.php?leftmenu=prospects','','ListProspectsShort','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87928,'smartphone',1,NULL,'left','companies',87927,NULL,NULL,0,'/societe/soc.php?leftmenu=prospects&action=create&type=p','','MenuNewProspect','companies',2,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87930,'smartphone',1,NULL,'left','companies',87921,NULL,NULL,4,'/comm/list.php?leftmenu=customers','','ListCustomersShort','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87931,'smartphone',1,NULL,'left','companies',87930,NULL,NULL,0,'/societe/soc.php?leftmenu=customers&action=create&type=c','','MenuNewCustomer','companies',2,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88021,'smartphone',1,NULL,'left','companies',87423,NULL,NULL,1,'/contact/list.php?leftmenu=contacts','','ContactsAddresses||Contacts@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88022,'smartphone',1,NULL,'left','companies',88021,NULL,NULL,0,'/contact/fiche.php?leftmenu=contacts&action=create','','NewContactAddress||NewContact@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88023,'smartphone',1,NULL,'left','companies',88021,NULL,NULL,1,'/contact/list.php?leftmenu=contacts','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88025,'smartphone',1,NULL,'left','companies',88023,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=p','','Prospects','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88026,'smartphone',1,NULL,'left','companies',88023,NULL,NULL,2,'/contact/list.php?leftmenu=contacts&type=c','','Customers','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88027,'smartphone',1,NULL,'left','companies',88023,NULL,NULL,3,'/contact/list.php?leftmenu=contacts&type=f','','Suppliers','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(88028,'smartphone',1,NULL,'left','companies',88023,NULL,NULL,4,'/contact/list.php?leftmenu=contacts&type=o','','Others','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88071,'smartphone',1,NULL,'left','companies',87423,NULL,NULL,3,'/categories/index.php?leftmenu=cat&type=1','','SuppliersCategoriesShort','categories',0,'','$user->rights->categorie->lire','$conf->societe->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(88072,'smartphone',1,NULL,'left','companies',88071,NULL,NULL,0,'/categories/fiche.php?action=create&type=1','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->societe->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(88081,'smartphone',1,NULL,'left','companies',87423,NULL,NULL,4,'/categories/index.php?leftmenu=cat&type=2','','CustomersProspectsCategoriesShort','categories',0,'','$user->rights->categorie->lire','$conf->fournisseur->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(88082,'smartphone',1,NULL,'left','companies',88081,NULL,NULL,0,'/categories/fiche.php?action=create&type=2','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->fournisseur->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(88121,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,1,'/comm/prospect/index.php?leftmenu=prospects','','Prospects','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88122,'smartphone',1,NULL,'left','commercial',88121,NULL,NULL,0,'/societe/soc.php?leftmenu=prospects&action=create&type=p','','MenuNewProspect','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88123,'smartphone',1,NULL,'left','commercial',88121,NULL,NULL,1,'/comm/prospect/list.php?leftmenu=prospects','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88124,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,0,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=-1','','LastProspectDoNotContact','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88125,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,1,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=0','','LastProspectNeverContacted','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88126,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,2,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=1','','LastProspectToContact','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88127,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,3,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=2','','LastProspectContactInProcess','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88128,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,4,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=3','','LastProspectContactDone','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88129,'smartphone',1,NULL,'left','commercial',88121,NULL,NULL,2,'/contact/list.php?leftmenu=prospects&type=p','','Contacts','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88221,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,2,'/comm/index.php?leftmenu=customers','','Customers','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88222,'smartphone',1,NULL,'left','commercial',88221,NULL,NULL,0,'/societe/soc.php?leftmenu=customers&action=create&type=c','','MenuNewCustomer','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88223,'smartphone',1,NULL,'left','commercial',88221,NULL,NULL,1,'/comm/list.php?leftmenu=customers','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88224,'smartphone',1,NULL,'left','commercial',88221,NULL,NULL,2,'/contact/list.php?leftmenu=customers&type=c','','Contacts','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88321,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,3,'/contact/list.php?leftmenu=contacts','','Contacts','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88322,'smartphone',1,NULL,'left','commercial',88321,NULL,NULL,0,'/contact/fiche.php?leftmenu=contacts&action=create','','NewContactAddress||NewContact@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88323,'smartphone',1,NULL,'left','commercial',88321,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&action=create','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88331,'smartphone',1,NULL,'left','commercial',88323,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=p','','Prospects','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88332,'smartphone',1,NULL,'left','commercial',88323,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=c','','Customers','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88333,'smartphone',1,NULL,'left','commercial',88323,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=f','','Suppliers','companies',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->societe->enabled && $conf->fournisseur->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88334,'smartphone',1,NULL,'left','commercial',88323,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=o','','Other','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88521,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,4,'/comm/propal.php?leftmenu=propals','','Prop','propal',0,'','$user->rights->propale->lire','$conf->propal->enabled',2,'2013-02-24 18:29:15'),(88522,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,0,'/societe/societe.php?leftmenu=propals','','NewPropal','propal',1,'','$user->rights->propale->creer','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88523,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,1,'/comm/propal.php?viewstatut=0','','PropalsDraft','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88524,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,2,'/comm/propal.php?viewstatut=1','','PropalsOpened','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88525,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,3,'/comm/propal.php?viewstatut=2,3,4','','PropalStatusClosedShort','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88526,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,4,'/comm/propal/stats/index.php?leftmenu=propals','','Statistics','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88621,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,5,'/commande/index.php?leftmenu=orders','','CustomersOrders','orders',0,'','$user->rights->commande->lire','$conf->commande->enabled',2,'2013-02-24 18:29:15'),(88622,'smartphone',1,NULL,'left','commercial',88621,NULL,NULL,0,'/societe/societe.php?leftmenu=orders','','NewOrder','orders',1,'','$user->rights->commande->creer','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88623,'smartphone',1,NULL,'left','commercial',88621,NULL,NULL,1,'/commande/liste.php?leftmenu=orders','','List','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88624,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,2,'/commande/liste.php?leftmenu=orders&viewstatut=0','','StatusOrderDraftShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88625,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,3,'/commande/liste.php?leftmenu=orders&viewstatut=1','','StatusOrderValidated','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88626,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,4,'/commande/liste.php?leftmenu=orders&viewstatut=2','','StatusOrderOnProcessShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88627,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,5,'/commande/liste.php?leftmenu=orders&viewstatut=3','','StatusOrderToBill','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88628,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,6,'/commande/liste.php?leftmenu=orders&viewstatut=4','','StatusOrderProcessed','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88629,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,7,'/commande/liste.php?leftmenu=orders&viewstatut=-1','','StatusOrderCanceledShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88630,'smartphone',1,NULL,'left','commercial',88621,NULL,NULL,4,'/commande/stats/index.php?leftmenu=orders','','Statistics','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88721,'smartphone',1,NULL,'left','commercial',87424,NULL,NULL,6,'/expedition/index.php?leftmenu=sendings','','Shipments','orders',0,'','$user->rights->expedition->lire','$conf->expedition->enabled',2,'2013-02-24 18:29:15'),(88722,'smartphone',1,NULL,'left','commercial',88721,NULL,NULL,0,'/expedition/liste.php?leftmenu=sendings','','List','orders',1,'','$user->rights->expedition->lire','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-02-24 18:29:15'),(88723,'smartphone',1,NULL,'left','commercial',88721,NULL,NULL,1,'/expedition/stats/index.php?leftmenu=sendings','','Statistics','orders',1,'','$user->rights->expedition->lire','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-02-24 18:29:15'),(88821,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,7,'/contrat/index.php?leftmenu=contracts','','Contracts','contracts',0,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-02-24 18:29:15'),(88822,'smartphone',1,NULL,'left','commercial',88821,NULL,NULL,0,'/societe/societe.php?leftmenu=contracts','','NewContract','contracts',1,'','$user->rights->contrat->creer','$conf->contrat->enabled',2,'2013-02-24 18:29:15'),(88823,'smartphone',1,NULL,'left','commercial',88821,NULL,NULL,1,'/contrat/liste.php?leftmenu=contracts','','List','contracts',1,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-02-24 18:29:15'),(88824,'smartphone',1,NULL,'left','commercial',88821,NULL,NULL,2,'/contrat/services.php?leftmenu=contracts','','MenuServices','contracts',1,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-02-24 18:29:15'),(88825,'smartphone',1,NULL,'left','commercial',88824,NULL,NULL,0,'/contrat/services.php?leftmenu=contracts&mode=0','','MenuInactiveServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-02-24 18:29:15'),(88826,'smartphone',1,NULL,'left','commercial',88824,NULL,NULL,1,'/contrat/services.php?leftmenu=contracts&mode=4','','MenuRunningServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-02-24 18:29:15'),(88827,'smartphone',1,NULL,'left','commercial',88824,NULL,NULL,2,'/contrat/services.php?leftmenu=contracts&mode=4&filter=expired','','MenuExpiredServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-02-24 18:29:15'),(88828,'smartphone',1,NULL,'left','commercial',88824,NULL,NULL,3,'/contrat/services.php?leftmenu=contracts&mode=5','','MenuClosedServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-02-24 18:29:15'),(88921,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,8,'/fichinter/list.php?leftmenu=ficheinter','','Interventions','interventions',0,'','$user->rights->ficheinter->lire','$conf->ficheinter->enabled',2,'2013-02-24 18:29:15'),(88922,'smartphone',1,NULL,'left','commercial',88921,NULL,NULL,0,'/fichinter/fiche.php?action=create&leftmenu=ficheinter','','NewIntervention','interventions',1,'','$user->rights->ficheinter->creer','$conf->ficheinter->enabled && $leftmenu==\"ficheinter\"',2,'2013-02-24 18:29:15'),(88923,'smartphone',1,NULL,'left','commercial',88921,NULL,NULL,1,'/fichinter/list.php?leftmenu=ficheinter','','List','interventions',1,'','$user->rights->ficheinter->lire','$conf->ficheinter->enabled && $leftmenu==\"ficheinter\"',2,'2013-02-24 18:29:15'),(89021,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,3,'/fourn/facture/index.php?leftmenu=suppliers_bills','','BillsSuppliers','bills',0,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(89022,'smartphone',1,NULL,'left','accountancy',89021,NULL,NULL,0,'/fourn/facture/fiche.php?action=create&leftmenu=suppliers_bills','','NewBill','bills',1,'','$user->rights->fournisseur->facture->creer','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(89023,'smartphone',1,NULL,'left','accountancy',89021,NULL,NULL,1,'/fourn/facture/impayees.php?leftmenu=suppliers_bills','','Unpaid','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(89024,'smartphone',1,NULL,'left','accountancy',89021,NULL,NULL,2,'/fourn/facture/paiement.php?leftmenu=suppliers_bills','','Payments','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(89121,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,3,'/compta/facture/list.php?leftmenu=customers_bills','','BillsCustomers','bills',0,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89122,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,3,'/compta/clients.php?action=facturer&leftmenu=customers_bills','','NewBill','bills',1,'','$user->rights->facture->creer','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89123,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,4,'/compta/facture/fiche-rec.php?leftmenu=customers_bills','','Repeatable','bills',1,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89124,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,5,'/compta/facture/impayees.php?action=facturer&leftmenu=customers_bills','','Unpaid','bills',1,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89125,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,6,'/compta/paiement/liste.php?leftmenu=customers_bills','','Payments','bills',1,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89131,'smartphone',1,NULL,'left','accountancy',89125,NULL,NULL,1,'/compta/paiement/rapport.php?leftmenu=customers_bills','','Reportings','bills',2,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89132,'smartphone',1,NULL,'left','accountancy',87435,NULL,NULL,9,'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank','','MenuChequeDeposits','bills',0,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-02-24 18:29:15'),(89133,'smartphone',1,NULL,'left','accountancy',89132,NULL,NULL,0,'/compta/paiement/cheque/fiche.php?leftmenu=checks&action=new','','NewCheckDeposit','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-02-24 18:29:15'),(89134,'smartphone',1,NULL,'left','accountancy',89132,NULL,NULL,1,'/compta/paiement/cheque/liste.php?leftmenu=checks','','List','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-02-24 18:29:15'),(89135,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,8,'/compta/facture/stats/index.php?leftmenu=customers_bills','','Statistics','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-02-24 18:29:15'),(89321,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,3,'/commande/liste.php?leftmenu=orders&viewstatut=3','','MenuOrdersToBill','orders',0,'','$user->rights->commande->lire','$conf->commande->enabled',0,'2013-02-24 18:29:15'),(89421,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,4,'/compta/dons/index.php?leftmenu=donations&mainmenu=accountancy','','Donations','donations',0,'','$user->rights->don->lire','$conf->don->enabled',2,'2013-02-24 18:29:15'),(89422,'smartphone',1,NULL,'left','accountancy',89421,NULL,NULL,0,'/compta/dons/fiche.php?leftmenu=donations&mainmenu=accountancy&action=create','','NewDonation','donations',1,'','$user->rights->don->creer','$conf->don->enabled && $leftmenu==\"donations\"',2,'2013-02-24 18:29:15'),(89423,'smartphone',1,NULL,'left','accountancy',89421,NULL,NULL,1,'/compta/dons/liste.php?leftmenu=donations&mainmenu=accountancy','','List','donations',1,'','$user->rights->don->lire','$conf->don->enabled && $leftmenu==\"donations\"',2,'2013-02-24 18:29:15'),(89521,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,5,'/compta/deplacement/index.php?leftmenu=tripsandexpenses','','TripsAndExpenses','trips',0,'','$user->rights->deplacement->lire','$conf->deplacement->enabled',0,'2013-02-24 18:29:15'),(89522,'smartphone',1,NULL,'left','accountancy',89521,NULL,NULL,1,'/compta/deplacement/fiche.php?action=create&leftmenu=tripsandexpenses','','New','trips',1,'','$user->rights->deplacement->creer','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-02-24 18:29:15'),(89523,'smartphone',1,NULL,'left','accountancy',89521,NULL,NULL,2,'/compta/deplacement/index.php?leftmenu=tripsandexpenses','','List','trips',1,'','$user->rights->deplacement->lire','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-02-24 18:29:15'),(89524,'smartphone',1,NULL,'left','accountancy',89521,NULL,NULL,2,'/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses','','Statistics','trips',1,'','$user->rights->deplacement->lire','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-02-24 18:29:15'),(89621,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,6,'/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy','','MenuTaxAndDividends','compta',0,'','$user->rights->tax->charges->lire','$conf->tax->enabled',0,'2013-02-24 18:29:15'),(89622,'smartphone',1,NULL,'left','accountancy',89621,NULL,NULL,1,'/compta/sociales/index.php?leftmenu=tax_social','','SocialContributions','',1,'','$user->rights->tax->charges->lire','$conf->tax->enabled',0,'2013-02-24 18:29:15'),(89623,'smartphone',1,NULL,'left','accountancy',89622,NULL,NULL,2,'/compta/sociales/charges.php?leftmenu=tax_social&action=create','','MenuNewSocialContribution','',2,'','$user->rights->tax->charges->creer','$conf->tax->enabled && $leftmenu==\"tax_social\"',0,'2013-02-24 18:29:15'),(89624,'smartphone',1,NULL,'left','accountancy',89622,NULL,NULL,3,'/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly','','Payments','',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && $leftmenu==\"tax_social\"',0,'2013-02-24 18:29:15'),(89721,'smartphone',1,NULL,'left','accountancy',89621,NULL,NULL,7,'/compta/tva/index.php?leftmenu=tax_vat&mainmenu=accountancy','','VAT','companies',1,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS)',0,'2013-02-24 18:29:15'),(89722,'smartphone',1,NULL,'left','accountancy',89721,NULL,NULL,0,'/compta/tva/fiche.php?leftmenu=tax_vat&action=create','','NewPayment','companies',2,'','$user->rights->tax->charges->creer','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-02-24 18:29:15'),(89723,'smartphone',1,NULL,'left','accountancy',89721,NULL,NULL,1,'/compta/tva/reglement.php?leftmenu=tax_vat','','Payments','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-02-24 18:29:15'),(89724,'smartphone',1,NULL,'left','accountancy',89721,NULL,NULL,2,'/compta/tva/clients.php?leftmenu=tax_vat','','ReportByCustomers','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-02-24 18:29:15'),(89725,'smartphone',1,NULL,'left','accountancy',89721,NULL,NULL,3,'/compta/tva/quadri_detail.php?leftmenu=tax_vat','','ReportByQuarter','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-02-24 18:29:15'),(89821,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,8,'/compta/ventilation/index.php?leftmenu=ventil','','Ventilation','companies',0,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89822,'smartphone',1,NULL,'left','accountancy',89821,NULL,NULL,0,'/compta/ventilation/liste.php','','ToDispatch','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89823,'smartphone',1,NULL,'left','accountancy',89821,NULL,NULL,1,'/compta/ventilation/lignes.php','','Dispatched','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89824,'smartphone',1,NULL,'left','accountancy',89821,NULL,NULL,2,'/compta/param/','','Setup','companies',1,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89825,'smartphone',1,NULL,'left','accountancy',89824,NULL,NULL,0,'/compta/param/comptes/liste.php','','List','companies',2,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89826,'smartphone',1,NULL,'left','accountancy',89824,NULL,NULL,1,'/compta/param/comptes/fiche.php?action=create','','New','companies',2,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89827,'smartphone',1,NULL,'left','accountancy',89821,NULL,NULL,3,'/compta/export/','','Export','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89828,'smartphone',1,NULL,'left','accountancy',89827,NULL,NULL,0,'/compta/export/index.php','','New','companies',2,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89829,'smartphone',1,NULL,'left','accountancy',89827,NULL,NULL,1,'/compta/export/liste.php','','List','companies',2,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89921,'smartphone',1,NULL,'left','accountancy',87435,NULL,NULL,9,'/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank','','StandingOrders','withdrawals',0,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled',2,'2013-02-24 18:29:15'),(89922,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,1,'/compta/prelevement/demandes.php?status=0&leftmenu=withdraw','','StandingOrderToProcess','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89923,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,0,'/compta/prelevement/create.php?leftmenu=withdraw','','NewStandingOrder','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89924,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,2,'/compta/prelevement/bons.php?leftmenu=withdraw','','WithdrawalsReceipts','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89925,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,3,'/compta/prelevement/liste.php?leftmenu=withdraw','','WithdrawalsLines','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89927,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,5,'/compta/prelevement/rejets.php?leftmenu=withdraw','','Rejects','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89928,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,6,'/compta/prelevement/stats.php?leftmenu=withdraw','','Statistics','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(90021,'smartphone',1,NULL,'left','accountancy',87435,NULL,NULL,1,'/compta/bank/index.php?leftmenu=bank&mainmenu=bank','','MenuBankCash','banks',0,'','$user->rights->banque->lire','$conf->banque->enabled',0,'2013-02-24 18:29:15'),(90022,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,0,'/compta/bank/fiche.php?action=create&leftmenu=bank','','MenuNewFinancialAccount','banks',1,'','$user->rights->banque->configurer','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90023,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,1,'/compta/bank/categ.php?leftmenu=bank','','Rubriques','categories',1,'','$user->rights->banque->configurer','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90024,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,2,'/compta/bank/search.php?leftmenu=bank','','ListTransactions','banks',1,'','$user->rights->banque->lire','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90025,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,3,'/compta/bank/budget.php?leftmenu=bank','','ListTransactionsByCategory','banks',1,'','$user->rights->banque->lire','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90027,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,5,'/compta/bank/virement.php?leftmenu=bank','','BankTransfers','banks',1,'','$user->rights->banque->transfer','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90121,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,11,'/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy','','Reportings','main',0,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90122,'smartphone',1,NULL,'left','accountancy',90121,NULL,NULL,0,'/compta/resultat/index.php?leftmenu=ca','','ReportInOut','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90123,'smartphone',1,NULL,'left','accountancy',90122,NULL,NULL,0,'/compta/resultat/clientfourn.php?leftmenu=ca','','ByCompanies','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90124,'smartphone',1,NULL,'left','accountancy',90121,NULL,NULL,1,'/compta/stats/index.php?leftmenu=ca','','ReportTurnover','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90125,'smartphone',1,NULL,'left','accountancy',90124,NULL,NULL,0,'/compta/stats/casoc.php?leftmenu=ca','','ByCompanies','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90126,'smartphone',1,NULL,'left','accountancy',90124,NULL,NULL,1,'/compta/stats/cabyuser.php?leftmenu=ca','','ByUsers','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90221,'smartphone',1,NULL,'left','products',87424,NULL,NULL,0,'/product/index.php?leftmenu=product&type=0','','Products','products',0,'','$user->rights->produit->lire','$conf->product->enabled',2,'2013-02-24 18:29:15'),(90222,'smartphone',1,NULL,'left','products',90221,NULL,NULL,0,'/product/fiche.php?leftmenu=product&action=create&type=0','','NewProduct','products',1,'','$user->rights->produit->creer','$conf->product->enabled',2,'2013-02-24 18:29:15'),(90223,'smartphone',1,NULL,'left','products',90221,NULL,NULL,1,'/product/liste.php?leftmenu=product&type=0','','List','products',1,'','$user->rights->produit->lire','$conf->product->enabled',2,'2013-02-24 18:29:15'),(90224,'smartphone',1,NULL,'left','products',90221,NULL,NULL,4,'/product/reassort.php?type=0','','Stocks','products',1,'','$user->rights->produit->lire && $user->rights->stock->lire','$conf->product->enabled',2,'2013-02-24 18:29:15'),(90321,'smartphone',1,NULL,'left','products',87424,NULL,NULL,1,'/product/index.php?leftmenu=service&type=1','','Services','products',0,'','$user->rights->service->lire','$conf->service->enabled',2,'2013-02-24 18:29:15'),(90322,'smartphone',1,NULL,'left','products',90321,NULL,NULL,0,'/product/fiche.php?leftmenu=service&action=create&type=1','','NewService','products',1,'','$user->rights->service->creer','$conf->service->enabled',2,'2013-02-24 18:29:15'),(90323,'smartphone',1,NULL,'left','products',90321,NULL,NULL,1,'/product/liste.php?leftmenu=service&type=1','','List','products',1,'','$user->rights->service->lire','$conf->service->enabled',2,'2013-02-24 18:29:15'),(90421,'smartphone',1,NULL,'left','products',87424,NULL,NULL,2,'/product/stats/index.php?leftmenu=stats','','Statistics','main',0,'','$user->rights->service->lire','$conf->product->enabled || $conf->service->enabled',2,'2013-02-24 18:29:15'),(90422,'smartphone',1,NULL,'left','products',90421,NULL,NULL,0,'/product/popuprop.php?leftmenu=stats','','Popularity','main',1,'','$user->rights->produit->lire && $user->rights->produit>lire','$conf->propal->enabled',2,'2013-02-24 18:29:15'),(90521,'smartphone',1,NULL,'left','products',87424,NULL,NULL,3,'/product/stock/index.php?leftmenu=stock','','Stock','stocks',0,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90522,'smartphone',1,NULL,'left','products',90521,NULL,NULL,0,'/product/stock/fiche.php?action=create','','MenuNewWarehouse','stocks',1,'','$user->rights->stock->creer','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90523,'smartphone',1,NULL,'left','products',90521,NULL,NULL,1,'/product/stock/liste.php','','List','stocks',1,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90524,'smartphone',1,NULL,'left','products',90521,NULL,NULL,2,'/product/stock/valo.php','','EnhancedValue','stocks',1,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90525,'smartphone',1,NULL,'left','products',90521,NULL,NULL,3,'/product/stock/mouvement.php','','Movements','stocks',1,'','$user->rights->stock->mouvement->lire','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90621,'smartphone',1,NULL,'left','products',87424,NULL,NULL,4,'/categories/index.php?leftmenu=cat&type=0','','Categories','categories',0,'','$user->rights->categorie->lire','$conf->categorie->enabled',2,'2013-02-24 18:29:15'),(90622,'smartphone',1,NULL,'left','products',90621,NULL,NULL,0,'/categories/fiche.php?action=create&type=0','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->categorie->enabled',2,'2013-02-24 18:29:15'),(91021,'smartphone',1,NULL,'left','project',87428,NULL,NULL,0,'/projet/index.php?leftmenu=projects','','Projects','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91022,'smartphone',1,NULL,'left','project',91021,NULL,NULL,1,'/projet/fiche.php?leftmenu=projects&action=create','','NewProject','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91023,'smartphone',1,NULL,'left','project',91021,NULL,NULL,2,'/projet/liste.php?leftmenu=projects','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91031,'smartphone',1,NULL,'left','project',87428,NULL,NULL,0,'/projet/index.php?leftmenu=projects&mode=mine','','MyProjects','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91032,'smartphone',1,NULL,'left','project',91031,NULL,NULL,1,'/projet/fiche.php?leftmenu=projects&action=create&mode=mine','','NewProject','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91033,'smartphone',1,NULL,'left','project',91031,NULL,NULL,2,'/projet/liste.php?leftmenu=projects&mode=mine','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91121,'smartphone',1,NULL,'left','project',87428,NULL,NULL,0,'/projet/activity/index.php?leftmenu=projects','','Activities','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91122,'smartphone',1,NULL,'left','project',91121,NULL,NULL,1,'/projet/tasks.php?leftmenu=projects&action=create','','NewTask','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91123,'smartphone',1,NULL,'left','project',91121,NULL,NULL,2,'/projet/tasks/index.php?leftmenu=projects','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91124,'smartphone',1,NULL,'left','project',91121,NULL,NULL,3,'/projet/activity/list.php?leftmenu=projects','','NewTimeSpent','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91221,'smartphone',1,NULL,'left','project',87428,NULL,NULL,0,'/projet/activity/index.php?leftmenu=projects&mode=mine','','MyActivities','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91222,'smartphone',1,NULL,'left','project',91221,NULL,NULL,1,'/projet/tasks.php?leftmenu=projects&action=create&mode=mine','','NewTask','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91223,'smartphone',1,NULL,'left','project',91221,NULL,NULL,2,'/projet/tasks/index.php?leftmenu=projects&mode=mine','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91224,'smartphone',1,NULL,'left','project',91221,NULL,NULL,3,'/projet/activity/list.php?leftmenu=projects&mode=mine','','NewTimeSpent','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91321,'smartphone',1,NULL,'left','tools',87429,NULL,NULL,0,'/comm/mailing/index.php?leftmenu=mailing','','EMailings','mails',0,'','$user->rights->mailing->lire','$conf->mailing->enabled',0,'2013-02-24 18:29:15'),(91322,'smartphone',1,NULL,'left','tools',91321,NULL,NULL,0,'/comm/mailing/fiche.php?leftmenu=mailing&action=create','','NewMailing','mails',1,'','$user->rights->mailing->creer','$conf->mailing->enabled',0,'2013-02-24 18:29:15'),(91323,'smartphone',1,NULL,'left','tools',91321,NULL,NULL,1,'/comm/mailing/liste.php?leftmenu=mailing','','List','mails',1,'','$user->rights->mailing->lire','$conf->mailing->enabled',0,'2013-02-24 18:29:15'),(91521,'smartphone',1,NULL,'left','tools',87429,NULL,NULL,2,'/exports/index.php?leftmenu=export','','FormatedExport','exports',0,'','$user->rights->export->lire','$conf->export->enabled',2,'2013-02-24 18:29:15'),(91522,'smartphone',1,NULL,'left','tools',91521,NULL,NULL,0,'/exports/export.php?leftmenu=export','','NewExport','exports',1,'','$user->rights->export->creer','$conf->export->enabled',2,'2013-02-24 18:29:15'),(91551,'smartphone',1,NULL,'left','tools',87429,NULL,NULL,2,'/imports/index.php?leftmenu=import','','FormatedImport','exports',0,'','$user->rights->import->run','$conf->import->enabled',2,'2013-02-24 18:29:15'),(91552,'smartphone',1,NULL,'left','tools',91551,NULL,NULL,0,'/imports/import.php?leftmenu=import','','NewImport','exports',1,'','$user->rights->import->run','$conf->import->enabled',2,'2013-02-24 18:29:15'),(91621,'smartphone',1,NULL,'left','members',87434,NULL,NULL,0,'/adherents/index.php?leftmenu=members&mainmenu=members','','Members','members',0,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91622,'smartphone',1,NULL,'left','members',91621,NULL,NULL,0,'/adherents/fiche.php?action=create','','NewMember','members',1,'','$user->rights->adherent->creer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91623,'smartphone',1,NULL,'left','members',91621,NULL,NULL,1,'/adherents/liste.php','','List','members',1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91624,'smartphone',1,NULL,'left','members',91623,NULL,NULL,2,'/adherents/liste.php?statut=-1','','MenuMembersToValidate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91625,'smartphone',1,NULL,'left','members',91623,NULL,NULL,3,'/adherents/liste.php?statut=1','','MenuMembersValidated','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91626,'smartphone',1,NULL,'left','members',91623,NULL,NULL,4,'/adherents/liste.php?statut=1&filter=outofdate','','MenuMembersNotUpToDate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91627,'smartphone',1,NULL,'left','members',91623,NULL,NULL,5,'/adherents/liste.php?statut=1&filter=uptodate','','MenuMembersUpToDate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91628,'smartphone',1,NULL,'left','members',91623,NULL,NULL,6,'/adherents/liste.php?statut=0','','MenuMembersResiliated','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91721,'smartphone',1,NULL,'left','members',87434,NULL,NULL,1,'/adherents/index.php?leftmenu=accountancy&mainmenu=members','','Subscriptions','compta',0,'','$user->rights->adherent->cotisation->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91722,'smartphone',1,NULL,'left','members',91721,NULL,NULL,0,'/adherents/liste.php?statut=-1&leftmenu=accountancy&mainmenu=members','','NewSubscription','compta',1,'','$user->rights->adherent->cotisation->creer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91723,'smartphone',1,NULL,'left','members',91721,NULL,NULL,1,'/adherents/cotisations.php?leftmenu=accountancy','','List','compta',1,'','$user->rights->adherent->cotisation->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91921,'smartphone',1,NULL,'left','members',87434,NULL,NULL,3,'/adherents/index.php?leftmenu=export&mainmenu=members','','Exports','members',0,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91922,'smartphone',1,NULL,'left','members',91921,NULL,NULL,0,'/exports/index.php?leftmenu=export','','Datas','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled && $conf->export->enabled',2,'2013-02-24 18:29:15'),(91923,'smartphone',1,NULL,'left','members',91921,NULL,NULL,1,'/adherents/htpasswd.php?leftmenu=export','','Filehtpasswd','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91924,'smartphone',1,NULL,'left','members',91921,NULL,NULL,2,'/adherents/cartes/carte.php?leftmenu=export','','MembersCards','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(92121,'smartphone',1,NULL,'left','members',87434,NULL,NULL,5,'/adherents/index.php?leftmenu=setup&mainmenu=members','','Setup','members',0,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(92122,'smartphone',1,NULL,'left','members',92121,NULL,NULL,0,'/adherents/type.php?leftmenu=setup','','MembersTypes','members',1,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(92123,'smartphone',1,NULL,'left','members',92121,NULL,NULL,1,'/adherents/options.php?leftmenu=setup','','MembersAttributes','members',1,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(92421,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,0,'/compta/index.php?leftmenu=suppliers','','Suppliers','companies',0,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(92422,'smartphone',1,NULL,'left','commercial',92421,NULL,NULL,0,'/societe/soc.php?leftmenu=suppliers&action=create&type=f','','NewSupplier','companies',1,'','$user->rights->societe->creer && $user->rights->fournisseur->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(92423,'smartphone',1,NULL,'left','commercial',92421,NULL,NULL,1,'/fourn/liste.php?leftmenu=suppliers','','List','companies',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(92424,'smartphone',1,NULL,'left','commercial',92421,NULL,NULL,2,'/contact/list.php?leftmenu=suppliers&type=f','','Contacts','companies',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(92521,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,6,'/fourn/commande/index.php?leftmenu=orders_suppliers','','SuppliersOrders','orders',0,'','$user->rights->fournisseur->commande->lire','$conf->commande->enabled',2,'2013-02-24 18:29:15'),(92522,'smartphone',1,NULL,'left','commercial',92521,NULL,NULL,0,'/societe/societe.php?leftmenu=orders_suppliers','','NewOrder','orders',1,'','$user->rights->fournisseur->commande->creer','$conf->commande->enabled && $leftmenu==\"orders_suppliers\"',2,'2013-02-24 18:29:15'),(92523,'smartphone',1,NULL,'left','commercial',92521,NULL,NULL,1,'/fourn/commande/liste.php?leftmenu=orders_suppliers&viewstatut=0','','List','orders',1,'','$user->rights->fournisseur->commande->lire','$conf->commande->enabled && $leftmenu==\"orders_suppliers\"',2,'2013-02-24 18:29:15'),(92529,'smartphone',1,NULL,'left','commercial',92521,NULL,NULL,7,'/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier','','Statistics','orders',1,'','$user->rights->fournisseur->commande->lire','$conf->commande->enabled && $leftmenu==\"orders_suppliers\"',2,'2013-02-24 18:29:15'),(92621,'smartphone',1,NULL,'left','members',87434,NULL,NULL,3,'/categories/index.php?leftmenu=cat&type=3','','MembersCategoriesShort','categories',0,'','$user->rights->categorie->lire','$conf->adherent->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(92622,'smartphone',1,NULL,'left','members',92621,NULL,NULL,0,'/categories/fiche.php?action=create&type=3','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->adherent->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(103094,'all',2,'agenda','top','agenda',0,NULL,NULL,100,'/comm/action/index.php','','Agenda','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103095,'all',2,'agenda','left','agenda',103094,NULL,NULL,100,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda','','Actions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103096,'all',2,'agenda','left','agenda',103095,NULL,NULL,101,'/comm/action/fiche.php?mainmenu=agenda&leftmenu=agenda&action=create','','NewAction','commercial',NULL,NULL,'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103097,'all',2,'agenda','left','agenda',103095,NULL,NULL,102,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda','','Calendar','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103098,'all',2,'agenda','left','agenda',103097,NULL,NULL,103,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine','','MenuToDoMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103099,'all',2,'agenda','left','agenda',103097,NULL,NULL,104,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine','','MenuDoneMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103100,'all',2,'agenda','left','agenda',103097,NULL,NULL,105,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo','','MenuToDoActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2013-03-13 15:29:19'),(103101,'all',2,'agenda','left','agenda',103097,NULL,NULL,106,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done','','MenuDoneActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2013-03-13 15:29:19'),(103102,'all',2,'agenda','left','agenda',103095,NULL,NULL,112,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda','','List','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103103,'all',2,'agenda','left','agenda',103102,NULL,NULL,113,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine','','MenuToDoMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103104,'all',2,'agenda','left','agenda',103102,NULL,NULL,114,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine','','MenuDoneMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103105,'all',2,'agenda','left','agenda',103102,NULL,NULL,115,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=todo','','MenuToDoActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2013-03-13 15:29:19'),(103106,'all',2,'agenda','left','agenda',103102,NULL,NULL,116,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=done','','MenuDoneActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2013-03-13 15:29:19'),(103107,'all',2,'agenda','left','agenda',103095,NULL,NULL,120,'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda','','Reportings','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103108,'all',2,'pos','top','pos',0,NULL,NULL,100,'/pos/backend/listefac.php','','POS','pos@pos',NULL,'1','1','1',2,'2013-03-13 20:33:09'),(103109,'all',2,'pos','left','pos',103108,NULL,NULL,100,'/pos/backend/liste.php','','Tickets','pos@pos',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103110,'all',2,'pos','left','pos',103109,NULL,NULL,100,'/pos/backend/liste.php','','List','main',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103111,'all',2,'pos','left','pos',103110,NULL,NULL,100,'/pos/backend/liste.php?viewstatut=0','','StatusTicketDraft','pos@pos',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103112,'all',2,'pos','left','@pos',103110,NULL,NULL,100,'/pos/backend/liste.php?viewstatut=1','','StatusTicketClosed','main',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103113,'all',2,'pos','left','@pos',103110,NULL,NULL,100,'/pos/backend/liste.php?viewstatut=2','','StatusTicketProcessed','main',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103114,'all',2,'pos','left','@pos',103110,NULL,NULL,100,'/pos/backend/liste.php?viewtype=1','','StatusTicketReturned','main',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103115,'all',2,'pos','left','pos',103108,NULL,NULL,100,'/pos/backend/listefac.php','','Factures','pos@pos',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103116,'all',2,'pos','left','pos',103115,NULL,NULL,100,'/pos/backend/listefac.php','','List','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103117,'all',2,'pos','left','pos',103116,NULL,NULL,100,'/pos/backend/listefac.php?viewstatut=0','','BillStatusDraft','bills',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103118,'all',2,'pos','left','@pos',103116,NULL,NULL,100,'/pos/backend/listefac.php?viewstatut=1','','BillStatusValidated','bills',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103119,'all',2,'pos','left','@pos',103116,NULL,NULL,100,'/pos/backend/listefac.php?viewstatut=2&viewtype=0','','BillStatusPaid','bills',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103120,'all',2,'pos','left','@pos',103116,NULL,NULL,100,'/pos/backend/listefac.php?viewtype=2','','BillStatusReturned','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103121,'all',2,'pos','left','@pos',103108,NULL,NULL,100,'/pos/frontend/index.php','','POS','main',NULL,NULL,'$user->rights->pos->frontend','1',0,'2013-03-13 20:33:09'),(103122,'all',2,'pos','left','@pos',103121,NULL,NULL,100,'/pos/frontend/index.php','','NewTicket','main',NULL,NULL,'$user->rights->pos->frontend','1',0,'2013-03-13 20:33:09'),(103123,'all',2,'pos','left','@pos',103121,NULL,NULL,101,'/pos/backend/closes.php','','CloseandArching','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103124,'all',2,'pos','left','@pos',103108,NULL,NULL,100,'/pos/backend/terminal/cash.php','','Terminal','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103125,'all',2,'pos','left','@pos',103124,NULL,NULL,100,'/pos/backend/terminal/fiche.php?action=create','','NewCash','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103126,'all',2,'pos','left','@pos',103124,NULL,NULL,101,'/pos/backend/terminal/cash.php','','List','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103127,'all',2,'pos','left','@pos',103123,NULL,NULL,101,'/pos/backend/closes.php?viewstatut=0','','Arqueo','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103128,'all',2,'pos','left','@pos',103123,NULL,NULL,102,'/pos/backend/closes.php?viewstatut=1','','Closes','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103129,'all',2,'pos','left','@pos',103108,NULL,NULL,102,'/pos/backend/transfers.php','','Transfer','main',NULL,NULL,'$user->rights->pos->transfer','1',0,'2013-03-13 20:33:09'),(103130,'all',2,'pos','left','@pos',103108,NULL,NULL,102,'/pos/backend/resultat/index.php','','Rapport','main',NULL,NULL,'$user->rights->pos->stats','1',0,'2013-03-13 20:33:09'),(103131,'all',2,'pos','left','@pos',103130,NULL,NULL,102,'/pos/backend/resultat/casoc.php','','ReportsCustomer','main',NULL,NULL,'$user->rights->pos->stats','1',0,'2013-03-13 20:33:09'),(103132,'all',2,'pos','left','@pos',103130,NULL,NULL,102,'/pos/backend/resultat/causer.php','','ReportsUser','main',NULL,NULL,'$user->rights->pos->stats','1',0,'2013-03-13 20:33:09'),(103133,'all',2,'pos','left','@pos',103130,NULL,NULL,102,'/pos/backend/resultat/sellsjournal.php','','ReportsSells','main',NULL,NULL,'$user->rights->pos->stats','1',0,'2013-03-13 20:33:09'),(103134,'all',2,'opensurvey','top','opensurvey',0,NULL,NULL,200,'/opensurvey/index.php','','Surveys','opensurvey',NULL,NULL,'$user->rights->opensurvey->survey->read','$conf->opensurvey->enabled',0,'2013-03-13 20:33:42'),(103135,'all',2,'opensurvey','left','opensurvey',-1,NULL,'opensurvey',200,'/opensurvey/index.php?mainmenu=opensurvey&leftmenu=opensurvey','','Survey','opensurvey@opensurvey',NULL,'opensurvey','','$conf->opensurvey->enabled',0,'2013-03-13 20:33:42'),(103136,'all',2,'opensurvey','left','opensurvey',-1,'opensurvey','opensurvey',210,'/opensurvey/public/index.php','_blank','NewSurvey','opensurvey@opensurvey',NULL,'opensurvey_new','','$conf->opensurvey->enabled',0,'2013-03-13 20:33:42'),(103137,'all',2,'opensurvey','left','opensurvey',-1,'opensurvey','opensurvey',220,'/opensurvey/list.php','','List','opensurvey@opensurvey',NULL,'opensurvey_list','','$conf->opensurvey->enabled',0,'2013-03-13 20:33:42'),(103160,'all',1,'cron','left','home',-1,'modulesadmintools','home',200,'/cron/list.php?status=1','','CronListActive','cron',NULL,NULL,'$user->rights->cron->read','$leftmenu==\'modulesadmintools\'',2,'2013-03-23 17:24:25'),(103161,'all',1,'cron','left','home',-1,'modulesadmintools','home',201,'/cron/list.php?status=0','','CronListInactive','cron',NULL,NULL,'$user->rights->cron->read','$leftmenu==\'modulesadmintools\'',2,'2013-03-23 17:24:25'),(103162,'auguria',1,'','top','home',0,NULL,NULL,1,'/index.php?mainmenu=home&leftmenu=','','Home','',-1,'','','1',2,'2013-03-24 02:31:47'),(103163,'auguria',1,'societe|fournisseur','top','companies',0,NULL,NULL,2,'/societe/index.php?mainmenu=companies&leftmenu=','','ThirdParties','companies',-1,'','$user->rights->societe->lire || $user->rights->societe->contact->lire','$conf->societe->enabled || $conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(103164,'auguria',1,'product|service','top','products',0,NULL,NULL,3,'/product/index.php?mainmenu=products&leftmenu=','','Products/Services','products',-1,'','$user->rights->produit->lire||$user->rights->service->lire','$conf->product->enabled || $conf->service->enabled',0,'2013-03-24 02:31:47'),(103166,'auguria',1,'propal|commande|fournisseur|contrat|ficheinter','top','commercial',0,NULL,NULL,5,'/comm/index.php?mainmenu=commercial&leftmenu=','','Commercial','commercial',-1,'','$user->rights->societe->lire || $user->rights->societe->contact->lire','$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled || $conf->tax->enabled',2,'2013-03-24 02:31:47'),(103167,'auguria',1,'comptabilite|accounting|facture|deplacement|don|tax','top','accountancy',0,NULL,NULL,6,'/compta/index.php?mainmenu=accountancy&leftmenu=','','MenuFinancial','compta',-1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->facture->lire|| $user->rights->deplacement->lire || $user->rights->don->lire || $user->rights->tax->charges->lire','$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled || $conf->tax->enabled',2,'2013-03-24 02:31:47'),(103168,'auguria',1,'projet','top','project',0,NULL,NULL,7,'/projet/index.php?mainmenu=project&leftmenu=','','Projects','projects',-1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(103169,'auguria',1,'mailing|export|import','top','tools',0,NULL,NULL,8,'/core/tools.php?mainmenu=tools&leftmenu=','','Tools','other',-1,'','$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run','$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled',2,'2013-03-24 02:31:47'),(103174,'auguria',1,'adherent','top','members',0,NULL,NULL,15,'/adherents/index.php?mainmenu=members&leftmenu=','','Members','members',-1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:47'),(103175,'auguria',1,'banque|prelevement','top','bank',0,NULL,NULL,6,'/compta/bank/index.php?mainmenu=bank&leftmenu=bank','','MenuBankCash','banks',-1,'','$user->rights->banque->lire || $user->rights->prelevement->bons->lire','$conf->banque->enabled || $conf->prelevement->enabled',0,'2013-03-24 02:31:47'),(103261,'auguria',1,'','left','home',103162,NULL,NULL,0,'/admin/index.php?leftmenu=setup','','Setup','admin',0,'setup','','$user->admin',2,'2013-03-24 02:31:47'),(103262,'auguria',1,'','left','home',103261,NULL,NULL,1,'/admin/company.php?leftmenu=setup','','MenuCompanySetup','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103263,'auguria',1,'','left','home',103261,NULL,NULL,4,'/admin/ihm.php?leftmenu=setup','','GUISetup','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103264,'auguria',1,'','left','home',103261,NULL,NULL,2,'/admin/modules.php?leftmenu=setup','','Modules','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103265,'auguria',1,'','left','home',103261,NULL,NULL,5,'/admin/boxes.php?leftmenu=setup','','Boxes','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103266,'auguria',1,'','left','home',103261,NULL,NULL,3,'/admin/menus.php?leftmenu=setup','','Menus','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103267,'auguria',1,'','left','home',103261,NULL,NULL,6,'/admin/delais.php?leftmenu=setup','','Alerts','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103268,'auguria',1,'','left','home',103261,NULL,NULL,9,'/admin/pdf.php?leftmenu=setup','','PDF','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103269,'auguria',1,'','left','home',103261,NULL,NULL,7,'/admin/proxy.php?leftmenu=setup','','Security','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103270,'auguria',1,'','left','home',103261,NULL,NULL,10,'/admin/mails.php?leftmenu=setup','','Emails','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103271,'auguria',1,'','left','home',103261,NULL,NULL,8,'/admin/limits.php?leftmenu=setup','','MenuLimits','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103272,'auguria',1,'','left','home',103261,NULL,NULL,12,'/admin/dict.php?leftmenu=setup','','DictionnarySetup','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103273,'auguria',1,'','left','home',103261,NULL,NULL,13,'/admin/const.php?leftmenu=setup','','OtherSetup','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103274,'auguria',1,'','left','home',103261,NULL,NULL,11,'/admin/sms.php?leftmenu=setup','','Sms','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103362,'auguria',1,'','left','home',103461,NULL,NULL,0,'/admin/system/dolibarr.php?leftmenu=admintools','','InfoDolibarr','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103364,'auguria',1,'','left','home',103461,NULL,NULL,13,'/admin/system/about.php?leftmenu=admintools','','About','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103365,'auguria',1,'','left','home',103461,NULL,NULL,1,'/admin/system/os.php?leftmenu=admintools','','InfoOS','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103366,'auguria',1,'','left','home',103461,NULL,NULL,2,'/admin/system/web.php?leftmenu=admintools','','InfoWebServer','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103367,'auguria',1,'','left','home',103461,NULL,NULL,3,'/admin/system/phpinfo.php?leftmenu=admintools','','InfoPHP','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103368,'auguria',1,'','left','home',103362,NULL,NULL,3,'/admin/triggers.php?leftmenu=admintools','','Triggers','admin',2,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103369,'auguria',1,'','left','home',103362,NULL,NULL,2,'/admin/system/modules.php?leftmenu=admintools','','Modules','admin',2,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103371,'auguria',1,'','left','home',103461,NULL,NULL,4,'/admin/system/database.php?leftmenu=admintools','','InfoDatabase','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103461,'auguria',1,'','left','home',103162,NULL,NULL,2,'/admin/tools/index.php?leftmenu=admintools','','SystemTools','admin',0,'admintools','','$user->admin',2,'2013-03-24 02:31:47'),(103462,'auguria',1,'','left','home',103461,NULL,NULL,5,'/admin/tools/dolibarr_export.php?leftmenu=admintools','','Backup','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103463,'auguria',1,'','left','home',103461,NULL,NULL,6,'/admin/tools/dolibarr_import.php?leftmenu=admintools','','Restore','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103464,'auguria',1,'','left','home',103461,NULL,NULL,11,'/admin/tools/purge.php?leftmenu=admintools','','Purge','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103465,'auguria',1,'','left','home',103461,NULL,NULL,8,'/admin/tools/eaccelerator.php?leftmenu=admintools','','EAccelerator','admin',1,'','','$leftmenu==\'admintools\' && function_exists(\'eaccelerator_info\')',2,'2013-03-24 02:31:47'),(103466,'auguria',1,'','left','home',103461,NULL,NULL,7,'/admin/tools/update.php?leftmenu=admintools','','MenuUpgrade','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103467,'auguria',1,'','left','home',103461,NULL,NULL,9,'/admin/tools/listevents.php?leftmenu=admintools','','Audit','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103468,'auguria',1,'','left','home',103461,NULL,NULL,12,'/support/index.php?leftmenu=admintools','_blank','HelpCenter','help',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103469,'auguria',1,'','left','home',103461,NULL,NULL,10,'/admin/tools/listsessions.php?leftmenu=admintools','','Sessions','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103561,'auguria',1,'','left','home',103162,NULL,NULL,3,'/user/home.php?leftmenu=users','','MenuUsersAndGroups','users',0,'users','','1',2,'2013-03-24 02:31:47'),(103562,'auguria',1,'','left','home',103561,NULL,NULL,0,'/user/index.php?leftmenu=users','','Users','users',1,'','$user->rights->user->user->lire || $user->admin','$leftmenu==\'users\'',2,'2013-03-24 02:31:47'),(103563,'auguria',1,'','left','home',103562,NULL,NULL,0,'/user/fiche.php?leftmenu=users&action=create','','NewUser','users',2,'','$user->rights->user->user->creer || $user->admin','$leftmenu==\'users\'',2,'2013-03-24 02:31:47'),(103564,'auguria',1,'','left','home',103561,NULL,NULL,1,'/user/group/index.php?leftmenu=users','','Groups','users',1,'','($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin','$leftmenu==\'users\'',2,'2013-03-24 02:31:47'),(103565,'auguria',1,'','left','home',103564,NULL,NULL,0,'/user/group/fiche.php?leftmenu=users&action=create','','NewGroup','users',2,'','($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin','$leftmenu==\'users\'',2,'2013-03-24 02:31:47'),(103661,'auguria',1,'','left','companies',103163,NULL,NULL,0,'/societe/index.php?leftmenu=thirdparties','','ThirdParty','companies',0,'thirdparties','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103662,'auguria',1,'','left','companies',103661,NULL,NULL,0,'/societe/soc.php?action=create','','MenuNewThirdParty','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103664,'auguria',1,'','left','companies',103661,NULL,NULL,5,'/fourn/liste.php?leftmenu=suppliers','','ListSuppliersShort','suppliers',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(103665,'auguria',1,'','left','companies',103664,NULL,NULL,0,'/societe/soc.php?leftmenu=supplier&action=create&type=f','','NewSupplier','suppliers',2,'','$user->rights->societe->creer','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(103667,'auguria',1,'','left','companies',103661,NULL,NULL,3,'/comm/prospect/list.php?leftmenu=prospects','','ListProspectsShort','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103668,'auguria',1,'','left','companies',103667,NULL,NULL,0,'/societe/soc.php?leftmenu=prospects&action=create&type=p','','MenuNewProspect','companies',2,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103670,'auguria',1,'','left','companies',103661,NULL,NULL,4,'/comm/list.php?leftmenu=customers','','ListCustomersShort','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103671,'auguria',1,'','left','companies',103670,NULL,NULL,0,'/societe/soc.php?leftmenu=customers&action=create&type=c','','MenuNewCustomer','companies',2,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103761,'auguria',1,'','left','companies',103163,NULL,NULL,1,'/contact/list.php?leftmenu=contacts','','ContactsAddresses','companies',0,'contacts','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103762,'auguria',1,'','left','companies',103761,NULL,NULL,0,'/contact/fiche.php?leftmenu=contacts&action=create','','NewContactAddress','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103763,'auguria',1,'','left','companies',103761,NULL,NULL,1,'/contact/list.php?leftmenu=contacts','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103765,'auguria',1,'','left','companies',103763,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=p','','Prospects','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103766,'auguria',1,'','left','companies',103763,NULL,NULL,2,'/contact/list.php?leftmenu=contacts&type=c','','Customers','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103767,'auguria',1,'','left','companies',103763,NULL,NULL,3,'/contact/list.php?leftmenu=contacts&type=f','','Suppliers','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(103768,'auguria',1,'','left','companies',103763,NULL,NULL,4,'/contact/list.php?leftmenu=contacts&type=o','','Others','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103811,'auguria',1,'','left','companies',103163,NULL,NULL,3,'/categories/index.php?leftmenu=cat&type=1','','SuppliersCategoriesShort','categories',0,'cat','$user->rights->categorie->lire','$conf->societe->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:47'),(103812,'auguria',1,'','left','companies',103811,NULL,NULL,0,'/categories/fiche.php?action=create&type=1','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->societe->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:47'),(103821,'auguria',1,'','left','companies',103163,NULL,NULL,4,'/categories/index.php?leftmenu=cat&type=2','','CustomersProspectsCategoriesShort','categories',0,'cat','$user->rights->categorie->lire','$conf->fournisseur->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:47'),(103822,'auguria',1,'','left','companies',103821,NULL,NULL,0,'/categories/fiche.php?action=create&type=2','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->fournisseur->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:47'),(104261,'auguria',1,'','left','commercial',103166,NULL,NULL,4,'/comm/propal/index.php?leftmenu=propals','','Prop','propal',0,'propals','$user->rights->propale->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(104262,'auguria',1,'','left','commercial',104261,NULL,NULL,0,'/societe/societe.php?leftmenu=propals','','NewPropal','propal',1,'','$user->rights->propale->creer','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(104263,'auguria',1,'','left','commercial',104261,NULL,NULL,1,'/comm/propal/list.php?leftmenu=propals','','List','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(104264,'auguria',1,'','left','commercial',104263,NULL,NULL,2,'/comm/propal/list.php?leftmenu=propals&viewstatut=0','','PropalsDraft','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104265,'auguria',1,'','left','commercial',104263,NULL,NULL,3,'/comm/propal/list.php?leftmenu=propals&viewstatut=1','','PropalsOpened','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104266,'auguria',1,'','left','commercial',104263,NULL,NULL,4,'/comm/propal/list.php?leftmenu=propals&viewstatut=2','','PropalStatusSigned','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104267,'auguria',1,'','left','commercial',104263,NULL,NULL,5,'/comm/propal/list.php?leftmenu=propals&viewstatut=3','','PropalStatusNotSigned','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104268,'auguria',1,'','left','commercial',104263,NULL,NULL,6,'/comm/propal/list.php?leftmenu=propals&viewstatut=4','','PropalStatusBilled','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104271,'auguria',1,'','left','commercial',104261,NULL,NULL,4,'/comm/propal/stats/index.php?leftmenu=propals','','Statistics','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(104361,'auguria',1,'','left','commercial',103166,NULL,NULL,5,'/commande/index.php?leftmenu=orders','','CustomersOrders','orders',0,'orders','$user->rights->commande->lire','$conf->commande->enabled',2,'2013-03-24 02:31:47'),(104362,'auguria',1,'','left','commercial',104361,NULL,NULL,0,'/societe/societe.php?leftmenu=orders','','NewOrder','orders',1,'','$user->rights->commande->creer','$conf->commande->enabled',2,'2013-03-24 02:31:47'),(104363,'auguria',1,'','left','commercial',104361,NULL,NULL,1,'/commande/liste.php?leftmenu=orders','','List','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled',2,'2013-03-24 02:31:47'),(104364,'auguria',1,'','left','commercial',104363,NULL,NULL,2,'/commande/liste.php?leftmenu=orders&viewstatut=0','','StatusOrderDraftShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104365,'auguria',1,'','left','commercial',104363,NULL,NULL,3,'/commande/liste.php?leftmenu=orders&viewstatut=1','','StatusOrderValidated','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104366,'auguria',1,'','left','commercial',104363,NULL,NULL,4,'/commande/liste.php?leftmenu=orders&viewstatut=2','','StatusOrderOnProcessShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104367,'auguria',1,'','left','commercial',104363,NULL,NULL,5,'/commande/liste.php?leftmenu=orders&viewstatut=3','','StatusOrderToBill','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104368,'auguria',1,'','left','commercial',104363,NULL,NULL,6,'/commande/liste.php?leftmenu=orders&viewstatut=4','','StatusOrderProcessed','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104369,'auguria',1,'','left','commercial',104363,NULL,NULL,7,'/commande/liste.php?leftmenu=orders&viewstatut=-1','','StatusOrderCanceledShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104370,'auguria',1,'','left','commercial',104361,NULL,NULL,4,'/commande/stats/index.php?leftmenu=orders','','Statistics','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled',2,'2013-03-24 02:31:47'),(104461,'auguria',1,'','left','commercial',103164,NULL,NULL,6,'/expedition/index.php?leftmenu=sendings','','Shipments','sendings',0,'sendings','$user->rights->expedition->lire','$conf->expedition->enabled',2,'2013-03-24 02:31:47'),(104462,'auguria',1,'','left','commercial',104461,NULL,NULL,0,'/expedition/fiche.php?action=create2&leftmenu=sendings','','NewSending','sendings',1,'','$user->rights->expedition->creer','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-03-24 02:31:47'),(104463,'auguria',1,'','left','commercial',104461,NULL,NULL,1,'/expedition/liste.php?leftmenu=sendings','','List','sendings',1,'','$user->rights->expedition->lire','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-03-24 02:31:47'),(104464,'auguria',1,'','left','commercial',104461,NULL,NULL,2,'/expedition/stats/index.php?leftmenu=sendings','','Statistics','sendings',1,'','$user->rights->expedition->lire','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-03-24 02:31:47'),(104561,'auguria',1,'','left','commercial',103166,NULL,NULL,7,'/contrat/index.php?leftmenu=contracts','','Contracts','contracts',0,'contracts','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-03-24 02:31:47'),(104562,'auguria',1,'','left','commercial',104561,NULL,NULL,0,'/societe/societe.php?leftmenu=contracts','','NewContract','contracts',1,'','$user->rights->contrat->creer','$conf->contrat->enabled',2,'2013-03-24 02:31:47'),(104563,'auguria',1,'','left','commercial',104561,NULL,NULL,1,'/contrat/liste.php?leftmenu=contracts','','List','contracts',1,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-03-24 02:31:47'),(104564,'auguria',1,'','left','commercial',104561,NULL,NULL,2,'/contrat/services.php?leftmenu=contracts','','MenuServices','contracts',1,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-03-24 02:31:47'),(104565,'auguria',1,'','left','commercial',104564,NULL,NULL,0,'/contrat/services.php?leftmenu=contracts&mode=0','','MenuInactiveServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-03-24 02:31:47'),(104566,'auguria',1,'','left','commercial',104564,NULL,NULL,1,'/contrat/services.php?leftmenu=contracts&mode=4','','MenuRunningServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-03-24 02:31:47'),(104567,'auguria',1,'','left','commercial',104564,NULL,NULL,2,'/contrat/services.php?leftmenu=contracts&mode=4&filter=expired','','MenuExpiredServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-03-24 02:31:47'),(104568,'auguria',1,'','left','commercial',104564,NULL,NULL,3,'/contrat/services.php?leftmenu=contracts&mode=5','','MenuClosedServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-03-24 02:31:47'),(104661,'auguria',1,'','left','commercial',103166,NULL,NULL,8,'/fichinter/list.php?leftmenu=ficheinter','','Interventions','interventions',0,'ficheinter','$user->rights->ficheinter->lire','$conf->ficheinter->enabled',2,'2013-03-24 02:31:47'),(104662,'auguria',1,'','left','commercial',104661,NULL,NULL,0,'/fichinter/fiche.php?action=create&leftmenu=ficheinter','','NewIntervention','interventions',1,'','$user->rights->ficheinter->creer','$conf->ficheinter->enabled',2,'2013-03-24 02:31:47'),(104663,'auguria',1,'','left','commercial',104661,NULL,NULL,1,'/fichinter/list.php?leftmenu=ficheinter','','List','interventions',1,'','$user->rights->ficheinter->lire','$conf->ficheinter->enabled',2,'2013-03-24 02:31:47'),(104761,'auguria',1,'','left','accountancy',103167,NULL,NULL,3,'/fourn/facture/index.php?leftmenu=suppliers_bills','','BillsSuppliers','bills',0,'supplier_bills','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104762,'auguria',1,'','left','accountancy',104761,NULL,NULL,0,'/fourn/facture/fiche.php?action=create&leftmenu=suppliers_bills','','NewBill','bills',1,'','$user->rights->fournisseur->facture->creer','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104763,'auguria',1,'','left','accountancy',104761,NULL,NULL,1,'/fourn/facture/impayees.php?leftmenu=suppliers_bills','','Unpaid','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104764,'auguria',1,'','left','accountancy',104761,NULL,NULL,2,'/fourn/facture/paiement.php?leftmenu=suppliers_bills','','Payments','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104765,'auguria',1,'','left','accountancy',104761,NULL,NULL,8,'/compta/facture/stats/index.php?leftmenu=customers_bills&mode=supplier','','Statistics','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104861,'auguria',1,'','left','accountancy',103167,NULL,NULL,3,'/compta/facture/list.php?leftmenu=customers_bills','','BillsCustomers','bills',0,'customer_bills','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104862,'auguria',1,'','left','accountancy',104861,NULL,NULL,3,'/compta/clients.php?action=facturer&leftmenu=customers_bills','','NewBill','bills',1,'','$user->rights->facture->creer','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104863,'auguria',1,'','left','accountancy',104861,NULL,NULL,4,'/compta/facture/fiche-rec.php?leftmenu=customers_bills','','Repeatable','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104864,'auguria',1,'','left','accountancy',104861,NULL,NULL,5,'/compta/facture/impayees.php?action=facturer&leftmenu=customers_bills','','Unpaid','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104865,'auguria',1,'','left','accountancy',104861,NULL,NULL,6,'/compta/paiement/liste.php?leftmenu=customers_bills','','Payments','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104871,'auguria',1,'','left','accountancy',104865,NULL,NULL,1,'/compta/paiement/rapport.php?leftmenu=customers_bills','','Reportings','bills',2,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104872,'auguria',1,'','left','accountancy',103175,NULL,NULL,9,'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank','','MenuChequeDeposits','bills',0,'checks','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-03-24 02:31:47'),(104873,'auguria',1,'','left','accountancy',104872,NULL,NULL,0,'/compta/paiement/cheque/fiche.php?leftmenu=checks&action=new','','NewCheckDeposit','compta',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-03-24 02:31:47'),(104874,'auguria',1,'','left','accountancy',104872,NULL,NULL,1,'/compta/paiement/cheque/liste.php?leftmenu=checks','','List','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-03-24 02:31:47'),(104875,'auguria',1,'','left','accountancy',104861,NULL,NULL,8,'/compta/facture/stats/index.php?leftmenu=customers_bills','','Statistics','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(105061,'auguria',1,'','left','accountancy',103167,NULL,NULL,3,'/commande/liste.php?leftmenu=orders&viewstatut=3','','MenuOrdersToBill','orders',0,'orders','$user->rights->commande->lire','$conf->commande->enabled',0,'2013-03-24 02:31:47'),(105161,'auguria',1,'','left','accountancy',103167,NULL,NULL,4,'/compta/dons/index.php?leftmenu=donations&mainmenu=accountancy','','Donations','donations',0,'donations','$user->rights->don->lire','$conf->don->enabled',2,'2013-03-24 02:31:47'),(105162,'auguria',1,'','left','accountancy',105161,NULL,NULL,0,'/compta/dons/fiche.php?leftmenu=donations&mainmenu=accountancy&action=create','','NewDonation','donations',1,'','$user->rights->don->creer','$conf->don->enabled && $leftmenu==\"donations\"',2,'2013-03-24 02:31:47'),(105163,'auguria',1,'','left','accountancy',105161,NULL,NULL,1,'/compta/dons/liste.php?leftmenu=donations&mainmenu=accountancy','','List','donations',1,'','$user->rights->don->lire','$conf->don->enabled && $leftmenu==\"donations\"',2,'2013-03-24 02:31:47'),(105261,'auguria',1,'','left','accountancy',103167,NULL,NULL,5,'/compta/deplacement/index.php?leftmenu=tripsandexpenses','','TripsAndExpenses','trips',0,'tripsandexpenses','$user->rights->deplacement->lire','$conf->deplacement->enabled',0,'2013-03-24 02:31:47'),(105262,'auguria',1,'','left','accountancy',105261,NULL,NULL,1,'/compta/deplacement/fiche.php?action=create&leftmenu=tripsandexpenses','','New','trips',1,'','$user->rights->deplacement->creer','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-03-24 02:31:47'),(105263,'auguria',1,'','left','accountancy',105261,NULL,NULL,2,'/compta/deplacement/list.php?leftmenu=tripsandexpenses','','List','trips',1,'','$user->rights->deplacement->lire','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-03-24 02:31:47'),(105264,'auguria',1,'','left','accountancy',105261,NULL,NULL,2,'/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses','','Statistics','trips',1,'','$user->rights->deplacement->lire','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-03-24 02:31:47'),(105361,'auguria',1,'','left','accountancy',103167,NULL,NULL,6,'/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy','','MenuTaxAndDividends','compta',0,'tax','$user->rights->tax->charges->lire','$conf->tax->enabled',0,'2013-03-24 02:31:47'),(105362,'auguria',1,'','left','accountancy',105361,NULL,NULL,1,'/compta/sociales/index.php?leftmenu=tax_social','','SocialContributions','',1,'tax_social','$user->rights->tax->charges->lire','$conf->tax->enabled',0,'2013-03-24 02:31:47'),(105363,'auguria',1,'','left','accountancy',105362,NULL,NULL,2,'/compta/sociales/charges.php?leftmenu=tax_social&action=create','','MenuNewSocialContribution','',2,'','$user->rights->tax->charges->creer','$conf->tax->enabled && $leftmenu==\"tax_social\"',0,'2013-03-24 02:31:47'),(105364,'auguria',1,'','left','accountancy',105362,NULL,NULL,3,'/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly','','Payments','',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && $leftmenu==\"tax_social\"',0,'2013-03-24 02:31:47'),(105461,'auguria',1,'','left','accountancy',105361,NULL,NULL,7,'/compta/tva/index.php?leftmenu=tax_vat&mainmenu=accountancy','','VAT','companies',1,'tax_vat','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS)',0,'2013-03-24 02:31:47'),(105462,'auguria',1,'','left','accountancy',105461,NULL,NULL,0,'/compta/tva/fiche.php?leftmenu=tax_vat&action=create','','NewPayment','companies',2,'','$user->rights->tax->charges->creer','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-03-24 02:31:47'),(105463,'auguria',1,'','left','accountancy',105461,NULL,NULL,1,'/compta/tva/reglement.php?leftmenu=tax_vat','','Payments','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-03-24 02:31:47'),(105464,'auguria',1,'','left','accountancy',105461,NULL,NULL,2,'/compta/tva/clients.php?leftmenu=tax_vat','','ReportByCustomers','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-03-24 02:31:47'),(105465,'auguria',1,'','left','accountancy',105461,NULL,NULL,3,'/compta/tva/quadri_detail.php?leftmenu=tax_vat','','ReportByQuarter','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-03-24 02:31:47'),(105561,'auguria',1,'','left','accountancy',103167,NULL,NULL,8,'/compta/ventilation/index.php?leftmenu=ventil','','Ventilation','companies',0,'ventil','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105562,'auguria',1,'','left','accountancy',105561,NULL,NULL,0,'/compta/ventilation/liste.php','','ToDispatch','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105563,'auguria',1,'','left','accountancy',105561,NULL,NULL,1,'/compta/ventilation/lignes.php','','Dispatched','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105564,'auguria',1,'','left','accountancy',105561,NULL,NULL,2,'/compta/param/','','Setup','companies',1,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105565,'auguria',1,'','left','accountancy',105564,NULL,NULL,0,'/compta/param/comptes/liste.php','','List','companies',2,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105566,'auguria',1,'','left','accountancy',105564,NULL,NULL,1,'/compta/param/comptes/fiche.php?action=create','','New','companies',2,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105567,'auguria',1,'','left','accountancy',105561,NULL,NULL,3,'/compta/export/','','Export','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105568,'auguria',1,'','left','accountancy',105567,NULL,NULL,0,'/compta/export/index.php','','New','companies',2,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105569,'auguria',1,'','left','accountancy',105567,NULL,NULL,1,'/compta/export/liste.php','','List','companies',2,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105661,'auguria',1,'','left','accountancy',103175,NULL,NULL,9,'/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank','','StandingOrders','withdrawals',0,'withdraw','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled',2,'2013-03-24 02:31:47'),(105663,'auguria',1,'','left','accountancy',105661,NULL,NULL,0,'/compta/prelevement/create.php?leftmenu=withdraw','','NewStandingOrder','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105664,'auguria',1,'','left','accountancy',105661,NULL,NULL,2,'/compta/prelevement/bons.php?leftmenu=withdraw','','WithdrawalsReceipts','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105665,'auguria',1,'','left','accountancy',105661,NULL,NULL,3,'/compta/prelevement/liste.php?leftmenu=withdraw','','WithdrawalsLines','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105667,'auguria',1,'','left','accountancy',105661,NULL,NULL,5,'/compta/prelevement/rejets.php?leftmenu=withdraw','','Rejects','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105668,'auguria',1,'','left','accountancy',105661,NULL,NULL,6,'/compta/prelevement/stats.php?leftmenu=withdraw','','Statistics','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105761,'auguria',1,'','left','accountancy',103175,NULL,NULL,1,'/compta/bank/index.php?leftmenu=bank&mainmenu=bank','','MenuBankCash','banks',0,'bank','$user->rights->banque->lire','$conf->banque->enabled',0,'2013-03-24 02:31:47'),(105762,'auguria',1,'','left','accountancy',105761,NULL,NULL,0,'/compta/bank/fiche.php?action=create&leftmenu=bank','','MenuNewFinancialAccount','banks',1,'','$user->rights->banque->configurer','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105763,'auguria',1,'','left','accountancy',105761,NULL,NULL,1,'/compta/bank/categ.php?leftmenu=bank','','Rubriques','categories',1,'','$user->rights->banque->configurer','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105764,'auguria',1,'','left','accountancy',105761,NULL,NULL,2,'/compta/bank/search.php?leftmenu=bank','','ListTransactions','banks',1,'','$user->rights->banque->lire','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105765,'auguria',1,'','left','accountancy',105761,NULL,NULL,3,'/compta/bank/budget.php?leftmenu=bank','','ListTransactionsByCategory','banks',1,'','$user->rights->banque->lire','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105767,'auguria',1,'','left','accountancy',105761,NULL,NULL,5,'/compta/bank/virement.php?leftmenu=bank','','BankTransfers','banks',1,'','$user->rights->banque->transfer','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105861,'auguria',1,'','left','accountancy',103167,NULL,NULL,11,'/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy','','Reportings','main',0,'ca','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105862,'auguria',1,'','left','accountancy',105861,NULL,NULL,0,'/compta/resultat/index.php?leftmenu=ca','','ReportInOut','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105863,'auguria',1,'','left','accountancy',105862,NULL,NULL,0,'/compta/resultat/clientfourn.php?leftmenu=ca','','ByCompanies','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105864,'auguria',1,'','left','accountancy',105861,NULL,NULL,1,'/compta/stats/index.php?leftmenu=ca','','ReportTurnover','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105865,'auguria',1,'','left','accountancy',105864,NULL,NULL,0,'/compta/stats/casoc.php?leftmenu=ca','','ByCompanies','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105866,'auguria',1,'','left','accountancy',105864,NULL,NULL,1,'/compta/stats/cabyuser.php?leftmenu=ca','','ByUsers','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105867,'auguria',1,'','left','accountancy',105861,NULL,NULL,1,'/compta/journal/sellsjournal.php?leftmenu=ca','','SellsJournal','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105868,'auguria',1,'','left','accountancy',105861,NULL,NULL,1,'/compta/journal/purchasesjournal.php?leftmenu=ca','','PurchasesJournal','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105961,'auguria',1,'','left','products',103164,NULL,NULL,0,'/product/index.php?leftmenu=product&type=0','','Products','products',0,'product','$user->rights->produit->lire','$conf->product->enabled',2,'2013-03-24 02:31:47'),(105962,'auguria',1,'','left','products',105961,NULL,NULL,0,'/product/fiche.php?leftmenu=product&action=create&type=0','','NewProduct','products',1,'','$user->rights->produit->creer','$conf->product->enabled',2,'2013-03-24 02:31:47'),(105963,'auguria',1,'','left','products',105961,NULL,NULL,1,'/product/liste.php?leftmenu=product&type=0','','List','products',1,'','$user->rights->produit->lire','$conf->product->enabled',2,'2013-03-24 02:31:47'),(105964,'auguria',1,'','left','products',105961,NULL,NULL,4,'/product/reassort.php?type=0','','Stocks','products',1,'','$user->rights->produit->lire && $user->rights->stock->lire','$conf->product->enabled',2,'2013-03-24 02:31:47'),(105965,'auguria',1,'','left','products',105961,NULL,NULL,5,'/product/popuprop.php?leftmenu=stats&type=0','','Statistics','main',1,'','$user->rights->produit->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(106061,'auguria',1,'','left','products',103164,NULL,NULL,1,'/product/index.php?leftmenu=service&type=1','','Services','products',0,'service','$user->rights->service->lire','$conf->service->enabled',2,'2013-03-24 02:31:47'),(106062,'auguria',1,'','left','products',106061,NULL,NULL,0,'/product/fiche.php?leftmenu=service&action=create&type=1','','NewService','products',1,'','$user->rights->service->creer','$conf->service->enabled',2,'2013-03-24 02:31:47'),(106063,'auguria',1,'','left','products',106061,NULL,NULL,1,'/product/liste.php?leftmenu=service&type=1','','List','products',1,'','$user->rights->service->lire','$conf->service->enabled',2,'2013-03-24 02:31:47'),(106064,'auguria',1,'','left','products',106061,NULL,NULL,5,'/product/popuprop.php?leftmenu=stats&type=1','','Statistics','main',1,'','$user->rights->service->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(106261,'auguria',1,'','left','products',103164,NULL,NULL,3,'/product/stock/index.php?leftmenu=stock','','Stock','stocks',0,'stock','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106262,'auguria',1,'','left','products',106261,NULL,NULL,0,'/product/stock/fiche.php?action=create','','MenuNewWarehouse','stocks',1,'','$user->rights->stock->creer','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106263,'auguria',1,'','left','products',106261,NULL,NULL,1,'/product/stock/liste.php','','List','stocks',1,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106264,'auguria',1,'','left','products',106261,NULL,NULL,2,'/product/stock/valo.php','','EnhancedValue','stocks',1,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106265,'auguria',1,'','left','products',106261,NULL,NULL,3,'/product/stock/mouvement.php','','Movements','stocks',1,'','$user->rights->stock->mouvement->lire','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106361,'auguria',1,'','left','products',103164,NULL,NULL,4,'/categories/index.php?leftmenu=cat&type=0','','Categories','categories',0,'cat','$user->rights->categorie->lire','$conf->categorie->enabled',2,'2013-03-24 02:31:47'),(106362,'auguria',1,'','left','products',106361,NULL,NULL,0,'/categories/fiche.php?action=create&type=0','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->categorie->enabled',2,'2013-03-24 02:31:47'),(106761,'auguria',1,'','left','project',103168,NULL,NULL,0,'/projet/index.php?leftmenu=projects','','Projects','projects',0,'projects','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106762,'auguria',1,'','left','project',106761,NULL,NULL,1,'/projet/fiche.php?leftmenu=projects&action=create','','NewProject','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106763,'auguria',1,'','left','project',106761,NULL,NULL,2,'/projet/liste.php?leftmenu=projects','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106771,'auguria',1,'','left','project',103168,NULL,NULL,0,'/projet/index.php?leftmenu=projects&mode=mine','','MyProjects','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106772,'auguria',1,'','left','project',106771,NULL,NULL,1,'/projet/fiche.php?leftmenu=projects&action=create&mode=mine','','NewProject','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106773,'auguria',1,'','left','project',106771,NULL,NULL,2,'/projet/liste.php?leftmenu=projects&mode=mine','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106861,'auguria',1,'','left','project',103168,NULL,NULL,0,'/projet/activity/index.php?leftmenu=projects','','Activities','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106862,'auguria',1,'','left','project',106861,NULL,NULL,1,'/projet/tasks.php?leftmenu=projects&action=create','','NewTask','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106863,'auguria',1,'','left','project',106861,NULL,NULL,2,'/projet/tasks/index.php?leftmenu=projects','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106864,'auguria',1,'','left','project',106861,NULL,NULL,3,'/projet/activity/list.php?leftmenu=projects','','NewTimeSpent','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106961,'auguria',1,'','left','project',103168,NULL,NULL,0,'/projet/activity/index.php?leftmenu=projects&mode=mine','','MyActivities','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106962,'auguria',1,'','left','project',106961,NULL,NULL,1,'/projet/tasks.php?leftmenu=projects&action=create&mode=mine','','NewTask','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106963,'auguria',1,'','left','project',106961,NULL,NULL,2,'/projet/tasks/index.php?leftmenu=projects&mode=mine','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106964,'auguria',1,'','left','project',106961,NULL,NULL,3,'/projet/activity/list.php?leftmenu=projects&mode=mine','','NewTimeSpent','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(107061,'auguria',1,'','left','tools',103169,NULL,NULL,0,'/comm/mailing/index.php?leftmenu=mailing','','EMailings','mails',0,'mailing','$user->rights->mailing->lire','$conf->mailing->enabled',0,'2013-03-24 02:31:47'),(107062,'auguria',1,'','left','tools',107061,NULL,NULL,0,'/comm/mailing/fiche.php?leftmenu=mailing&action=create','','NewMailing','mails',1,'','$user->rights->mailing->creer','$conf->mailing->enabled',0,'2013-03-24 02:31:47'),(107063,'auguria',1,'','left','tools',107061,NULL,NULL,1,'/comm/mailing/liste.php?leftmenu=mailing','','List','mails',1,'','$user->rights->mailing->lire','$conf->mailing->enabled',0,'2013-03-24 02:31:47'),(107261,'auguria',1,'','left','tools',103169,NULL,NULL,2,'/exports/index.php?leftmenu=export','','FormatedExport','exports',0,'export','$user->rights->export->lire','$conf->export->enabled',2,'2013-03-24 02:31:47'),(107262,'auguria',1,'','left','tools',107261,NULL,NULL,0,'/exports/export.php?leftmenu=export','','NewExport','exports',1,'','$user->rights->export->creer','$conf->export->enabled',2,'2013-03-24 02:31:47'),(107291,'auguria',1,'','left','tools',103169,NULL,NULL,2,'/imports/index.php?leftmenu=import','','FormatedImport','exports',0,'import','$user->rights->import->run','$conf->import->enabled',2,'2013-03-24 02:31:47'),(107292,'auguria',1,'','left','tools',107291,NULL,NULL,0,'/imports/import.php?leftmenu=import','','NewImport','exports',1,'','$user->rights->import->run','$conf->import->enabled',2,'2013-03-24 02:31:47'),(107361,'auguria',1,'','left','members',103174,NULL,NULL,0,'/adherents/index.php?leftmenu=members&mainmenu=members','','Members','members',0,'members','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107362,'auguria',1,'','left','members',107361,NULL,NULL,0,'/adherents/fiche.php?leftmenu=members&action=create','','NewMember','members',1,'','$user->rights->adherent->creer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107363,'auguria',1,'','left','members',107361,NULL,NULL,1,'/adherents/liste.php','','List','members',1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107364,'auguria',1,'','left','members',107363,NULL,NULL,2,'/adherents/liste.php?leftmenu=members&statut=-1','','MenuMembersToValidate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107365,'auguria',1,'','left','members',107363,NULL,NULL,3,'/adherents/liste.php?leftmenu=members&statut=1','','MenuMembersValidated','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107366,'auguria',1,'','left','members',107363,NULL,NULL,4,'/adherents/liste.php?leftmenu=members&statut=1&filter=outofdate','','MenuMembersNotUpToDate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107367,'auguria',1,'','left','members',107363,NULL,NULL,5,'/adherents/liste.php?leftmenu=members&statut=1&filter=uptodate','','MenuMembersUpToDate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107368,'auguria',1,'','left','members',107363,NULL,NULL,6,'/adherents/liste.php?leftmenu=members&statut=0','','MenuMembersResiliated','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107369,'auguria',1,'','left','members',107361,NULL,NULL,7,'/adherents/stats/geo.php?leftmenu=members&mode=memberbycountry','','MenuMembersStats','members',1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107461,'auguria',1,'','left','members',103174,NULL,NULL,1,'/adherents/index.php?leftmenu=members&mainmenu=members','','Subscriptions','compta',0,'','$user->rights->adherent->cotisation->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107462,'auguria',1,'','left','members',107461,NULL,NULL,0,'/adherents/liste.php?statut=-1&leftmenu=accountancy&mainmenu=members','','NewSubscription','compta',1,'','$user->rights->adherent->cotisation->creer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107463,'auguria',1,'','left','members',107461,NULL,NULL,1,'/adherents/cotisations.php?leftmenu=members','','List','compta',1,'','$user->rights->adherent->cotisation->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107464,'auguria',1,'','left','members',107461,NULL,NULL,7,'/adherents/stats/index.php?leftmenu=members','','MenuMembersStats','members',1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107661,'auguria',1,'','left','members',103174,NULL,NULL,3,'/adherents/index.php?leftmenu=export&mainmenu=members','','Exports','members',0,'export','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107662,'auguria',1,'','left','members',107661,NULL,NULL,0,'/exports/index.php?leftmenu=export','','Datas','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled && $conf->export->enabled',2,'2013-03-24 02:31:48'),(107663,'auguria',1,'','left','members',107661,NULL,NULL,1,'/adherents/htpasswd.php?leftmenu=export','','Filehtpasswd','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107664,'auguria',1,'','left','members',107661,NULL,NULL,2,'/adherents/cartes/carte.php?leftmenu=export','','MembersCards','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107861,'auguria',1,'','left','members',103174,NULL,NULL,5,'/adherents/type.php?leftmenu=setup&mainmenu=members','','MembersTypes','members',0,'setup','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107862,'auguria',1,'','left','members',107861,NULL,NULL,0,'/adherents/type.php?leftmenu=setup&mainmenu=members&action=create','','New','members',1,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107863,'auguria',1,'','left','members',107861,NULL,NULL,1,'/adherents/type.php?leftmenu=setup&mainmenu=members','','List','members',1,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(108261,'auguria',1,'','left','commercial',103166,NULL,NULL,6,'/fourn/commande/index.php?leftmenu=orders_suppliers','','SuppliersOrders','orders',0,'orders_suppliers','$user->rights->fournisseur->commande->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(108262,'auguria',1,'','left','commercial',108261,NULL,NULL,0,'/societe/societe.php?leftmenu=orders_suppliers','','NewOrder','orders',1,'','$user->rights->fournisseur->commande->creer','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(108263,'auguria',1,'','left','commercial',108261,NULL,NULL,1,'/fourn/commande/liste.php?leftmenu=orders_suppliers&viewstatut=0','','List','orders',1,'','$user->rights->fournisseur->commande->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(108269,'auguria',1,'','left','commercial',108261,NULL,NULL,7,'/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier','','Statistics','orders',1,'','$user->rights->fournisseur->commande->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(108361,'auguria',1,'','left','members',103174,NULL,NULL,3,'/categories/index.php?leftmenu=cat&type=3','','MembersCategoriesShort','categories',0,'cat','$user->rights->categorie->lire','$conf->adherent->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:48'),(108362,'auguria',1,'','left','members',108361,NULL,NULL,0,'/categories/fiche.php?action=create&type=3','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->adherent->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:48'),(108457,'all',1,'barcode','left','tools',-1,NULL,'tools',200,'/barcode/printsheet.php?mainmenu=home&leftmenu=modulesadmintools','','BarCodePrintsheet','products',NULL,'barcodeprint','1','$conf->barcode->enabled',2,'2014-03-02 15:37:26'),(108458,'all',1,'barcode','left','home',-1,'modulesadmintools','home',300,'/barcode/codeinit.php?mainmenu=home&leftmenu=modulesadmintools','','MassBarcodeInit','products',NULL,NULL,'1','$conf->barcode->enabled && $leftmenu==\"modulesadmintools\"',0,'2014-03-02 15:37:26'),(108459,'all',1,'agenda','top','agenda',0,NULL,NULL,100,'/comm/action/index.php','','Agenda','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108460,'all',1,'agenda','left','agenda',108459,NULL,NULL,100,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda','','Actions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108461,'all',1,'agenda','left','agenda',108460,NULL,NULL,101,'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create','','NewAction','commercial',NULL,NULL,'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108462,'all',1,'agenda','left','agenda',108460,NULL,NULL,102,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda','','Calendar','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108463,'all',1,'agenda','left','agenda',108462,NULL,NULL,103,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine','','MenuToDoMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108464,'all',1,'agenda','left','agenda',108462,NULL,NULL,104,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine','','MenuDoneMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108465,'all',1,'agenda','left','agenda',108462,NULL,NULL,105,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo','','MenuToDoActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2014-12-21 12:51:26'),(108466,'all',1,'agenda','left','agenda',108462,NULL,NULL,106,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done','','MenuDoneActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2014-12-21 12:51:26'),(108467,'all',1,'agenda','left','agenda',108460,NULL,NULL,112,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda','','List','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108468,'all',1,'agenda','left','agenda',108467,NULL,NULL,113,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine','','MenuToDoMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108469,'all',1,'agenda','left','agenda',108467,NULL,NULL,114,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine','','MenuDoneMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108470,'all',1,'agenda','left','agenda',108467,NULL,NULL,115,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=todo','','MenuToDoActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2014-12-21 12:51:26'),(108471,'all',1,'agenda','left','agenda',108467,NULL,NULL,116,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=done','','MenuDoneActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2014-12-21 12:51:26'),(108472,'all',1,'agenda','left','agenda',108460,NULL,NULL,120,'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda','','Reportings','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108473,'all',1,'ecm','top','ecm',0,NULL,NULL,100,'/ecm/index.php','','MenuECM','ecm',NULL,NULL,'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup','$conf->ecm->enabled',2,'2014-12-21 12:51:28'),(108474,'all',1,'ecm','left','ecm',-1,NULL,'ecm',101,'/ecm/index.php?mainmenu=ecm&leftmenu=ecm','','ECMArea','ecm',NULL,'ecm','$user->rights->ecm->read || $user->rights->ecm->upload','$user->rights->ecm->read || $user->rights->ecm->upload',2,'2014-12-21 12:51:28'),(108475,'all',1,'ecm','left','ecm',-1,'ecm','ecm',102,'/ecm/index.php?action=file_manager&mainmenu=ecm&leftmenu=ecm','','ECMSectionsManual','ecm',NULL,'ecm_manual','$user->rights->ecm->read || $user->rights->ecm->upload','$user->rights->ecm->read || $user->rights->ecm->upload',2,'2014-12-21 12:51:28'),(108476,'all',1,'ecm','left','ecm',-1,'ecm','ecm',103,'/ecm/index_auto.php?action=file_manager&mainmenu=ecm&leftmenu=ecm','','ECMSectionsAuto','ecm',NULL,NULL,'$user->rights->ecm->read || $user->rights->ecm->upload','$user->rights->ecm->read || $user->rights->ecm->upload',2,'2014-12-21 12:51:28'),(108477,'all',1,'opensurvey','left','tools',-1,NULL,'tools',200,'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey','','Survey','opensurvey',NULL,'opensurvey','','$conf->opensurvey->enabled',0,'2014-12-21 19:52:31'),(108478,'all',1,'opensurvey','left','tools',-1,'opensurvey','tools',210,'/opensurvey/wizard/index.php','','NewSurvey','opensurvey',NULL,'opensurvey_new','$user->rights->opensurvey->write','$conf->opensurvey->enabled',0,'2014-12-21 19:52:31'),(108479,'all',1,'opensurvey','left','tools',-1,'opensurvey','tools',220,'/opensurvey/list.php','','List','opensurvey',NULL,'opensurvey_list','','$conf->opensurvey->enabled',0,'2014-12-21 19:52:31'); +INSERT INTO `llx_menu` VALUES (19289,'all',1,'cashdesk','top','cashdesk',0,NULL,NULL,100,'/cashdesk/index.php?user=__LOGIN__','pointofsale','CashDeskMenu','cashdesk',NULL,NULL,'1','$conf->cashdesk->enabled',0,'2012-12-08 13:11:09'),(87422,'smartphone',1,NULL,'top','home',0,NULL,NULL,1,'/index.php?mainmenu=home&leftmenu=','','Home','',-1,'','','1',2,'2013-02-24 18:29:15'),(87423,'smartphone',1,NULL,'top','companies',0,NULL,NULL,2,'/societe/index.php?mainmenu=companies&leftmenu=','','ThirdParties','companies',-1,'','$user->rights->societe->lire || $user->rights->societe->contact->lire','$conf->societe->enabled || $conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(87424,'smartphone',1,NULL,'top','products',0,NULL,NULL,3,'/product/index.php?mainmenu=products&leftmenu=','','Products/Services','products',-1,'','$user->rights->produit->lire||$user->rights->service->lire','$conf->product->enabled || $conf->service->enabled',0,'2013-02-24 18:29:15'),(87426,'smartphone',1,NULL,'top','commercial',0,NULL,NULL,5,'/comm/index.php?mainmenu=commercial&leftmenu=','','Commercial','commercial',-1,'','$user->rights->societe->lire || $user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87427,'smartphone',1,NULL,'top','accountancy',0,NULL,NULL,6,'/compta/index.php?mainmenu=accountancy&leftmenu=','','MenuFinancial','compta',-1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->commande->lire || $user->rights->facture->lire','$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled',2,'2013-02-24 18:29:15'),(87428,'smartphone',1,NULL,'top','project',0,NULL,NULL,7,'/projet/index.php?mainmenu=project&leftmenu=','','Projects','projects',-1,'','$user->rights->projet->lire','$conf->projet->enabled',0,'2013-02-24 18:29:15'),(87429,'smartphone',1,NULL,'top','tools',0,NULL,NULL,8,'/core/tools.php?mainmenu=tools&leftmenu=','','Tools','other',-1,'','$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run','$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled',2,'2013-02-24 18:29:15'),(87432,'smartphone',1,NULL,'top','shop',0,NULL,NULL,11,'/boutique/index.php?mainmenu=shop&leftmenu=','','OSCommerce','shop',-1,'','','! empty($conf->boutique->enabled)',0,'2013-02-24 18:29:15'),(87434,'smartphone',1,NULL,'top','members',0,NULL,NULL,15,'/adherents/index.php?mainmenu=members&leftmenu=','','Members','members',-1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(87435,'smartphone',1,NULL,'top','bank',0,NULL,NULL,6,'/compta/bank/index.php?mainmenu=bank&leftmenu=bank','','MenuBankCash','banks',-1,'','$user->rights->banque->lire || $user->rights->prelevement->bons->lire','$conf->banque->enabled || $conf->prelevement->enabled',2,'2013-02-24 18:29:15'),(87521,'smartphone',1,NULL,'left','home',87422,NULL,NULL,0,'/admin/index.php?leftmenu=setup','','Setup','admin',0,'','','$user->admin',2,'2013-02-24 18:29:15'),(87522,'smartphone',1,NULL,'left','home',87521,NULL,NULL,1,'/admin/company.php?leftmenu=setup','','MenuCompanySetup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87523,'smartphone',1,NULL,'left','home',87521,NULL,NULL,4,'/admin/ihm.php?leftmenu=setup','','GUISetup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87524,'smartphone',1,NULL,'left','home',87521,NULL,NULL,2,'/admin/modules.php?leftmenu=setup','','Modules','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87525,'smartphone',1,NULL,'left','home',87521,NULL,NULL,5,'/admin/boxes.php?leftmenu=setup','','Boxes','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87526,'smartphone',1,NULL,'left','home',87521,NULL,NULL,3,'/admin/menus.php?leftmenu=setup','','Menus','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87527,'smartphone',1,NULL,'left','home',87521,NULL,NULL,6,'/admin/delais.php?leftmenu=setup','','Alerts','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87529,'smartphone',1,NULL,'left','home',87521,NULL,NULL,7,'/admin/perms.php?leftmenu=setup','','Security','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87530,'smartphone',1,NULL,'left','home',87521,NULL,NULL,9,'/admin/mails.php?leftmenu=setup','','Emails','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87531,'smartphone',1,NULL,'left','home',87521,NULL,NULL,8,'/admin/limits.php?leftmenu=setup','','MenuLimits','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87532,'smartphone',1,NULL,'left','home',87521,NULL,NULL,10,'/admin/dict.php?leftmenu=setup','','DictionarySetup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87533,'smartphone',1,NULL,'left','home',87521,NULL,NULL,11,'/admin/const.php?leftmenu=setup','','OtherSetup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87621,'smartphone',1,NULL,'left','home',87422,NULL,NULL,1,'/admin/system/index.php?leftmenu=system','','SystemInfo','admin',0,'','','$user->admin',2,'2013-02-24 18:29:15'),(87622,'smartphone',1,NULL,'left','home',87621,NULL,NULL,0,'/admin/system/dolibarr.php?leftmenu=system','','Dolibarr','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87623,'smartphone',1,NULL,'left','home',87622,NULL,NULL,1,'/admin/system/constall.php?leftmenu=system','','AllParameters','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87624,'smartphone',1,NULL,'left','home',87622,NULL,NULL,4,'/admin/system/about.php?leftmenu=system','','About','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87625,'smartphone',1,NULL,'left','home',87621,NULL,NULL,1,'/admin/system/os.php?leftmenu=system','','OS','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87626,'smartphone',1,NULL,'left','home',87621,NULL,NULL,2,'/admin/system/web.php?leftmenu=system','','WebServer','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87627,'smartphone',1,NULL,'left','home',87621,NULL,NULL,3,'/admin/system/phpinfo.php?leftmenu=system','','Php','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87628,'smartphone',1,NULL,'left','home',87622,NULL,NULL,3,'/admin/triggers.php?leftmenu=system','','Triggers','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87629,'smartphone',1,NULL,'left','home',87622,NULL,NULL,2,'/admin/system/modules.php?leftmenu=system','','Modules','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87631,'smartphone',1,NULL,'left','home',87621,NULL,NULL,4,'/admin/system/database.php?leftmenu=system','','Database','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87632,'smartphone',1,NULL,'left','home',87631,NULL,NULL,0,'/admin/system/database-tables.php?leftmenu=system','','Tables','admin',2,'','','1',2,'2013-02-24 18:29:15'),(87721,'smartphone',1,NULL,'left','home',87422,NULL,NULL,2,'/admin/tools/index.php?leftmenu=admintools','','SystemTools','admin',0,'','','$user->admin',2,'2013-02-24 18:29:15'),(87722,'smartphone',1,NULL,'left','home',87721,NULL,NULL,0,'/admin/tools/dolibarr_export.php?leftmenu=admintools','','Backup','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87723,'smartphone',1,NULL,'left','home',87721,NULL,NULL,1,'/admin/tools/dolibarr_import.php?leftmenu=admintools','','Restore','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87724,'smartphone',1,NULL,'left','home',87721,NULL,NULL,6,'/admin/tools/purge.php?leftmenu=admintools','','Purge','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87725,'smartphone',1,NULL,'left','home',87721,NULL,NULL,3,'/admin/tools/eaccelerator.php?leftmenu=admintools','','EAccelerator','admin',1,'','','1 && function_exists(\'eaccelerator_info\')',2,'2013-02-24 18:29:15'),(87726,'smartphone',1,NULL,'left','home',87721,NULL,NULL,2,'/admin/tools/update.php?leftmenu=admintools','','MenuUpgrade','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87727,'smartphone',1,NULL,'left','home',87721,NULL,NULL,4,'/admin/tools/listevents.php?leftmenu=admintools','','Audit','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87728,'smartphone',1,NULL,'left','home',87721,NULL,NULL,7,'/support/index.php?leftmenu=admintools','_blank','HelpCenter','help',1,'','','1',2,'2013-02-24 18:29:15'),(87729,'smartphone',1,NULL,'left','home',87721,NULL,NULL,5,'/admin/tools/listsessions.php?leftmenu=admintools','','Sessions','admin',1,'','','1',2,'2013-02-24 18:29:15'),(87821,'smartphone',1,NULL,'left','home',87422,NULL,NULL,3,'/user/home.php?leftmenu=users','','MenuUsersAndGroups','users',0,'','','1',2,'2013-02-24 18:29:15'),(87822,'smartphone',1,NULL,'left','home',87821,NULL,NULL,0,'/user/index.php?leftmenu=users','','Users','users',1,'','$user->rights->user->user->lire || $user->admin','1',2,'2013-02-24 18:29:15'),(87823,'smartphone',1,NULL,'left','home',87822,NULL,NULL,0,'/user/card.php?leftmenu=users&action=create','','NewUser','users',2,'','$user->rights->user->user->creer || $user->admin','1',2,'2013-02-24 18:29:15'),(87824,'smartphone',1,NULL,'left','home',87821,NULL,NULL,1,'/user/group/index.php?leftmenu=users','','Groups','users',1,'','($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin','1',2,'2013-02-24 18:29:15'),(87825,'smartphone',1,NULL,'left','home',87824,NULL,NULL,0,'/user/group/card.php?leftmenu=users&action=create','','NewGroup','users',2,'','($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin','1',2,'2013-02-24 18:29:15'),(87921,'smartphone',1,NULL,'left','companies',87423,NULL,NULL,0,'/societe/societe.php','','ThirdParty','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87922,'smartphone',1,NULL,'left','companies',87921,NULL,NULL,0,'/societe/soc.php?action=create','','MenuNewThirdParty','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87924,'smartphone',1,NULL,'left','companies',87921,NULL,NULL,5,'/fourn/liste.php?leftmenu=suppliers','','ListSuppliersShort','suppliers',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(87925,'smartphone',1,NULL,'left','companies',87924,NULL,NULL,0,'/societe/soc.php?leftmenu=supplier&action=create&type=f','','NewSupplier','suppliers',2,'','$user->rights->societe->creer','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(87927,'smartphone',1,NULL,'left','companies',87921,NULL,NULL,3,'/comm/prospect/list.php?leftmenu=prospects','','ListProspectsShort','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87928,'smartphone',1,NULL,'left','companies',87927,NULL,NULL,0,'/societe/soc.php?leftmenu=prospects&action=create&type=p','','MenuNewProspect','companies',2,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87930,'smartphone',1,NULL,'left','companies',87921,NULL,NULL,4,'/comm/list.php?leftmenu=customers','','ListCustomersShort','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(87931,'smartphone',1,NULL,'left','companies',87930,NULL,NULL,0,'/societe/soc.php?leftmenu=customers&action=create&type=c','','MenuNewCustomer','companies',2,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88021,'smartphone',1,NULL,'left','companies',87423,NULL,NULL,1,'/contact/list.php?leftmenu=contacts','','ContactsAddresses||Contacts@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88022,'smartphone',1,NULL,'left','companies',88021,NULL,NULL,0,'/contact/card.php?leftmenu=contacts&action=create','','NewContactAddress||NewContact@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88023,'smartphone',1,NULL,'left','companies',88021,NULL,NULL,1,'/contact/list.php?leftmenu=contacts','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88025,'smartphone',1,NULL,'left','companies',88023,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=p','','Prospects','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88026,'smartphone',1,NULL,'left','companies',88023,NULL,NULL,2,'/contact/list.php?leftmenu=contacts&type=c','','Customers','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88027,'smartphone',1,NULL,'left','companies',88023,NULL,NULL,3,'/contact/list.php?leftmenu=contacts&type=f','','Suppliers','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(88028,'smartphone',1,NULL,'left','companies',88023,NULL,NULL,4,'/contact/list.php?leftmenu=contacts&type=o','','Others','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(88071,'smartphone',1,NULL,'left','companies',87423,NULL,NULL,3,'/categories/index.php?leftmenu=cat&type=1','','SuppliersCategoriesShort','categories',0,'','$user->rights->categorie->lire','$conf->societe->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(88072,'smartphone',1,NULL,'left','companies',88071,NULL,NULL,0,'/categories/card.php?action=create&type=1','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->societe->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(88081,'smartphone',1,NULL,'left','companies',87423,NULL,NULL,4,'/categories/index.php?leftmenu=cat&type=2','','CustomersProspectsCategoriesShort','categories',0,'','$user->rights->categorie->lire','$conf->fournisseur->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(88082,'smartphone',1,NULL,'left','companies',88081,NULL,NULL,0,'/categories/card.php?action=create&type=2','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->fournisseur->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(88121,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,1,'/comm/prospect/index.php?leftmenu=prospects','','Prospects','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88122,'smartphone',1,NULL,'left','commercial',88121,NULL,NULL,0,'/societe/soc.php?leftmenu=prospects&action=create&type=p','','MenuNewProspect','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88123,'smartphone',1,NULL,'left','commercial',88121,NULL,NULL,1,'/comm/prospect/list.php?leftmenu=prospects','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88124,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,0,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=-1','','LastProspectDoNotContact','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88125,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,1,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=0','','LastProspectNeverContacted','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88126,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,2,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=1','','LastProspectToContact','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88127,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,3,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=2','','LastProspectContactInProcess','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88128,'smartphone',1,NULL,'left','commercial',88123,NULL,NULL,4,'/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&stcomm=3','','LastProspectContactDone','companies',2,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88129,'smartphone',1,NULL,'left','commercial',88121,NULL,NULL,2,'/contact/list.php?leftmenu=prospects&type=p','','Contacts','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88221,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,2,'/comm/index.php?leftmenu=customers','','Customers','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88222,'smartphone',1,NULL,'left','commercial',88221,NULL,NULL,0,'/societe/soc.php?leftmenu=customers&action=create&type=c','','MenuNewCustomer','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88223,'smartphone',1,NULL,'left','commercial',88221,NULL,NULL,1,'/comm/list.php?leftmenu=customers','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88224,'smartphone',1,NULL,'left','commercial',88221,NULL,NULL,2,'/contact/list.php?leftmenu=customers&type=c','','Contacts','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88321,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,3,'/contact/list.php?leftmenu=contacts','','Contacts','companies',0,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88322,'smartphone',1,NULL,'left','commercial',88321,NULL,NULL,0,'/contact/card.php?leftmenu=contacts&action=create','','NewContactAddress||NewContact@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88323,'smartphone',1,NULL,'left','commercial',88321,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&action=create','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',0,'2013-02-24 18:29:15'),(88331,'smartphone',1,NULL,'left','commercial',88323,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=p','','Prospects','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88332,'smartphone',1,NULL,'left','commercial',88323,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=c','','Customers','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88333,'smartphone',1,NULL,'left','commercial',88323,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=f','','Suppliers','companies',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->societe->enabled && $conf->fournisseur->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88334,'smartphone',1,NULL,'left','commercial',88323,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=o','','Other','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled && $leftmenu==\"prospects\"',0,'2013-02-24 18:29:15'),(88521,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,4,'/comm/propal.php?leftmenu=propals','','Prop','propal',0,'','$user->rights->propale->lire','$conf->propal->enabled',2,'2013-02-24 18:29:15'),(88522,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,0,'/societe/societe.php?leftmenu=propals','','NewPropal','propal',1,'','$user->rights->propale->creer','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88523,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,1,'/comm/propal.php?viewstatut=0','','PropalsDraft','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88524,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,2,'/comm/propal.php?viewstatut=1','','PropalsOpened','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88525,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,3,'/comm/propal.php?viewstatut=2,3,4','','PropalStatusClosedShort','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88526,'smartphone',1,NULL,'left','commercial',88521,NULL,NULL,4,'/comm/propal/stats/index.php?leftmenu=propals','','Statistics','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-02-24 18:29:15'),(88621,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,5,'/commande/index.php?leftmenu=orders','','CustomersOrders','orders',0,'','$user->rights->commande->lire','$conf->commande->enabled',2,'2013-02-24 18:29:15'),(88622,'smartphone',1,NULL,'left','commercial',88621,NULL,NULL,0,'/societe/societe.php?leftmenu=orders','','NewOrder','orders',1,'','$user->rights->commande->creer','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88623,'smartphone',1,NULL,'left','commercial',88621,NULL,NULL,1,'/commande/liste.php?leftmenu=orders','','List','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88624,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,2,'/commande/liste.php?leftmenu=orders&viewstatut=0','','StatusOrderDraftShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88625,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,3,'/commande/liste.php?leftmenu=orders&viewstatut=1','','StatusOrderValidated','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88626,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,4,'/commande/liste.php?leftmenu=orders&viewstatut=2','','StatusOrderOnProcessShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88627,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,5,'/commande/liste.php?leftmenu=orders&viewstatut=3','','StatusOrderToBill','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88628,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,6,'/commande/liste.php?leftmenu=orders&viewstatut=4','','StatusOrderProcessed','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88629,'smartphone',1,NULL,'left','commercial',88623,NULL,NULL,7,'/commande/liste.php?leftmenu=orders&viewstatut=-1','','StatusOrderCanceledShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88630,'smartphone',1,NULL,'left','commercial',88621,NULL,NULL,4,'/commande/stats/index.php?leftmenu=orders','','Statistics','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-02-24 18:29:15'),(88721,'smartphone',1,NULL,'left','commercial',87424,NULL,NULL,6,'/expedition/index.php?leftmenu=sendings','','Shipments','orders',0,'','$user->rights->expedition->lire','$conf->expedition->enabled',2,'2013-02-24 18:29:15'),(88722,'smartphone',1,NULL,'left','commercial',88721,NULL,NULL,0,'/expedition/liste.php?leftmenu=sendings','','List','orders',1,'','$user->rights->expedition->lire','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-02-24 18:29:15'),(88723,'smartphone',1,NULL,'left','commercial',88721,NULL,NULL,1,'/expedition/stats/index.php?leftmenu=sendings','','Statistics','orders',1,'','$user->rights->expedition->lire','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-02-24 18:29:15'),(88821,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,7,'/contrat/index.php?leftmenu=contracts','','Contracts','contracts',0,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-02-24 18:29:15'),(88822,'smartphone',1,NULL,'left','commercial',88821,NULL,NULL,0,'/societe/societe.php?leftmenu=contracts','','NewContract','contracts',1,'','$user->rights->contrat->creer','$conf->contrat->enabled',2,'2013-02-24 18:29:15'),(88823,'smartphone',1,NULL,'left','commercial',88821,NULL,NULL,1,'/contrat/liste.php?leftmenu=contracts','','List','contracts',1,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-02-24 18:29:15'),(88824,'smartphone',1,NULL,'left','commercial',88821,NULL,NULL,2,'/contrat/services.php?leftmenu=contracts','','MenuServices','contracts',1,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-02-24 18:29:15'),(88825,'smartphone',1,NULL,'left','commercial',88824,NULL,NULL,0,'/contrat/services.php?leftmenu=contracts&mode=0','','MenuInactiveServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-02-24 18:29:15'),(88826,'smartphone',1,NULL,'left','commercial',88824,NULL,NULL,1,'/contrat/services.php?leftmenu=contracts&mode=4','','MenuRunningServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-02-24 18:29:15'),(88827,'smartphone',1,NULL,'left','commercial',88824,NULL,NULL,2,'/contrat/services.php?leftmenu=contracts&mode=4&filter=expired','','MenuExpiredServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-02-24 18:29:15'),(88828,'smartphone',1,NULL,'left','commercial',88824,NULL,NULL,3,'/contrat/services.php?leftmenu=contracts&mode=5','','MenuClosedServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-02-24 18:29:15'),(88921,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,8,'/fichinter/list.php?leftmenu=ficheinter','','Interventions','interventions',0,'','$user->rights->ficheinter->lire','$conf->ficheinter->enabled',2,'2013-02-24 18:29:15'),(88922,'smartphone',1,NULL,'left','commercial',88921,NULL,NULL,0,'/fichinter/card.php?action=create&leftmenu=ficheinter','','NewIntervention','interventions',1,'','$user->rights->ficheinter->creer','$conf->ficheinter->enabled && $leftmenu==\"ficheinter\"',2,'2013-02-24 18:29:15'),(88923,'smartphone',1,NULL,'left','commercial',88921,NULL,NULL,1,'/fichinter/list.php?leftmenu=ficheinter','','List','interventions',1,'','$user->rights->ficheinter->lire','$conf->ficheinter->enabled && $leftmenu==\"ficheinter\"',2,'2013-02-24 18:29:15'),(89021,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,3,'/fourn/facture/index.php?leftmenu=suppliers_bills','','BillsSuppliers','bills',0,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(89022,'smartphone',1,NULL,'left','accountancy',89021,NULL,NULL,0,'/fourn/facture/card.php?action=create&leftmenu=suppliers_bills','','NewBill','bills',1,'','$user->rights->fournisseur->facture->creer','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(89023,'smartphone',1,NULL,'left','accountancy',89021,NULL,NULL,1,'/fourn/facture/impayees.php?leftmenu=suppliers_bills','','Unpaid','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(89024,'smartphone',1,NULL,'left','accountancy',89021,NULL,NULL,2,'/fourn/facture/paiement.php?leftmenu=suppliers_bills','','Payments','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(89121,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,3,'/compta/facture/list.php?leftmenu=customers_bills','','BillsCustomers','bills',0,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89122,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,3,'/compta/clients.php?action=facturer&leftmenu=customers_bills','','NewBill','bills',1,'','$user->rights->facture->creer','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89123,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,4,'/compta/facture/fiche-rec.php?leftmenu=customers_bills','','Repeatable','bills',1,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89124,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,5,'/compta/facture/impayees.php?action=facturer&leftmenu=customers_bills','','Unpaid','bills',1,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89125,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,6,'/compta/paiement/liste.php?leftmenu=customers_bills','','Payments','bills',1,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89131,'smartphone',1,NULL,'left','accountancy',89125,NULL,NULL,1,'/compta/paiement/rapport.php?leftmenu=customers_bills','','Reportings','bills',2,'','$user->rights->facture->lire','$conf->societe->enabled',2,'2013-02-24 18:29:15'),(89132,'smartphone',1,NULL,'left','accountancy',87435,NULL,NULL,9,'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank','','MenuChequeDeposits','bills',0,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-02-24 18:29:15'),(89133,'smartphone',1,NULL,'left','accountancy',89132,NULL,NULL,0,'/compta/paiement/cheque/card.php?leftmenu=checks&action=new','','NewCheckDeposit','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-02-24 18:29:15'),(89134,'smartphone',1,NULL,'left','accountancy',89132,NULL,NULL,1,'/compta/paiement/cheque/liste.php?leftmenu=checks','','List','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-02-24 18:29:15'),(89135,'smartphone',1,NULL,'left','accountancy',89121,NULL,NULL,8,'/compta/facture/stats/index.php?leftmenu=customers_bills','','Statistics','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-02-24 18:29:15'),(89321,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,3,'/commande/liste.php?leftmenu=orders&viewstatut=3','','MenuOrdersToBill','orders',0,'','$user->rights->commande->lire','$conf->commande->enabled',0,'2013-02-24 18:29:15'),(89421,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,4,'/compta/dons/index.php?leftmenu=donations&mainmenu=accountancy','','Donations','donations',0,'','$user->rights->don->lire','$conf->don->enabled',2,'2013-02-24 18:29:15'),(89422,'smartphone',1,NULL,'left','accountancy',89421,NULL,NULL,0,'/compta/dons/card.php?leftmenu=donations&mainmenu=accountancy&action=create','','NewDonation','donations',1,'','$user->rights->don->creer','$conf->don->enabled && $leftmenu==\"donations\"',2,'2013-02-24 18:29:15'),(89423,'smartphone',1,NULL,'left','accountancy',89421,NULL,NULL,1,'/compta/dons/liste.php?leftmenu=donations&mainmenu=accountancy','','List','donations',1,'','$user->rights->don->lire','$conf->don->enabled && $leftmenu==\"donations\"',2,'2013-02-24 18:29:15'),(89521,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,5,'/compta/deplacement/index.php?leftmenu=tripsandexpenses','','TripsAndExpenses','trips',0,'','$user->rights->deplacement->lire','$conf->deplacement->enabled',0,'2013-02-24 18:29:15'),(89522,'smartphone',1,NULL,'left','accountancy',89521,NULL,NULL,1,'/compta/deplacement/card.php?action=create&leftmenu=tripsandexpenses','','New','trips',1,'','$user->rights->deplacement->creer','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-02-24 18:29:15'),(89523,'smartphone',1,NULL,'left','accountancy',89521,NULL,NULL,2,'/compta/deplacement/index.php?leftmenu=tripsandexpenses','','List','trips',1,'','$user->rights->deplacement->lire','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-02-24 18:29:15'),(89524,'smartphone',1,NULL,'left','accountancy',89521,NULL,NULL,2,'/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses','','Statistics','trips',1,'','$user->rights->deplacement->lire','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-02-24 18:29:15'),(89621,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,6,'/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy','','MenuTaxAndDividends','compta',0,'','$user->rights->tax->charges->lire','$conf->tax->enabled',0,'2013-02-24 18:29:15'),(89622,'smartphone',1,NULL,'left','accountancy',89621,NULL,NULL,1,'/compta/sociales/index.php?leftmenu=tax_social','','SocialContributions','',1,'','$user->rights->tax->charges->lire','$conf->tax->enabled',0,'2013-02-24 18:29:15'),(89623,'smartphone',1,NULL,'left','accountancy',89622,NULL,NULL,2,'/compta/sociales/charges.php?leftmenu=tax_social&action=create','','MenuNewSocialContribution','',2,'','$user->rights->tax->charges->creer','$conf->tax->enabled && $leftmenu==\"tax_social\"',0,'2013-02-24 18:29:15'),(89624,'smartphone',1,NULL,'left','accountancy',89622,NULL,NULL,3,'/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly','','Payments','',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && $leftmenu==\"tax_social\"',0,'2013-02-24 18:29:15'),(89721,'smartphone',1,NULL,'left','accountancy',89621,NULL,NULL,7,'/compta/tva/index.php?leftmenu=tax_vat&mainmenu=accountancy','','VAT','companies',1,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS)',0,'2013-02-24 18:29:15'),(89722,'smartphone',1,NULL,'left','accountancy',89721,NULL,NULL,0,'/compta/tva/card.php?leftmenu=tax_vat&action=create','','NewPayment','companies',2,'','$user->rights->tax->charges->creer','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-02-24 18:29:15'),(89723,'smartphone',1,NULL,'left','accountancy',89721,NULL,NULL,1,'/compta/tva/reglement.php?leftmenu=tax_vat','','Payments','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-02-24 18:29:15'),(89724,'smartphone',1,NULL,'left','accountancy',89721,NULL,NULL,2,'/compta/tva/clients.php?leftmenu=tax_vat','','ReportByCustomers','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-02-24 18:29:15'),(89725,'smartphone',1,NULL,'left','accountancy',89721,NULL,NULL,3,'/compta/tva/quadri_detail.php?leftmenu=tax_vat','','ReportByQuarter','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-02-24 18:29:15'),(89821,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,8,'/compta/ventilation/index.php?leftmenu=ventil','','Ventilation','companies',0,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89822,'smartphone',1,NULL,'left','accountancy',89821,NULL,NULL,0,'/compta/ventilation/liste.php','','ToDispatch','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89823,'smartphone',1,NULL,'left','accountancy',89821,NULL,NULL,1,'/compta/ventilation/lignes.php','','Dispatched','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89824,'smartphone',1,NULL,'left','accountancy',89821,NULL,NULL,2,'/compta/param/','','Setup','companies',1,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89825,'smartphone',1,NULL,'left','accountancy',89824,NULL,NULL,0,'/compta/param/comptes/liste.php','','List','companies',2,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89826,'smartphone',1,NULL,'left','accountancy',89824,NULL,NULL,1,'/compta/param/comptes/card.php?action=create','','New','companies',2,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89827,'smartphone',1,NULL,'left','accountancy',89821,NULL,NULL,3,'/compta/export/','','Export','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89828,'smartphone',1,NULL,'left','accountancy',89827,NULL,NULL,0,'/compta/export/index.php','','New','companies',2,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89829,'smartphone',1,NULL,'left','accountancy',89827,NULL,NULL,1,'/compta/export/liste.php','','List','companies',2,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-02-24 18:29:15'),(89921,'smartphone',1,NULL,'left','accountancy',87435,NULL,NULL,9,'/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank','','StandingOrders','withdrawals',0,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled',2,'2013-02-24 18:29:15'),(89922,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,1,'/compta/prelevement/demandes.php?status=0&leftmenu=withdraw','','StandingOrderToProcess','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89923,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,0,'/compta/prelevement/create.php?leftmenu=withdraw','','NewStandingOrder','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89924,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,2,'/compta/prelevement/bons.php?leftmenu=withdraw','','WithdrawalsReceipts','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89925,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,3,'/compta/prelevement/liste.php?leftmenu=withdraw','','WithdrawalsLines','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89927,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,5,'/compta/prelevement/rejets.php?leftmenu=withdraw','','Rejects','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(89928,'smartphone',1,NULL,'left','accountancy',89921,NULL,NULL,6,'/compta/prelevement/stats.php?leftmenu=withdraw','','Statistics','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-02-24 18:29:15'),(90021,'smartphone',1,NULL,'left','accountancy',87435,NULL,NULL,1,'/compta/bank/index.php?leftmenu=bank&mainmenu=bank','','MenuBankCash','banks',0,'','$user->rights->banque->lire','$conf->banque->enabled',0,'2013-02-24 18:29:15'),(90022,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,0,'/compta/bank/card.php?action=create&leftmenu=bank','','MenuNewFinancialAccount','banks',1,'','$user->rights->banque->configurer','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90023,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,1,'/compta/bank/categ.php?leftmenu=bank','','Rubriques','categories',1,'','$user->rights->banque->configurer','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90024,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,2,'/compta/bank/search.php?leftmenu=bank','','ListTransactions','banks',1,'','$user->rights->banque->lire','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90025,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,3,'/compta/bank/budget.php?leftmenu=bank','','ListTransactionsByCategory','banks',1,'','$user->rights->banque->lire','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90027,'smartphone',1,NULL,'left','accountancy',90021,NULL,NULL,5,'/compta/bank/virement.php?leftmenu=bank','','BankTransfers','banks',1,'','$user->rights->banque->transfer','$conf->banque->enabled && $leftmenu==bank',0,'2013-02-24 18:29:15'),(90121,'smartphone',1,NULL,'left','accountancy',87427,NULL,NULL,11,'/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy','','Reportings','main',0,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90122,'smartphone',1,NULL,'left','accountancy',90121,NULL,NULL,0,'/compta/resultat/index.php?leftmenu=ca','','ReportInOut','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90123,'smartphone',1,NULL,'left','accountancy',90122,NULL,NULL,0,'/compta/resultat/clientfourn.php?leftmenu=ca','','ByCompanies','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90124,'smartphone',1,NULL,'left','accountancy',90121,NULL,NULL,1,'/compta/stats/index.php?leftmenu=ca','','ReportTurnover','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90125,'smartphone',1,NULL,'left','accountancy',90124,NULL,NULL,0,'/compta/stats/casoc.php?leftmenu=ca','','ByCompanies','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90126,'smartphone',1,NULL,'left','accountancy',90124,NULL,NULL,1,'/compta/stats/cabyuser.php?leftmenu=ca','','ByUsers','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-02-24 18:29:15'),(90221,'smartphone',1,NULL,'left','products',87424,NULL,NULL,0,'/product/index.php?leftmenu=product&type=0','','Products','products',0,'','$user->rights->produit->lire','$conf->product->enabled',2,'2013-02-24 18:29:15'),(90222,'smartphone',1,NULL,'left','products',90221,NULL,NULL,0,'/product/card.php?leftmenu=product&action=create&type=0','','NewProduct','products',1,'','$user->rights->produit->creer','$conf->product->enabled',2,'2013-02-24 18:29:15'),(90223,'smartphone',1,NULL,'left','products',90221,NULL,NULL,1,'/product/liste.php?leftmenu=product&type=0','','List','products',1,'','$user->rights->produit->lire','$conf->product->enabled',2,'2013-02-24 18:29:15'),(90224,'smartphone',1,NULL,'left','products',90221,NULL,NULL,4,'/product/reassort.php?type=0','','Stocks','products',1,'','$user->rights->produit->lire && $user->rights->stock->lire','$conf->product->enabled',2,'2013-02-24 18:29:15'),(90321,'smartphone',1,NULL,'left','products',87424,NULL,NULL,1,'/product/index.php?leftmenu=service&type=1','','Services','products',0,'','$user->rights->service->lire','$conf->service->enabled',2,'2013-02-24 18:29:15'),(90322,'smartphone',1,NULL,'left','products',90321,NULL,NULL,0,'/product/card.php?leftmenu=service&action=create&type=1','','NewService','products',1,'','$user->rights->service->creer','$conf->service->enabled',2,'2013-02-24 18:29:15'),(90323,'smartphone',1,NULL,'left','products',90321,NULL,NULL,1,'/product/liste.php?leftmenu=service&type=1','','List','products',1,'','$user->rights->service->lire','$conf->service->enabled',2,'2013-02-24 18:29:15'),(90421,'smartphone',1,NULL,'left','products',87424,NULL,NULL,2,'/product/stats/index.php?leftmenu=stats','','Statistics','main',0,'','$user->rights->service->lire','$conf->product->enabled || $conf->service->enabled',2,'2013-02-24 18:29:15'),(90422,'smartphone',1,NULL,'left','products',90421,NULL,NULL,0,'/product/popuprop.php?leftmenu=stats','','Popularity','main',1,'','$user->rights->produit->lire && $user->rights->produit>lire','$conf->propal->enabled',2,'2013-02-24 18:29:15'),(90521,'smartphone',1,NULL,'left','products',87424,NULL,NULL,3,'/product/stock/index.php?leftmenu=stock','','Stock','stocks',0,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90522,'smartphone',1,NULL,'left','products',90521,NULL,NULL,0,'/product/stock/card.php?action=create','','MenuNewWarehouse','stocks',1,'','$user->rights->stock->creer','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90523,'smartphone',1,NULL,'left','products',90521,NULL,NULL,1,'/product/stock/liste.php','','List','stocks',1,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90524,'smartphone',1,NULL,'left','products',90521,NULL,NULL,2,'/product/stock/valo.php','','EnhancedValue','stocks',1,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90525,'smartphone',1,NULL,'left','products',90521,NULL,NULL,3,'/product/stock/mouvement.php','','Movements','stocks',1,'','$user->rights->stock->mouvement->lire','$conf->stock->enabled',2,'2013-02-24 18:29:15'),(90621,'smartphone',1,NULL,'left','products',87424,NULL,NULL,4,'/categories/index.php?leftmenu=cat&type=0','','Categories','categories',0,'','$user->rights->categorie->lire','$conf->categorie->enabled',2,'2013-02-24 18:29:15'),(90622,'smartphone',1,NULL,'left','products',90621,NULL,NULL,0,'/categories/card.php?action=create&type=0','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->categorie->enabled',2,'2013-02-24 18:29:15'),(91021,'smartphone',1,NULL,'left','project',87428,NULL,NULL,0,'/projet/index.php?leftmenu=projects','','Projects','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91022,'smartphone',1,NULL,'left','project',91021,NULL,NULL,1,'/projet/card.php?leftmenu=projects&action=create','','NewProject','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91023,'smartphone',1,NULL,'left','project',91021,NULL,NULL,2,'/projet/liste.php?leftmenu=projects','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91031,'smartphone',1,NULL,'left','project',87428,NULL,NULL,0,'/projet/index.php?leftmenu=projects&mode=mine','','MyProjects','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91032,'smartphone',1,NULL,'left','project',91031,NULL,NULL,1,'/projet/card.php?leftmenu=projects&action=create&mode=mine','','NewProject','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91033,'smartphone',1,NULL,'left','project',91031,NULL,NULL,2,'/projet/liste.php?leftmenu=projects&mode=mine','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91121,'smartphone',1,NULL,'left','project',87428,NULL,NULL,0,'/projet/activity/index.php?leftmenu=projects','','Activities','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91122,'smartphone',1,NULL,'left','project',91121,NULL,NULL,1,'/projet/tasks.php?leftmenu=projects&action=create','','NewTask','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91123,'smartphone',1,NULL,'left','project',91121,NULL,NULL,2,'/projet/tasks/index.php?leftmenu=projects','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91124,'smartphone',1,NULL,'left','project',91121,NULL,NULL,3,'/projet/activity/list.php?leftmenu=projects','','NewTimeSpent','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91221,'smartphone',1,NULL,'left','project',87428,NULL,NULL,0,'/projet/activity/index.php?leftmenu=projects&mode=mine','','MyActivities','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91222,'smartphone',1,NULL,'left','project',91221,NULL,NULL,1,'/projet/tasks.php?leftmenu=projects&action=create&mode=mine','','NewTask','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91223,'smartphone',1,NULL,'left','project',91221,NULL,NULL,2,'/projet/tasks/index.php?leftmenu=projects&mode=mine','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91224,'smartphone',1,NULL,'left','project',91221,NULL,NULL,3,'/projet/activity/list.php?leftmenu=projects&mode=mine','','NewTimeSpent','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-02-24 18:29:15'),(91321,'smartphone',1,NULL,'left','tools',87429,NULL,NULL,0,'/comm/mailing/index.php?leftmenu=mailing','','EMailings','mails',0,'','$user->rights->mailing->lire','$conf->mailing->enabled',0,'2013-02-24 18:29:15'),(91322,'smartphone',1,NULL,'left','tools',91321,NULL,NULL,0,'/comm/mailing/card.php?leftmenu=mailing&action=create','','NewMailing','mails',1,'','$user->rights->mailing->creer','$conf->mailing->enabled',0,'2013-02-24 18:29:15'),(91323,'smartphone',1,NULL,'left','tools',91321,NULL,NULL,1,'/comm/mailing/liste.php?leftmenu=mailing','','List','mails',1,'','$user->rights->mailing->lire','$conf->mailing->enabled',0,'2013-02-24 18:29:15'),(91521,'smartphone',1,NULL,'left','tools',87429,NULL,NULL,2,'/exports/index.php?leftmenu=export','','FormatedExport','exports',0,'','$user->rights->export->lire','$conf->export->enabled',2,'2013-02-24 18:29:15'),(91522,'smartphone',1,NULL,'left','tools',91521,NULL,NULL,0,'/exports/export.php?leftmenu=export','','NewExport','exports',1,'','$user->rights->export->creer','$conf->export->enabled',2,'2013-02-24 18:29:15'),(91551,'smartphone',1,NULL,'left','tools',87429,NULL,NULL,2,'/imports/index.php?leftmenu=import','','FormatedImport','exports',0,'','$user->rights->import->run','$conf->import->enabled',2,'2013-02-24 18:29:15'),(91552,'smartphone',1,NULL,'left','tools',91551,NULL,NULL,0,'/imports/import.php?leftmenu=import','','NewImport','exports',1,'','$user->rights->import->run','$conf->import->enabled',2,'2013-02-24 18:29:15'),(91621,'smartphone',1,NULL,'left','members',87434,NULL,NULL,0,'/adherents/index.php?leftmenu=members&mainmenu=members','','Members','members',0,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91622,'smartphone',1,NULL,'left','members',91621,NULL,NULL,0,'/adherents/card.php?action=create','','NewMember','members',1,'','$user->rights->adherent->creer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91623,'smartphone',1,NULL,'left','members',91621,NULL,NULL,1,'/adherents/liste.php','','List','members',1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91624,'smartphone',1,NULL,'left','members',91623,NULL,NULL,2,'/adherents/liste.php?statut=-1','','MenuMembersToValidate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91625,'smartphone',1,NULL,'left','members',91623,NULL,NULL,3,'/adherents/liste.php?statut=1','','MenuMembersValidated','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91626,'smartphone',1,NULL,'left','members',91623,NULL,NULL,4,'/adherents/liste.php?statut=1&filter=outofdate','','MenuMembersNotUpToDate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91627,'smartphone',1,NULL,'left','members',91623,NULL,NULL,5,'/adherents/liste.php?statut=1&filter=uptodate','','MenuMembersUpToDate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91628,'smartphone',1,NULL,'left','members',91623,NULL,NULL,6,'/adherents/liste.php?statut=0','','MenuMembersResiliated','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91721,'smartphone',1,NULL,'left','members',87434,NULL,NULL,1,'/adherents/index.php?leftmenu=accountancy&mainmenu=members','','Subscriptions','compta',0,'','$user->rights->adherent->cotisation->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91722,'smartphone',1,NULL,'left','members',91721,NULL,NULL,0,'/adherents/liste.php?statut=-1&leftmenu=accountancy&mainmenu=members','','NewSubscription','compta',1,'','$user->rights->adherent->cotisation->creer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91723,'smartphone',1,NULL,'left','members',91721,NULL,NULL,1,'/adherents/cotisations.php?leftmenu=accountancy','','List','compta',1,'','$user->rights->adherent->cotisation->lire','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91921,'smartphone',1,NULL,'left','members',87434,NULL,NULL,3,'/adherents/index.php?leftmenu=export&mainmenu=members','','Exports','members',0,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91922,'smartphone',1,NULL,'left','members',91921,NULL,NULL,0,'/exports/index.php?leftmenu=export','','Datas','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled && $conf->export->enabled',2,'2013-02-24 18:29:15'),(91923,'smartphone',1,NULL,'left','members',91921,NULL,NULL,1,'/adherents/htpasswd.php?leftmenu=export','','Filehtpasswd','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(91924,'smartphone',1,NULL,'left','members',91921,NULL,NULL,2,'/adherents/cartes/carte.php?leftmenu=export','','MembersCards','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(92121,'smartphone',1,NULL,'left','members',87434,NULL,NULL,5,'/adherents/index.php?leftmenu=setup&mainmenu=members','','Setup','members',0,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(92122,'smartphone',1,NULL,'left','members',92121,NULL,NULL,0,'/adherents/type.php?leftmenu=setup','','MembersTypes','members',1,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(92123,'smartphone',1,NULL,'left','members',92121,NULL,NULL,1,'/adherents/options.php?leftmenu=setup','','MembersAttributes','members',1,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-02-24 18:29:15'),(92421,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,0,'/compta/index.php?leftmenu=suppliers','','Suppliers','companies',0,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(92422,'smartphone',1,NULL,'left','commercial',92421,NULL,NULL,0,'/societe/soc.php?leftmenu=suppliers&action=create&type=f','','NewSupplier','companies',1,'','$user->rights->societe->creer && $user->rights->fournisseur->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(92423,'smartphone',1,NULL,'left','commercial',92421,NULL,NULL,1,'/fourn/liste.php?leftmenu=suppliers','','List','companies',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(92424,'smartphone',1,NULL,'left','commercial',92421,NULL,NULL,2,'/contact/list.php?leftmenu=suppliers&type=f','','Contacts','companies',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->fournisseur->enabled',2,'2013-02-24 18:29:15'),(92521,'smartphone',1,NULL,'left','commercial',87426,NULL,NULL,6,'/fourn/commande/index.php?leftmenu=orders_suppliers','','SuppliersOrders','orders',0,'','$user->rights->fournisseur->commande->lire','$conf->commande->enabled',2,'2013-02-24 18:29:15'),(92522,'smartphone',1,NULL,'left','commercial',92521,NULL,NULL,0,'/societe/societe.php?leftmenu=orders_suppliers','','NewOrder','orders',1,'','$user->rights->fournisseur->commande->creer','$conf->commande->enabled && $leftmenu==\"orders_suppliers\"',2,'2013-02-24 18:29:15'),(92523,'smartphone',1,NULL,'left','commercial',92521,NULL,NULL,1,'/fourn/commande/liste.php?leftmenu=orders_suppliers&viewstatut=0','','List','orders',1,'','$user->rights->fournisseur->commande->lire','$conf->commande->enabled && $leftmenu==\"orders_suppliers\"',2,'2013-02-24 18:29:15'),(92529,'smartphone',1,NULL,'left','commercial',92521,NULL,NULL,7,'/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier','','Statistics','orders',1,'','$user->rights->fournisseur->commande->lire','$conf->commande->enabled && $leftmenu==\"orders_suppliers\"',2,'2013-02-24 18:29:15'),(92621,'smartphone',1,NULL,'left','members',87434,NULL,NULL,3,'/categories/index.php?leftmenu=cat&type=3','','MembersCategoriesShort','categories',0,'','$user->rights->categorie->lire','$conf->adherent->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(92622,'smartphone',1,NULL,'left','members',92621,NULL,NULL,0,'/categories/card.php?action=create&type=3','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->adherent->enabled && $conf->categorie->enabled',2,'2013-02-24 18:29:15'),(103094,'all',2,'agenda','top','agenda',0,NULL,NULL,100,'/comm/action/index.php','','Agenda','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103095,'all',2,'agenda','left','agenda',103094,NULL,NULL,100,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda','','Actions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103096,'all',2,'agenda','left','agenda',103095,NULL,NULL,101,'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create','','NewAction','commercial',NULL,NULL,'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103097,'all',2,'agenda','left','agenda',103095,NULL,NULL,102,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda','','Calendar','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103098,'all',2,'agenda','left','agenda',103097,NULL,NULL,103,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine','','MenuToDoMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103099,'all',2,'agenda','left','agenda',103097,NULL,NULL,104,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine','','MenuDoneMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103100,'all',2,'agenda','left','agenda',103097,NULL,NULL,105,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo','','MenuToDoActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2013-03-13 15:29:19'),(103101,'all',2,'agenda','left','agenda',103097,NULL,NULL,106,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done','','MenuDoneActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2013-03-13 15:29:19'),(103102,'all',2,'agenda','left','agenda',103095,NULL,NULL,112,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda','','List','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103103,'all',2,'agenda','left','agenda',103102,NULL,NULL,113,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine','','MenuToDoMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103104,'all',2,'agenda','left','agenda',103102,NULL,NULL,114,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine','','MenuDoneMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103105,'all',2,'agenda','left','agenda',103102,NULL,NULL,115,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=todo','','MenuToDoActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2013-03-13 15:29:19'),(103106,'all',2,'agenda','left','agenda',103102,NULL,NULL,116,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=done','','MenuDoneActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2013-03-13 15:29:19'),(103107,'all',2,'agenda','left','agenda',103095,NULL,NULL,120,'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda','','Reportings','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$conf->agenda->enabled',2,'2013-03-13 15:29:19'),(103108,'all',2,'pos','top','pos',0,NULL,NULL,100,'/pos/backend/listefac.php','','POS','pos@pos',NULL,'1','1','1',2,'2013-03-13 20:33:09'),(103109,'all',2,'pos','left','pos',103108,NULL,NULL,100,'/pos/backend/liste.php','','Tickets','pos@pos',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103110,'all',2,'pos','left','pos',103109,NULL,NULL,100,'/pos/backend/liste.php','','List','main',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103111,'all',2,'pos','left','pos',103110,NULL,NULL,100,'/pos/backend/liste.php?viewstatut=0','','StatusTicketDraft','pos@pos',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103112,'all',2,'pos','left','@pos',103110,NULL,NULL,100,'/pos/backend/liste.php?viewstatut=1','','StatusTicketClosed','main',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103113,'all',2,'pos','left','@pos',103110,NULL,NULL,100,'/pos/backend/liste.php?viewstatut=2','','StatusTicketProcessed','main',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103114,'all',2,'pos','left','@pos',103110,NULL,NULL,100,'/pos/backend/liste.php?viewtype=1','','StatusTicketReturned','main',NULL,NULL,'$user->rights->pos->backend','$conf->global->POS_USE_TICKETS',0,'2013-03-13 20:33:09'),(103115,'all',2,'pos','left','pos',103108,NULL,NULL,100,'/pos/backend/listefac.php','','Factures','pos@pos',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103116,'all',2,'pos','left','pos',103115,NULL,NULL,100,'/pos/backend/listefac.php','','List','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103117,'all',2,'pos','left','pos',103116,NULL,NULL,100,'/pos/backend/listefac.php?viewstatut=0','','BillStatusDraft','bills',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103118,'all',2,'pos','left','@pos',103116,NULL,NULL,100,'/pos/backend/listefac.php?viewstatut=1','','BillStatusValidated','bills',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103119,'all',2,'pos','left','@pos',103116,NULL,NULL,100,'/pos/backend/listefac.php?viewstatut=2&viewtype=0','','BillStatusPaid','bills',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103120,'all',2,'pos','left','@pos',103116,NULL,NULL,100,'/pos/backend/listefac.php?viewtype=2','','BillStatusReturned','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103121,'all',2,'pos','left','@pos',103108,NULL,NULL,100,'/pos/frontend/index.php','','POS','main',NULL,NULL,'$user->rights->pos->frontend','1',0,'2013-03-13 20:33:09'),(103122,'all',2,'pos','left','@pos',103121,NULL,NULL,100,'/pos/frontend/index.php','','NewTicket','main',NULL,NULL,'$user->rights->pos->frontend','1',0,'2013-03-13 20:33:09'),(103123,'all',2,'pos','left','@pos',103121,NULL,NULL,101,'/pos/backend/closes.php','','CloseandArching','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103124,'all',2,'pos','left','@pos',103108,NULL,NULL,100,'/pos/backend/terminal/cash.php','','Terminal','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103125,'all',2,'pos','left','@pos',103124,NULL,NULL,100,'/pos/backend/terminal/card.php?action=create','','NewCash','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103126,'all',2,'pos','left','@pos',103124,NULL,NULL,101,'/pos/backend/terminal/cash.php','','List','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103127,'all',2,'pos','left','@pos',103123,NULL,NULL,101,'/pos/backend/closes.php?viewstatut=0','','Arqueo','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103128,'all',2,'pos','left','@pos',103123,NULL,NULL,102,'/pos/backend/closes.php?viewstatut=1','','Closes','main',NULL,NULL,'$user->rights->pos->backend','1',0,'2013-03-13 20:33:09'),(103129,'all',2,'pos','left','@pos',103108,NULL,NULL,102,'/pos/backend/transfers.php','','Transfer','main',NULL,NULL,'$user->rights->pos->transfer','1',0,'2013-03-13 20:33:09'),(103130,'all',2,'pos','left','@pos',103108,NULL,NULL,102,'/pos/backend/resultat/index.php','','Rapport','main',NULL,NULL,'$user->rights->pos->stats','1',0,'2013-03-13 20:33:09'),(103131,'all',2,'pos','left','@pos',103130,NULL,NULL,102,'/pos/backend/resultat/casoc.php','','ReportsCustomer','main',NULL,NULL,'$user->rights->pos->stats','1',0,'2013-03-13 20:33:09'),(103132,'all',2,'pos','left','@pos',103130,NULL,NULL,102,'/pos/backend/resultat/causer.php','','ReportsUser','main',NULL,NULL,'$user->rights->pos->stats','1',0,'2013-03-13 20:33:09'),(103133,'all',2,'pos','left','@pos',103130,NULL,NULL,102,'/pos/backend/resultat/sellsjournal.php','','ReportsSells','main',NULL,NULL,'$user->rights->pos->stats','1',0,'2013-03-13 20:33:09'),(103134,'all',2,'opensurvey','top','opensurvey',0,NULL,NULL,200,'/opensurvey/index.php','','Surveys','opensurvey',NULL,NULL,'$user->rights->opensurvey->survey->read','$conf->opensurvey->enabled',0,'2013-03-13 20:33:42'),(103135,'all',2,'opensurvey','left','opensurvey',-1,NULL,'opensurvey',200,'/opensurvey/index.php?mainmenu=opensurvey&leftmenu=opensurvey','','Survey','opensurvey@opensurvey',NULL,'opensurvey','','$conf->opensurvey->enabled',0,'2013-03-13 20:33:42'),(103136,'all',2,'opensurvey','left','opensurvey',-1,'opensurvey','opensurvey',210,'/opensurvey/public/index.php','_blank','NewSurvey','opensurvey@opensurvey',NULL,'opensurvey_new','','$conf->opensurvey->enabled',0,'2013-03-13 20:33:42'),(103137,'all',2,'opensurvey','left','opensurvey',-1,'opensurvey','opensurvey',220,'/opensurvey/list.php','','List','opensurvey@opensurvey',NULL,'opensurvey_list','','$conf->opensurvey->enabled',0,'2013-03-13 20:33:42'),(103160,'all',1,'cron','left','home',-1,'modulesadmintools','home',200,'/cron/list.php?status=1','','CronListActive','cron',NULL,NULL,'$user->rights->cron->read','$leftmenu==\'modulesadmintools\'',2,'2013-03-23 17:24:25'),(103161,'all',1,'cron','left','home',-1,'modulesadmintools','home',201,'/cron/list.php?status=0','','CronListInactive','cron',NULL,NULL,'$user->rights->cron->read','$leftmenu==\'modulesadmintools\'',2,'2013-03-23 17:24:25'),(103162,'auguria',1,'','top','home',0,NULL,NULL,1,'/index.php?mainmenu=home&leftmenu=','','Home','',-1,'','','1',2,'2013-03-24 02:31:47'),(103163,'auguria',1,'societe|fournisseur','top','companies',0,NULL,NULL,2,'/societe/index.php?mainmenu=companies&leftmenu=','','ThirdParties','companies',-1,'','$user->rights->societe->lire || $user->rights->societe->contact->lire','$conf->societe->enabled || $conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(103164,'auguria',1,'product|service','top','products',0,NULL,NULL,3,'/product/index.php?mainmenu=products&leftmenu=','','Products/Services','products',-1,'','$user->rights->produit->lire||$user->rights->service->lire','$conf->product->enabled || $conf->service->enabled',0,'2013-03-24 02:31:47'),(103166,'auguria',1,'propal|commande|fournisseur|contrat|ficheinter','top','commercial',0,NULL,NULL,5,'/comm/index.php?mainmenu=commercial&leftmenu=','','Commercial','commercial',-1,'','$user->rights->societe->lire || $user->rights->societe->contact->lire','$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled || $conf->tax->enabled',2,'2013-03-24 02:31:47'),(103167,'auguria',1,'comptabilite|accounting|facture|deplacement|don|tax','top','accountancy',0,NULL,NULL,6,'/compta/index.php?mainmenu=accountancy&leftmenu=','','MenuFinancial','compta',-1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->facture->lire|| $user->rights->deplacement->lire || $user->rights->don->lire || $user->rights->tax->charges->lire','$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled || $conf->tax->enabled',2,'2013-03-24 02:31:47'),(103168,'auguria',1,'projet','top','project',0,NULL,NULL,7,'/projet/index.php?mainmenu=project&leftmenu=','','Projects','projects',-1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(103169,'auguria',1,'mailing|export|import','top','tools',0,NULL,NULL,8,'/core/tools.php?mainmenu=tools&leftmenu=','','Tools','other',-1,'','$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run','$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled',2,'2013-03-24 02:31:47'),(103174,'auguria',1,'adherent','top','members',0,NULL,NULL,15,'/adherents/index.php?mainmenu=members&leftmenu=','','Members','members',-1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:47'),(103175,'auguria',1,'banque|prelevement','top','bank',0,NULL,NULL,6,'/compta/bank/index.php?mainmenu=bank&leftmenu=bank','','MenuBankCash','banks',-1,'','$user->rights->banque->lire || $user->rights->prelevement->bons->lire','$conf->banque->enabled || $conf->prelevement->enabled',0,'2013-03-24 02:31:47'),(103261,'auguria',1,'','left','home',103162,NULL,NULL,0,'/admin/index.php?leftmenu=setup','','Setup','admin',0,'setup','','$user->admin',2,'2013-03-24 02:31:47'),(103262,'auguria',1,'','left','home',103261,NULL,NULL,1,'/admin/company.php?leftmenu=setup','','MenuCompanySetup','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103263,'auguria',1,'','left','home',103261,NULL,NULL,4,'/admin/ihm.php?leftmenu=setup','','GUISetup','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103264,'auguria',1,'','left','home',103261,NULL,NULL,2,'/admin/modules.php?leftmenu=setup','','Modules','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103265,'auguria',1,'','left','home',103261,NULL,NULL,5,'/admin/boxes.php?leftmenu=setup','','Boxes','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103266,'auguria',1,'','left','home',103261,NULL,NULL,3,'/admin/menus.php?leftmenu=setup','','Menus','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103267,'auguria',1,'','left','home',103261,NULL,NULL,6,'/admin/delais.php?leftmenu=setup','','Alerts','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103268,'auguria',1,'','left','home',103261,NULL,NULL,9,'/admin/pdf.php?leftmenu=setup','','PDF','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103269,'auguria',1,'','left','home',103261,NULL,NULL,7,'/admin/proxy.php?leftmenu=setup','','Security','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103270,'auguria',1,'','left','home',103261,NULL,NULL,10,'/admin/mails.php?leftmenu=setup','','Emails','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103271,'auguria',1,'','left','home',103261,NULL,NULL,8,'/admin/limits.php?leftmenu=setup','','MenuLimits','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103272,'auguria',1,'','left','home',103261,NULL,NULL,12,'/admin/dict.php?leftmenu=setup','','DictionnarySetup','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103273,'auguria',1,'','left','home',103261,NULL,NULL,13,'/admin/const.php?leftmenu=setup','','OtherSetup','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103274,'auguria',1,'','left','home',103261,NULL,NULL,11,'/admin/sms.php?leftmenu=setup','','Sms','admin',1,'','','$leftmenu==\'setup\'',2,'2013-03-24 02:31:47'),(103362,'auguria',1,'','left','home',103461,NULL,NULL,0,'/admin/system/dolibarr.php?leftmenu=admintools','','InfoDolibarr','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103364,'auguria',1,'','left','home',103461,NULL,NULL,13,'/admin/system/about.php?leftmenu=admintools','','About','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103365,'auguria',1,'','left','home',103461,NULL,NULL,1,'/admin/system/os.php?leftmenu=admintools','','InfoOS','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103366,'auguria',1,'','left','home',103461,NULL,NULL,2,'/admin/system/web.php?leftmenu=admintools','','InfoWebServer','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103367,'auguria',1,'','left','home',103461,NULL,NULL,3,'/admin/system/phpinfo.php?leftmenu=admintools','','InfoPHP','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103368,'auguria',1,'','left','home',103362,NULL,NULL,3,'/admin/triggers.php?leftmenu=admintools','','Triggers','admin',2,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103369,'auguria',1,'','left','home',103362,NULL,NULL,2,'/admin/system/modules.php?leftmenu=admintools','','Modules','admin',2,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103371,'auguria',1,'','left','home',103461,NULL,NULL,4,'/admin/system/database.php?leftmenu=admintools','','InfoDatabase','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103461,'auguria',1,'','left','home',103162,NULL,NULL,2,'/admin/tools/index.php?leftmenu=admintools','','SystemTools','admin',0,'admintools','','$user->admin',2,'2013-03-24 02:31:47'),(103462,'auguria',1,'','left','home',103461,NULL,NULL,5,'/admin/tools/dolibarr_export.php?leftmenu=admintools','','Backup','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103463,'auguria',1,'','left','home',103461,NULL,NULL,6,'/admin/tools/dolibarr_import.php?leftmenu=admintools','','Restore','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103464,'auguria',1,'','left','home',103461,NULL,NULL,11,'/admin/tools/purge.php?leftmenu=admintools','','Purge','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103465,'auguria',1,'','left','home',103461,NULL,NULL,8,'/admin/tools/eaccelerator.php?leftmenu=admintools','','EAccelerator','admin',1,'','','$leftmenu==\'admintools\' && function_exists(\'eaccelerator_info\')',2,'2013-03-24 02:31:47'),(103466,'auguria',1,'','left','home',103461,NULL,NULL,7,'/admin/tools/update.php?leftmenu=admintools','','MenuUpgrade','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103467,'auguria',1,'','left','home',103461,NULL,NULL,9,'/admin/tools/listevents.php?leftmenu=admintools','','Audit','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103468,'auguria',1,'','left','home',103461,NULL,NULL,12,'/support/index.php?leftmenu=admintools','_blank','HelpCenter','help',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103469,'auguria',1,'','left','home',103461,NULL,NULL,10,'/admin/tools/listsessions.php?leftmenu=admintools','','Sessions','admin',1,'','','$leftmenu==\'admintools\'',2,'2013-03-24 02:31:47'),(103561,'auguria',1,'','left','home',103162,NULL,NULL,3,'/user/home.php?leftmenu=users','','MenuUsersAndGroups','users',0,'users','','1',2,'2013-03-24 02:31:47'),(103562,'auguria',1,'','left','home',103561,NULL,NULL,0,'/user/index.php?leftmenu=users','','Users','users',1,'','$user->rights->user->user->lire || $user->admin','$leftmenu==\'users\'',2,'2013-03-24 02:31:47'),(103563,'auguria',1,'','left','home',103562,NULL,NULL,0,'/user/card.php?leftmenu=users&action=create','','NewUser','users',2,'','$user->rights->user->user->creer || $user->admin','$leftmenu==\'users\'',2,'2013-03-24 02:31:47'),(103564,'auguria',1,'','left','home',103561,NULL,NULL,1,'/user/group/index.php?leftmenu=users','','Groups','users',1,'','($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin','$leftmenu==\'users\'',2,'2013-03-24 02:31:47'),(103565,'auguria',1,'','left','home',103564,NULL,NULL,0,'/user/group/card.php?leftmenu=users&action=create','','NewGroup','users',2,'','($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin','$leftmenu==\'users\'',2,'2013-03-24 02:31:47'),(103661,'auguria',1,'','left','companies',103163,NULL,NULL,0,'/societe/index.php?leftmenu=thirdparties','','ThirdParty','companies',0,'thirdparties','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103662,'auguria',1,'','left','companies',103661,NULL,NULL,0,'/societe/soc.php?action=create','','MenuNewThirdParty','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103664,'auguria',1,'','left','companies',103661,NULL,NULL,5,'/fourn/liste.php?leftmenu=suppliers','','ListSuppliersShort','suppliers',1,'','$user->rights->societe->lire && $user->rights->fournisseur->lire','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(103665,'auguria',1,'','left','companies',103664,NULL,NULL,0,'/societe/soc.php?leftmenu=supplier&action=create&type=f','','NewSupplier','suppliers',2,'','$user->rights->societe->creer','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(103667,'auguria',1,'','left','companies',103661,NULL,NULL,3,'/comm/prospect/list.php?leftmenu=prospects','','ListProspectsShort','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103668,'auguria',1,'','left','companies',103667,NULL,NULL,0,'/societe/soc.php?leftmenu=prospects&action=create&type=p','','MenuNewProspect','companies',2,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103670,'auguria',1,'','left','companies',103661,NULL,NULL,4,'/comm/list.php?leftmenu=customers','','ListCustomersShort','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103671,'auguria',1,'','left','companies',103670,NULL,NULL,0,'/societe/soc.php?leftmenu=customers&action=create&type=c','','MenuNewCustomer','companies',2,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103761,'auguria',1,'','left','companies',103163,NULL,NULL,1,'/contact/list.php?leftmenu=contacts','','ContactsAddresses','companies',0,'contacts','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103762,'auguria',1,'','left','companies',103761,NULL,NULL,0,'/contact/card.php?leftmenu=contacts&action=create','','NewContactAddress','companies',1,'','$user->rights->societe->creer','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103763,'auguria',1,'','left','companies',103761,NULL,NULL,1,'/contact/list.php?leftmenu=contacts','','List','companies',1,'','$user->rights->societe->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103765,'auguria',1,'','left','companies',103763,NULL,NULL,1,'/contact/list.php?leftmenu=contacts&type=p','','Prospects','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103766,'auguria',1,'','left','companies',103763,NULL,NULL,2,'/contact/list.php?leftmenu=contacts&type=c','','Customers','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103767,'auguria',1,'','left','companies',103763,NULL,NULL,3,'/contact/list.php?leftmenu=contacts&type=f','','Suppliers','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled && $conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(103768,'auguria',1,'','left','companies',103763,NULL,NULL,4,'/contact/list.php?leftmenu=contacts&type=o','','Others','companies',2,'','$user->rights->societe->contact->lire','$conf->societe->enabled',2,'2013-03-24 02:31:47'),(103811,'auguria',1,'','left','companies',103163,NULL,NULL,3,'/categories/index.php?leftmenu=cat&type=1','','SuppliersCategoriesShort','categories',0,'cat','$user->rights->categorie->lire','$conf->societe->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:47'),(103812,'auguria',1,'','left','companies',103811,NULL,NULL,0,'/categories/card.php?action=create&type=1','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->societe->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:47'),(103821,'auguria',1,'','left','companies',103163,NULL,NULL,4,'/categories/index.php?leftmenu=cat&type=2','','CustomersProspectsCategoriesShort','categories',0,'cat','$user->rights->categorie->lire','$conf->fournisseur->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:47'),(103822,'auguria',1,'','left','companies',103821,NULL,NULL,0,'/categories/card.php?action=create&type=2','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->fournisseur->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:47'),(104261,'auguria',1,'','left','commercial',103166,NULL,NULL,4,'/comm/propal/index.php?leftmenu=propals','','Prop','propal',0,'propals','$user->rights->propale->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(104262,'auguria',1,'','left','commercial',104261,NULL,NULL,0,'/societe/societe.php?leftmenu=propals','','NewPropal','propal',1,'','$user->rights->propale->creer','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(104263,'auguria',1,'','left','commercial',104261,NULL,NULL,1,'/comm/propal/list.php?leftmenu=propals','','List','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(104264,'auguria',1,'','left','commercial',104263,NULL,NULL,2,'/comm/propal/list.php?leftmenu=propals&viewstatut=0','','PropalsDraft','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104265,'auguria',1,'','left','commercial',104263,NULL,NULL,3,'/comm/propal/list.php?leftmenu=propals&viewstatut=1','','PropalsOpened','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104266,'auguria',1,'','left','commercial',104263,NULL,NULL,4,'/comm/propal/list.php?leftmenu=propals&viewstatut=2','','PropalStatusSigned','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104267,'auguria',1,'','left','commercial',104263,NULL,NULL,5,'/comm/propal/list.php?leftmenu=propals&viewstatut=3','','PropalStatusNotSigned','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104268,'auguria',1,'','left','commercial',104263,NULL,NULL,6,'/comm/propal/list.php?leftmenu=propals&viewstatut=4','','PropalStatusBilled','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled && $leftmenu==\"propals\"',2,'2013-03-24 02:31:47'),(104271,'auguria',1,'','left','commercial',104261,NULL,NULL,4,'/comm/propal/stats/index.php?leftmenu=propals','','Statistics','propal',1,'','$user->rights->propale->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(104361,'auguria',1,'','left','commercial',103166,NULL,NULL,5,'/commande/index.php?leftmenu=orders','','CustomersOrders','orders',0,'orders','$user->rights->commande->lire','$conf->commande->enabled',2,'2013-03-24 02:31:47'),(104362,'auguria',1,'','left','commercial',104361,NULL,NULL,0,'/societe/societe.php?leftmenu=orders','','NewOrder','orders',1,'','$user->rights->commande->creer','$conf->commande->enabled',2,'2013-03-24 02:31:47'),(104363,'auguria',1,'','left','commercial',104361,NULL,NULL,1,'/commande/liste.php?leftmenu=orders','','List','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled',2,'2013-03-24 02:31:47'),(104364,'auguria',1,'','left','commercial',104363,NULL,NULL,2,'/commande/liste.php?leftmenu=orders&viewstatut=0','','StatusOrderDraftShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104365,'auguria',1,'','left','commercial',104363,NULL,NULL,3,'/commande/liste.php?leftmenu=orders&viewstatut=1','','StatusOrderValidated','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104366,'auguria',1,'','left','commercial',104363,NULL,NULL,4,'/commande/liste.php?leftmenu=orders&viewstatut=2','','StatusOrderOnProcessShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104367,'auguria',1,'','left','commercial',104363,NULL,NULL,5,'/commande/liste.php?leftmenu=orders&viewstatut=3','','StatusOrderToBill','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104368,'auguria',1,'','left','commercial',104363,NULL,NULL,6,'/commande/liste.php?leftmenu=orders&viewstatut=4','','StatusOrderProcessed','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104369,'auguria',1,'','left','commercial',104363,NULL,NULL,7,'/commande/liste.php?leftmenu=orders&viewstatut=-1','','StatusOrderCanceledShort','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled && $leftmenu==\"orders\"',2,'2013-03-24 02:31:47'),(104370,'auguria',1,'','left','commercial',104361,NULL,NULL,4,'/commande/stats/index.php?leftmenu=orders','','Statistics','orders',1,'','$user->rights->commande->lire','$conf->commande->enabled',2,'2013-03-24 02:31:47'),(104461,'auguria',1,'','left','commercial',103164,NULL,NULL,6,'/expedition/index.php?leftmenu=sendings','','Shipments','sendings',0,'sendings','$user->rights->expedition->lire','$conf->expedition->enabled',2,'2013-03-24 02:31:47'),(104462,'auguria',1,'','left','commercial',104461,NULL,NULL,0,'/expedition/card.php?action=create2&leftmenu=sendings','','NewSending','sendings',1,'','$user->rights->expedition->creer','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-03-24 02:31:47'),(104463,'auguria',1,'','left','commercial',104461,NULL,NULL,1,'/expedition/liste.php?leftmenu=sendings','','List','sendings',1,'','$user->rights->expedition->lire','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-03-24 02:31:47'),(104464,'auguria',1,'','left','commercial',104461,NULL,NULL,2,'/expedition/stats/index.php?leftmenu=sendings','','Statistics','sendings',1,'','$user->rights->expedition->lire','$conf->expedition->enabled && $leftmenu==\"sendings\"',2,'2013-03-24 02:31:47'),(104561,'auguria',1,'','left','commercial',103166,NULL,NULL,7,'/contrat/index.php?leftmenu=contracts','','Contracts','contracts',0,'contracts','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-03-24 02:31:47'),(104562,'auguria',1,'','left','commercial',104561,NULL,NULL,0,'/societe/societe.php?leftmenu=contracts','','NewContract','contracts',1,'','$user->rights->contrat->creer','$conf->contrat->enabled',2,'2013-03-24 02:31:47'),(104563,'auguria',1,'','left','commercial',104561,NULL,NULL,1,'/contrat/liste.php?leftmenu=contracts','','List','contracts',1,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-03-24 02:31:47'),(104564,'auguria',1,'','left','commercial',104561,NULL,NULL,2,'/contrat/services.php?leftmenu=contracts','','MenuServices','contracts',1,'','$user->rights->contrat->lire','$conf->contrat->enabled',2,'2013-03-24 02:31:47'),(104565,'auguria',1,'','left','commercial',104564,NULL,NULL,0,'/contrat/services.php?leftmenu=contracts&mode=0','','MenuInactiveServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-03-24 02:31:47'),(104566,'auguria',1,'','left','commercial',104564,NULL,NULL,1,'/contrat/services.php?leftmenu=contracts&mode=4','','MenuRunningServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-03-24 02:31:47'),(104567,'auguria',1,'','left','commercial',104564,NULL,NULL,2,'/contrat/services.php?leftmenu=contracts&mode=4&filter=expired','','MenuExpiredServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-03-24 02:31:47'),(104568,'auguria',1,'','left','commercial',104564,NULL,NULL,3,'/contrat/services.php?leftmenu=contracts&mode=5','','MenuClosedServices','contracts',2,'','$user->rights->contrat->lire','$conf->contrat->enabled&&$leftmenu==\"contracts\"',2,'2013-03-24 02:31:47'),(104661,'auguria',1,'','left','commercial',103166,NULL,NULL,8,'/fichinter/list.php?leftmenu=ficheinter','','Interventions','interventions',0,'ficheinter','$user->rights->ficheinter->lire','$conf->ficheinter->enabled',2,'2013-03-24 02:31:47'),(104662,'auguria',1,'','left','commercial',104661,NULL,NULL,0,'/fichinter/card.php?action=create&leftmenu=ficheinter','','NewIntervention','interventions',1,'','$user->rights->ficheinter->creer','$conf->ficheinter->enabled',2,'2013-03-24 02:31:47'),(104663,'auguria',1,'','left','commercial',104661,NULL,NULL,1,'/fichinter/list.php?leftmenu=ficheinter','','List','interventions',1,'','$user->rights->ficheinter->lire','$conf->ficheinter->enabled',2,'2013-03-24 02:31:47'),(104761,'auguria',1,'','left','accountancy',103167,NULL,NULL,3,'/fourn/facture/index.php?leftmenu=suppliers_bills','','BillsSuppliers','bills',0,'supplier_bills','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104762,'auguria',1,'','left','accountancy',104761,NULL,NULL,0,'/fourn/facture/card.php?action=create&leftmenu=suppliers_bills','','NewBill','bills',1,'','$user->rights->fournisseur->facture->creer','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104763,'auguria',1,'','left','accountancy',104761,NULL,NULL,1,'/fourn/facture/impayees.php?leftmenu=suppliers_bills','','Unpaid','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104764,'auguria',1,'','left','accountancy',104761,NULL,NULL,2,'/fourn/facture/paiement.php?leftmenu=suppliers_bills','','Payments','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104765,'auguria',1,'','left','accountancy',104761,NULL,NULL,8,'/compta/facture/stats/index.php?leftmenu=customers_bills&mode=supplier','','Statistics','bills',1,'','$user->rights->fournisseur->facture->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(104861,'auguria',1,'','left','accountancy',103167,NULL,NULL,3,'/compta/facture/list.php?leftmenu=customers_bills','','BillsCustomers','bills',0,'customer_bills','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104862,'auguria',1,'','left','accountancy',104861,NULL,NULL,3,'/compta/clients.php?action=facturer&leftmenu=customers_bills','','NewBill','bills',1,'','$user->rights->facture->creer','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104863,'auguria',1,'','left','accountancy',104861,NULL,NULL,4,'/compta/facture/fiche-rec.php?leftmenu=customers_bills','','Repeatable','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104864,'auguria',1,'','left','accountancy',104861,NULL,NULL,5,'/compta/facture/impayees.php?action=facturer&leftmenu=customers_bills','','Unpaid','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104865,'auguria',1,'','left','accountancy',104861,NULL,NULL,6,'/compta/paiement/liste.php?leftmenu=customers_bills','','Payments','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104871,'auguria',1,'','left','accountancy',104865,NULL,NULL,1,'/compta/paiement/rapport.php?leftmenu=customers_bills','','Reportings','bills',2,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(104872,'auguria',1,'','left','accountancy',103175,NULL,NULL,9,'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank','','MenuChequeDeposits','bills',0,'checks','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-03-24 02:31:47'),(104873,'auguria',1,'','left','accountancy',104872,NULL,NULL,0,'/compta/paiement/cheque/card.php?leftmenu=checks&action=new','','NewCheckDeposit','compta',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-03-24 02:31:47'),(104874,'auguria',1,'','left','accountancy',104872,NULL,NULL,1,'/compta/paiement/cheque/liste.php?leftmenu=checks','','List','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled && $conf->banque->enabled',2,'2013-03-24 02:31:47'),(104875,'auguria',1,'','left','accountancy',104861,NULL,NULL,8,'/compta/facture/stats/index.php?leftmenu=customers_bills','','Statistics','bills',1,'','$user->rights->facture->lire','$conf->facture->enabled',2,'2013-03-24 02:31:47'),(105061,'auguria',1,'','left','accountancy',103167,NULL,NULL,3,'/commande/liste.php?leftmenu=orders&viewstatut=3','','MenuOrdersToBill','orders',0,'orders','$user->rights->commande->lire','$conf->commande->enabled',0,'2013-03-24 02:31:47'),(105161,'auguria',1,'','left','accountancy',103167,NULL,NULL,4,'/compta/dons/index.php?leftmenu=donations&mainmenu=accountancy','','Donations','donations',0,'donations','$user->rights->don->lire','$conf->don->enabled',2,'2013-03-24 02:31:47'),(105162,'auguria',1,'','left','accountancy',105161,NULL,NULL,0,'/compta/dons/card.php?leftmenu=donations&mainmenu=accountancy&action=create','','NewDonation','donations',1,'','$user->rights->don->creer','$conf->don->enabled && $leftmenu==\"donations\"',2,'2013-03-24 02:31:47'),(105163,'auguria',1,'','left','accountancy',105161,NULL,NULL,1,'/compta/dons/liste.php?leftmenu=donations&mainmenu=accountancy','','List','donations',1,'','$user->rights->don->lire','$conf->don->enabled && $leftmenu==\"donations\"',2,'2013-03-24 02:31:47'),(105261,'auguria',1,'','left','accountancy',103167,NULL,NULL,5,'/compta/deplacement/index.php?leftmenu=tripsandexpenses','','TripsAndExpenses','trips',0,'tripsandexpenses','$user->rights->deplacement->lire','$conf->deplacement->enabled',0,'2013-03-24 02:31:47'),(105262,'auguria',1,'','left','accountancy',105261,NULL,NULL,1,'/compta/deplacement/card.php?action=create&leftmenu=tripsandexpenses','','New','trips',1,'','$user->rights->deplacement->creer','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-03-24 02:31:47'),(105263,'auguria',1,'','left','accountancy',105261,NULL,NULL,2,'/compta/deplacement/list.php?leftmenu=tripsandexpenses','','List','trips',1,'','$user->rights->deplacement->lire','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-03-24 02:31:47'),(105264,'auguria',1,'','left','accountancy',105261,NULL,NULL,2,'/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses','','Statistics','trips',1,'','$user->rights->deplacement->lire','$conf->deplacement->enabled && $leftmenu==\"tripsandexpenses\"',0,'2013-03-24 02:31:47'),(105361,'auguria',1,'','left','accountancy',103167,NULL,NULL,6,'/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy','','MenuTaxAndDividends','compta',0,'tax','$user->rights->tax->charges->lire','$conf->tax->enabled',0,'2013-03-24 02:31:47'),(105362,'auguria',1,'','left','accountancy',105361,NULL,NULL,1,'/compta/sociales/index.php?leftmenu=tax_social','','SocialContributions','',1,'tax_social','$user->rights->tax->charges->lire','$conf->tax->enabled',0,'2013-03-24 02:31:47'),(105363,'auguria',1,'','left','accountancy',105362,NULL,NULL,2,'/compta/sociales/charges.php?leftmenu=tax_social&action=create','','MenuNewSocialContribution','',2,'','$user->rights->tax->charges->creer','$conf->tax->enabled && $leftmenu==\"tax_social\"',0,'2013-03-24 02:31:47'),(105364,'auguria',1,'','left','accountancy',105362,NULL,NULL,3,'/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly','','Payments','',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && $leftmenu==\"tax_social\"',0,'2013-03-24 02:31:47'),(105461,'auguria',1,'','left','accountancy',105361,NULL,NULL,7,'/compta/tva/index.php?leftmenu=tax_vat&mainmenu=accountancy','','VAT','companies',1,'tax_vat','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS)',0,'2013-03-24 02:31:47'),(105462,'auguria',1,'','left','accountancy',105461,NULL,NULL,0,'/compta/tva/card.php?leftmenu=tax_vat&action=create','','NewPayment','companies',2,'','$user->rights->tax->charges->creer','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-03-24 02:31:47'),(105463,'auguria',1,'','left','accountancy',105461,NULL,NULL,1,'/compta/tva/reglement.php?leftmenu=tax_vat','','Payments','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-03-24 02:31:47'),(105464,'auguria',1,'','left','accountancy',105461,NULL,NULL,2,'/compta/tva/clients.php?leftmenu=tax_vat','','ReportByCustomers','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-03-24 02:31:47'),(105465,'auguria',1,'','left','accountancy',105461,NULL,NULL,3,'/compta/tva/quadri_detail.php?leftmenu=tax_vat','','ReportByQuarter','companies',2,'','$user->rights->tax->charges->lire','$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu==\"tax_vat\"',0,'2013-03-24 02:31:47'),(105561,'auguria',1,'','left','accountancy',103167,NULL,NULL,8,'/compta/ventilation/index.php?leftmenu=ventil','','Ventilation','companies',0,'ventil','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105562,'auguria',1,'','left','accountancy',105561,NULL,NULL,0,'/compta/ventilation/liste.php','','ToDispatch','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105563,'auguria',1,'','left','accountancy',105561,NULL,NULL,1,'/compta/ventilation/lignes.php','','Dispatched','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105564,'auguria',1,'','left','accountancy',105561,NULL,NULL,2,'/compta/param/','','Setup','companies',1,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105565,'auguria',1,'','left','accountancy',105564,NULL,NULL,0,'/compta/param/comptes/liste.php','','List','companies',2,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105566,'auguria',1,'','left','accountancy',105564,NULL,NULL,1,'/compta/param/comptes/card.php?action=create','','New','companies',2,'','$user->rights->compta->ventilation->parametrer','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105567,'auguria',1,'','left','accountancy',105561,NULL,NULL,3,'/compta/export/','','Export','companies',1,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105568,'auguria',1,'','left','accountancy',105567,NULL,NULL,0,'/compta/export/index.php','','New','companies',2,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105569,'auguria',1,'','left','accountancy',105567,NULL,NULL,1,'/compta/export/liste.php','','List','companies',2,'','$user->rights->compta->ventilation->lire','$conf->comptabilite->enabled && $conf->global->FACTURE_VENTILATION',0,'2013-03-24 02:31:47'),(105661,'auguria',1,'','left','accountancy',103175,NULL,NULL,9,'/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank','','StandingOrders','withdrawals',0,'withdraw','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled',2,'2013-03-24 02:31:47'),(105663,'auguria',1,'','left','accountancy',105661,NULL,NULL,0,'/compta/prelevement/create.php?leftmenu=withdraw','','NewStandingOrder','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105664,'auguria',1,'','left','accountancy',105661,NULL,NULL,2,'/compta/prelevement/bons.php?leftmenu=withdraw','','WithdrawalsReceipts','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105665,'auguria',1,'','left','accountancy',105661,NULL,NULL,3,'/compta/prelevement/liste.php?leftmenu=withdraw','','WithdrawalsLines','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105667,'auguria',1,'','left','accountancy',105661,NULL,NULL,5,'/compta/prelevement/rejets.php?leftmenu=withdraw','','Rejects','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105668,'auguria',1,'','left','accountancy',105661,NULL,NULL,6,'/compta/prelevement/stats.php?leftmenu=withdraw','','Statistics','withdrawals',1,'','$user->rights->prelevement->bons->lire','$conf->prelevement->enabled && $leftmenu==\"withdraw\"',2,'2013-03-24 02:31:47'),(105761,'auguria',1,'','left','accountancy',103175,NULL,NULL,1,'/compta/bank/index.php?leftmenu=bank&mainmenu=bank','','MenuBankCash','banks',0,'bank','$user->rights->banque->lire','$conf->banque->enabled',0,'2013-03-24 02:31:47'),(105762,'auguria',1,'','left','accountancy',105761,NULL,NULL,0,'/compta/bank/card.php?action=create&leftmenu=bank','','MenuNewFinancialAccount','banks',1,'','$user->rights->banque->configurer','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105763,'auguria',1,'','left','accountancy',105761,NULL,NULL,1,'/compta/bank/categ.php?leftmenu=bank','','Rubriques','categories',1,'','$user->rights->banque->configurer','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105764,'auguria',1,'','left','accountancy',105761,NULL,NULL,2,'/compta/bank/search.php?leftmenu=bank','','ListTransactions','banks',1,'','$user->rights->banque->lire','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105765,'auguria',1,'','left','accountancy',105761,NULL,NULL,3,'/compta/bank/budget.php?leftmenu=bank','','ListTransactionsByCategory','banks',1,'','$user->rights->banque->lire','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105767,'auguria',1,'','left','accountancy',105761,NULL,NULL,5,'/compta/bank/virement.php?leftmenu=bank','','BankTransfers','banks',1,'','$user->rights->banque->transfer','$conf->banque->enabled && ($leftmenu==\"bank\" || $leftmenu==\"checks\" || $leftmenu==\"withdraw\")',0,'2013-03-24 02:31:47'),(105861,'auguria',1,'','left','accountancy',103167,NULL,NULL,11,'/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy','','Reportings','main',0,'ca','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105862,'auguria',1,'','left','accountancy',105861,NULL,NULL,0,'/compta/resultat/index.php?leftmenu=ca','','ReportInOut','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105863,'auguria',1,'','left','accountancy',105862,NULL,NULL,0,'/compta/resultat/clientfourn.php?leftmenu=ca','','ByCompanies','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105864,'auguria',1,'','left','accountancy',105861,NULL,NULL,1,'/compta/stats/index.php?leftmenu=ca','','ReportTurnover','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105865,'auguria',1,'','left','accountancy',105864,NULL,NULL,0,'/compta/stats/casoc.php?leftmenu=ca','','ByCompanies','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105866,'auguria',1,'','left','accountancy',105864,NULL,NULL,1,'/compta/stats/cabyuser.php?leftmenu=ca','','ByUsers','main',2,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105867,'auguria',1,'','left','accountancy',105861,NULL,NULL,1,'/compta/journal/sellsjournal.php?leftmenu=ca','','SellsJournal','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105868,'auguria',1,'','left','accountancy',105861,NULL,NULL,1,'/compta/journal/purchasesjournal.php?leftmenu=ca','','PurchasesJournal','main',1,'','$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire','$conf->comptabilite->enabled || $conf->accounting->enabled',0,'2013-03-24 02:31:47'),(105961,'auguria',1,'','left','products',103164,NULL,NULL,0,'/product/index.php?leftmenu=product&type=0','','Products','products',0,'product','$user->rights->produit->lire','$conf->product->enabled',2,'2013-03-24 02:31:47'),(105962,'auguria',1,'','left','products',105961,NULL,NULL,0,'/product/card.php?leftmenu=product&action=create&type=0','','NewProduct','products',1,'','$user->rights->produit->creer','$conf->product->enabled',2,'2013-03-24 02:31:47'),(105963,'auguria',1,'','left','products',105961,NULL,NULL,1,'/product/liste.php?leftmenu=product&type=0','','List','products',1,'','$user->rights->produit->lire','$conf->product->enabled',2,'2013-03-24 02:31:47'),(105964,'auguria',1,'','left','products',105961,NULL,NULL,4,'/product/reassort.php?type=0','','Stocks','products',1,'','$user->rights->produit->lire && $user->rights->stock->lire','$conf->product->enabled',2,'2013-03-24 02:31:47'),(105965,'auguria',1,'','left','products',105961,NULL,NULL,5,'/product/popuprop.php?leftmenu=stats&type=0','','Statistics','main',1,'','$user->rights->produit->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(106061,'auguria',1,'','left','products',103164,NULL,NULL,1,'/product/index.php?leftmenu=service&type=1','','Services','products',0,'service','$user->rights->service->lire','$conf->service->enabled',2,'2013-03-24 02:31:47'),(106062,'auguria',1,'','left','products',106061,NULL,NULL,0,'/product/card.php?leftmenu=service&action=create&type=1','','NewService','products',1,'','$user->rights->service->creer','$conf->service->enabled',2,'2013-03-24 02:31:47'),(106063,'auguria',1,'','left','products',106061,NULL,NULL,1,'/product/liste.php?leftmenu=service&type=1','','List','products',1,'','$user->rights->service->lire','$conf->service->enabled',2,'2013-03-24 02:31:47'),(106064,'auguria',1,'','left','products',106061,NULL,NULL,5,'/product/popuprop.php?leftmenu=stats&type=1','','Statistics','main',1,'','$user->rights->service->lire','$conf->propal->enabled',2,'2013-03-24 02:31:47'),(106261,'auguria',1,'','left','products',103164,NULL,NULL,3,'/product/stock/index.php?leftmenu=stock','','Stock','stocks',0,'stock','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106262,'auguria',1,'','left','products',106261,NULL,NULL,0,'/product/stock/card.php?action=create','','MenuNewWarehouse','stocks',1,'','$user->rights->stock->creer','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106263,'auguria',1,'','left','products',106261,NULL,NULL,1,'/product/stock/liste.php','','List','stocks',1,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106264,'auguria',1,'','left','products',106261,NULL,NULL,2,'/product/stock/valo.php','','EnhancedValue','stocks',1,'','$user->rights->stock->lire','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106265,'auguria',1,'','left','products',106261,NULL,NULL,3,'/product/stock/mouvement.php','','Movements','stocks',1,'','$user->rights->stock->mouvement->lire','$conf->stock->enabled',2,'2013-03-24 02:31:47'),(106361,'auguria',1,'','left','products',103164,NULL,NULL,4,'/categories/index.php?leftmenu=cat&type=0','','Categories','categories',0,'cat','$user->rights->categorie->lire','$conf->categorie->enabled',2,'2013-03-24 02:31:47'),(106362,'auguria',1,'','left','products',106361,NULL,NULL,0,'/categories/card.php?action=create&type=0','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->categorie->enabled',2,'2013-03-24 02:31:47'),(106761,'auguria',1,'','left','project',103168,NULL,NULL,0,'/projet/index.php?leftmenu=projects','','Projects','projects',0,'projects','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106762,'auguria',1,'','left','project',106761,NULL,NULL,1,'/projet/card.php?leftmenu=projects&action=create','','NewProject','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106763,'auguria',1,'','left','project',106761,NULL,NULL,2,'/projet/liste.php?leftmenu=projects','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106771,'auguria',1,'','left','project',103168,NULL,NULL,0,'/projet/index.php?leftmenu=projects&mode=mine','','MyProjects','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106772,'auguria',1,'','left','project',106771,NULL,NULL,1,'/projet/card.php?leftmenu=projects&action=create&mode=mine','','NewProject','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106773,'auguria',1,'','left','project',106771,NULL,NULL,2,'/projet/liste.php?leftmenu=projects&mode=mine','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106861,'auguria',1,'','left','project',103168,NULL,NULL,0,'/projet/activity/index.php?leftmenu=projects','','Activities','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106862,'auguria',1,'','left','project',106861,NULL,NULL,1,'/projet/tasks.php?leftmenu=projects&action=create','','NewTask','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106863,'auguria',1,'','left','project',106861,NULL,NULL,2,'/projet/tasks/index.php?leftmenu=projects','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106864,'auguria',1,'','left','project',106861,NULL,NULL,3,'/projet/activity/list.php?leftmenu=projects','','NewTimeSpent','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106961,'auguria',1,'','left','project',103168,NULL,NULL,0,'/projet/activity/index.php?leftmenu=projects&mode=mine','','MyActivities','projects',0,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106962,'auguria',1,'','left','project',106961,NULL,NULL,1,'/projet/tasks.php?leftmenu=projects&action=create&mode=mine','','NewTask','projects',1,'','$user->rights->projet->creer','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106963,'auguria',1,'','left','project',106961,NULL,NULL,2,'/projet/tasks/index.php?leftmenu=projects&mode=mine','','List','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(106964,'auguria',1,'','left','project',106961,NULL,NULL,3,'/projet/activity/list.php?leftmenu=projects&mode=mine','','NewTimeSpent','projects',1,'','$user->rights->projet->lire','$conf->projet->enabled',2,'2013-03-24 02:31:47'),(107061,'auguria',1,'','left','tools',103169,NULL,NULL,0,'/comm/mailing/index.php?leftmenu=mailing','','EMailings','mails',0,'mailing','$user->rights->mailing->lire','$conf->mailing->enabled',0,'2013-03-24 02:31:47'),(107062,'auguria',1,'','left','tools',107061,NULL,NULL,0,'/comm/mailing/card.php?leftmenu=mailing&action=create','','NewMailing','mails',1,'','$user->rights->mailing->creer','$conf->mailing->enabled',0,'2013-03-24 02:31:47'),(107063,'auguria',1,'','left','tools',107061,NULL,NULL,1,'/comm/mailing/liste.php?leftmenu=mailing','','List','mails',1,'','$user->rights->mailing->lire','$conf->mailing->enabled',0,'2013-03-24 02:31:47'),(107261,'auguria',1,'','left','tools',103169,NULL,NULL,2,'/exports/index.php?leftmenu=export','','FormatedExport','exports',0,'export','$user->rights->export->lire','$conf->export->enabled',2,'2013-03-24 02:31:47'),(107262,'auguria',1,'','left','tools',107261,NULL,NULL,0,'/exports/export.php?leftmenu=export','','NewExport','exports',1,'','$user->rights->export->creer','$conf->export->enabled',2,'2013-03-24 02:31:47'),(107291,'auguria',1,'','left','tools',103169,NULL,NULL,2,'/imports/index.php?leftmenu=import','','FormatedImport','exports',0,'import','$user->rights->import->run','$conf->import->enabled',2,'2013-03-24 02:31:47'),(107292,'auguria',1,'','left','tools',107291,NULL,NULL,0,'/imports/import.php?leftmenu=import','','NewImport','exports',1,'','$user->rights->import->run','$conf->import->enabled',2,'2013-03-24 02:31:47'),(107361,'auguria',1,'','left','members',103174,NULL,NULL,0,'/adherents/index.php?leftmenu=members&mainmenu=members','','Members','members',0,'members','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107362,'auguria',1,'','left','members',107361,NULL,NULL,0,'/adherents/card.php?leftmenu=members&action=create','','NewMember','members',1,'','$user->rights->adherent->creer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107363,'auguria',1,'','left','members',107361,NULL,NULL,1,'/adherents/liste.php','','List','members',1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107364,'auguria',1,'','left','members',107363,NULL,NULL,2,'/adherents/liste.php?leftmenu=members&statut=-1','','MenuMembersToValidate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107365,'auguria',1,'','left','members',107363,NULL,NULL,3,'/adherents/liste.php?leftmenu=members&statut=1','','MenuMembersValidated','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107366,'auguria',1,'','left','members',107363,NULL,NULL,4,'/adherents/liste.php?leftmenu=members&statut=1&filter=outofdate','','MenuMembersNotUpToDate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107367,'auguria',1,'','left','members',107363,NULL,NULL,5,'/adherents/liste.php?leftmenu=members&statut=1&filter=uptodate','','MenuMembersUpToDate','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107368,'auguria',1,'','left','members',107363,NULL,NULL,6,'/adherents/liste.php?leftmenu=members&statut=0','','MenuMembersResiliated','members',2,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107369,'auguria',1,'','left','members',107361,NULL,NULL,7,'/adherents/stats/geo.php?leftmenu=members&mode=memberbycountry','','MenuMembersStats','members',1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107461,'auguria',1,'','left','members',103174,NULL,NULL,1,'/adherents/index.php?leftmenu=members&mainmenu=members','','Subscriptions','compta',0,'','$user->rights->adherent->cotisation->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107462,'auguria',1,'','left','members',107461,NULL,NULL,0,'/adherents/liste.php?statut=-1&leftmenu=accountancy&mainmenu=members','','NewSubscription','compta',1,'','$user->rights->adherent->cotisation->creer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107463,'auguria',1,'','left','members',107461,NULL,NULL,1,'/adherents/cotisations.php?leftmenu=members','','List','compta',1,'','$user->rights->adherent->cotisation->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107464,'auguria',1,'','left','members',107461,NULL,NULL,7,'/adherents/stats/index.php?leftmenu=members','','MenuMembersStats','members',1,'','$user->rights->adherent->lire','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107661,'auguria',1,'','left','members',103174,NULL,NULL,3,'/adherents/index.php?leftmenu=export&mainmenu=members','','Exports','members',0,'export','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107662,'auguria',1,'','left','members',107661,NULL,NULL,0,'/exports/index.php?leftmenu=export','','Datas','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled && $conf->export->enabled',2,'2013-03-24 02:31:48'),(107663,'auguria',1,'','left','members',107661,NULL,NULL,1,'/adherents/htpasswd.php?leftmenu=export','','Filehtpasswd','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107664,'auguria',1,'','left','members',107661,NULL,NULL,2,'/adherents/cartes/carte.php?leftmenu=export','','MembersCards','members',1,'','$user->rights->adherent->export','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107861,'auguria',1,'','left','members',103174,NULL,NULL,5,'/adherents/type.php?leftmenu=setup&mainmenu=members','','MembersTypes','members',0,'setup','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107862,'auguria',1,'','left','members',107861,NULL,NULL,0,'/adherents/type.php?leftmenu=setup&mainmenu=members&action=create','','New','members',1,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(107863,'auguria',1,'','left','members',107861,NULL,NULL,1,'/adherents/type.php?leftmenu=setup&mainmenu=members','','List','members',1,'','$user->rights->adherent->configurer','$conf->adherent->enabled',2,'2013-03-24 02:31:48'),(108261,'auguria',1,'','left','commercial',103166,NULL,NULL,6,'/fourn/commande/index.php?leftmenu=orders_suppliers','','SuppliersOrders','orders',0,'orders_suppliers','$user->rights->fournisseur->commande->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(108262,'auguria',1,'','left','commercial',108261,NULL,NULL,0,'/societe/societe.php?leftmenu=orders_suppliers','','NewOrder','orders',1,'','$user->rights->fournisseur->commande->creer','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(108263,'auguria',1,'','left','commercial',108261,NULL,NULL,1,'/fourn/commande/liste.php?leftmenu=orders_suppliers&viewstatut=0','','List','orders',1,'','$user->rights->fournisseur->commande->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(108269,'auguria',1,'','left','commercial',108261,NULL,NULL,7,'/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier','','Statistics','orders',1,'','$user->rights->fournisseur->commande->lire','$conf->fournisseur->enabled',2,'2013-03-24 02:31:47'),(108361,'auguria',1,'','left','members',103174,NULL,NULL,3,'/categories/index.php?leftmenu=cat&type=3','','MembersCategoriesShort','categories',0,'cat','$user->rights->categorie->lire','$conf->adherent->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:48'),(108362,'auguria',1,'','left','members',108361,NULL,NULL,0,'/categories/card.php?action=create&type=3','','NewCategory','categories',1,'','$user->rights->categorie->creer','$conf->adherent->enabled && $conf->categorie->enabled',2,'2013-03-24 02:31:48'),(108457,'all',1,'barcode','left','tools',-1,NULL,'tools',200,'/barcode/printsheet.php?mainmenu=home&leftmenu=modulesadmintools','','BarCodePrintsheet','products',NULL,'barcodeprint','1','$conf->barcode->enabled',2,'2014-03-02 15:37:26'),(108458,'all',1,'barcode','left','home',-1,'modulesadmintools','home',300,'/barcode/codeinit.php?mainmenu=home&leftmenu=modulesadmintools','','MassBarcodeInit','products',NULL,NULL,'1','$conf->barcode->enabled && $leftmenu==\"modulesadmintools\"',0,'2014-03-02 15:37:26'),(108459,'all',1,'agenda','top','agenda',0,NULL,NULL,100,'/comm/action/index.php','','Agenda','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108460,'all',1,'agenda','left','agenda',108459,NULL,NULL,100,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda','','Actions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108461,'all',1,'agenda','left','agenda',108460,NULL,NULL,101,'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create','','NewAction','commercial',NULL,NULL,'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108462,'all',1,'agenda','left','agenda',108460,NULL,NULL,102,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda','','Calendar','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108463,'all',1,'agenda','left','agenda',108462,NULL,NULL,103,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine','','MenuToDoMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108464,'all',1,'agenda','left','agenda',108462,NULL,NULL,104,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine','','MenuDoneMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108465,'all',1,'agenda','left','agenda',108462,NULL,NULL,105,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo','','MenuToDoActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2014-12-21 12:51:26'),(108466,'all',1,'agenda','left','agenda',108462,NULL,NULL,106,'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done','','MenuDoneActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2014-12-21 12:51:26'),(108467,'all',1,'agenda','left','agenda',108460,NULL,NULL,112,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda','','List','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108468,'all',1,'agenda','left','agenda',108467,NULL,NULL,113,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine','','MenuToDoMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108469,'all',1,'agenda','left','agenda',108467,NULL,NULL,114,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine','','MenuDoneMyActions','agenda',NULL,NULL,'$user->rights->agenda->myactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108470,'all',1,'agenda','left','agenda',108467,NULL,NULL,115,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=todo','','MenuToDoActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2014-12-21 12:51:26'),(108471,'all',1,'agenda','left','agenda',108467,NULL,NULL,116,'/comm/action/listactions.php?mainmenu=agenda&leftmenu=agenda&status=done','','MenuDoneActions','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$user->rights->agenda->allactions->read',2,'2014-12-21 12:51:26'),(108472,'all',1,'agenda','left','agenda',108460,NULL,NULL,120,'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda','','Reportings','agenda',NULL,NULL,'$user->rights->agenda->allactions->read','$conf->agenda->enabled',2,'2014-12-21 12:51:26'),(108473,'all',1,'ecm','top','ecm',0,NULL,NULL,100,'/ecm/index.php','','MenuECM','ecm',NULL,NULL,'$user->rights->ecm->read || $user->rights->ecm->upload || $user->rights->ecm->setup','$conf->ecm->enabled',2,'2014-12-21 12:51:28'),(108474,'all',1,'ecm','left','ecm',-1,NULL,'ecm',101,'/ecm/index.php?mainmenu=ecm&leftmenu=ecm','','ECMArea','ecm',NULL,'ecm','$user->rights->ecm->read || $user->rights->ecm->upload','$user->rights->ecm->read || $user->rights->ecm->upload',2,'2014-12-21 12:51:28'),(108475,'all',1,'ecm','left','ecm',-1,'ecm','ecm',102,'/ecm/index.php?action=file_manager&mainmenu=ecm&leftmenu=ecm','','ECMSectionsManual','ecm',NULL,'ecm_manual','$user->rights->ecm->read || $user->rights->ecm->upload','$user->rights->ecm->read || $user->rights->ecm->upload',2,'2014-12-21 12:51:28'),(108476,'all',1,'ecm','left','ecm',-1,'ecm','ecm',103,'/ecm/index_auto.php?action=file_manager&mainmenu=ecm&leftmenu=ecm','','ECMSectionsAuto','ecm',NULL,NULL,'$user->rights->ecm->read || $user->rights->ecm->upload','$user->rights->ecm->read || $user->rights->ecm->upload',2,'2014-12-21 12:51:28'),(108477,'all',1,'opensurvey','left','tools',-1,NULL,'tools',200,'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey','','Survey','opensurvey',NULL,'opensurvey','','$conf->opensurvey->enabled',0,'2014-12-21 19:52:31'),(108478,'all',1,'opensurvey','left','tools',-1,'opensurvey','tools',210,'/opensurvey/wizard/index.php','','NewSurvey','opensurvey',NULL,'opensurvey_new','$user->rights->opensurvey->write','$conf->opensurvey->enabled',0,'2014-12-21 19:52:31'),(108479,'all',1,'opensurvey','left','tools',-1,'opensurvey','tools',220,'/opensurvey/list.php','','List','opensurvey',NULL,'opensurvey_list','','$conf->opensurvey->enabled',0,'2014-12-21 19:52:31'); /*!40000 ALTER TABLE `llx_menu` ENABLE KEYS */; UNLOCK TABLES; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 2be5d4336d6..b9850a7f98f 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -358,7 +358,7 @@ if ($result) print ''; } else if ($links[$key]['type']=='user') { - print ''; + print ''; print img_object($langs->trans('ShowUser'),'user').' '; print $langs->trans("User"); print ''; From 31be2563c23a087283b29c2e37fb5a9282ee4fa6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jan 2015 12:29:55 +0100 Subject: [PATCH 144/152] Fixed: Allow external module a chance to fix regression. --- htdocs/core/lib/functions2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index cd99afaf373..826008036db 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -608,7 +608,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskraz=-1; $maskoffset=0; $resetEveryMonth=false; - if (dol_strlen($maskcounter) < 3) return 'CounterMustHaveMoreThan3Digits'; + if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) return 'CounterMustHaveMoreThan3Digits'; // Extract value for third party mask counter if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef)) From 5c007e53beb66d6fd4ef1285810d8f25ee488991 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jan 2015 18:35:02 +0100 Subject: [PATCH 145/152] Update sample examples --- dev/ldap/ldapadd_sample1.txt | 1 + dev/ldap/ldapadd_sample2.txt | 1 + dev/ldap/ldapadd_sample3.txt | 1 + dev/ldap/ldapdelete_sample1.txt | 1 + dev/ldap/ldapdelete_sample3.txt | 1 + dev/ldap/ldapmodify_sample1.txt | 1 + dev/ldap/ldapsearch_sample1.txt | 9 +++++++++ 7 files changed, 15 insertions(+) create mode 100644 dev/ldap/ldapsearch_sample1.txt diff --git a/dev/ldap/ldapadd_sample1.txt b/dev/ldap/ldapadd_sample1.txt index 2a9738381a7..8a28529acb8 100644 --- a/dev/ldap/ldapadd_sample1.txt +++ b/dev/ldap/ldapadd_sample1.txt @@ -1,4 +1,5 @@ # ldapadd_sample1.txt +# ldapadd is into package ldap-utils on debian. # # Use this sample to add a dc "my-domain". # This is the first thing to create diff --git a/dev/ldap/ldapadd_sample2.txt b/dev/ldap/ldapadd_sample2.txt index 356481fe247..8b4f2469899 100644 --- a/dev/ldap/ldapadd_sample2.txt +++ b/dev/ldap/ldapadd_sample2.txt @@ -1,4 +1,5 @@ # ldapadd_sample2.txt +# ldapadd is into package ldap-utils on debian. # # Use this sample to add a ou "contacts" # This is the second thing to create after creating the root my-domain diff --git a/dev/ldap/ldapadd_sample3.txt b/dev/ldap/ldapadd_sample3.txt index 65576a79090..531d0d00017 100644 --- a/dev/ldap/ldapadd_sample3.txt +++ b/dev/ldap/ldapadd_sample3.txt @@ -1,4 +1,5 @@ # ldapadd_sample3.txt +# ldapadd is into package ldap-utils on debian. # # Use this sample to add cn records # This is the step to create records inside tree ou=contacts,dc=my-domain,dc=com diff --git a/dev/ldap/ldapdelete_sample1.txt b/dev/ldap/ldapdelete_sample1.txt index cc2db307eeb..3198ffd276d 100644 --- a/dev/ldap/ldapdelete_sample1.txt +++ b/dev/ldap/ldapdelete_sample1.txt @@ -1,4 +1,5 @@ # ldapdelete_sample1.txt +# ldapdelete is into package ldap-utils on debian. # # Use this sample to delete a dc "my-domain" # This delete the first level of LDAP tree. diff --git a/dev/ldap/ldapdelete_sample3.txt b/dev/ldap/ldapdelete_sample3.txt index 3d2d357d876..737b6818ffb 100644 --- a/dev/ldap/ldapdelete_sample3.txt +++ b/dev/ldap/ldapdelete_sample3.txt @@ -1,4 +1,5 @@ # ldapdelete_sample3.txt +# ldapdelete is into package ldap-utils on debian. # # Use this sample to delete cn records # This is the step to delete a cn record stored inside tree ou=contacts,dc=my-domain,dc=com diff --git a/dev/ldap/ldapmodify_sample1.txt b/dev/ldap/ldapmodify_sample1.txt index f80c6ac25b9..e3a8361ca31 100644 --- a/dev/ldap/ldapmodify_sample1.txt +++ b/dev/ldap/ldapmodify_sample1.txt @@ -1,4 +1,5 @@ # ldapmodify_sample1.txt +# ldapmodify is into package ldap-utils on debian. # # Use this sample to modify a dc "my-domain" # diff --git a/dev/ldap/ldapsearch_sample1.txt b/dev/ldap/ldapsearch_sample1.txt new file mode 100644 index 00000000000..fb7c4f85543 --- /dev/null +++ b/dev/ldap/ldapsearch_sample1.txt @@ -0,0 +1,9 @@ +# ldapsearch_sample1.txt +# ldapsearch is into package ldap-utils on debian. +# +# Use this sample to search into a ldap +# +# ldapsearch -h hostname -x +# ldapsearch -h hostname -x -b "ou=people,dc=teclib,dc=infra" +# ldapsearch -h hostname -x -z 0 -b "o=somecompany.com" -D "cn=manager,o=somecompany.com" -W "(objectclass=*)" +# ldapsearch -h hostname -x -b "o=somecompany.com" -D "cn=manager,o=somecompany.com" -W "(objectclass=*)" From 36c083e9db1282b4d97df926453f0efb9af77119 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jan 2015 18:44:02 +0100 Subject: [PATCH 146/152] Fixed: Refresh was doing update --- htdocs/projet/element.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index e30a5bfffdc..df420f159d7 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -275,7 +275,7 @@ foreach ($listofreferent as $key => $value) { print ''; print ''; - print ''; + print ''; print '
'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 34bda84ae6e..e8ace86cf73 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2606,7 +2606,9 @@ class Propal extends CommonObject $result=''; $label=$langs->trans("ShowPropal").': '.$this->ref; - $linkclose = '" title="'.$label.'" class="classfortooltip">'; + if (! empty($this->ref_client)) + $label.= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; if ($option == '') { $lien = 'ref; + if (! empty($this->ref_client)) + $label.= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; - $linkstart = '
'; + $linkstart = ''; $linkend=''; if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b2e3dc79f78..5ecca4047e6 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -935,7 +935,7 @@ class Account extends CommonObject global $langs; $result=''; - $linkclose = '" title="'.$this->label.'" class="classfortooltip">'; + $linkclose = '" title="'.dol_escape_htmltag($this->label, 1).'" class="classfortooltip">'; if (empty($mode)) { @@ -1485,7 +1485,7 @@ class AccountLine extends CommonObject $result=''; $label=$langs->trans("ShowTransaction").': '.$this->rowid; - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($label, 'account', 'class="classfortooltip"').$lienfin.' '); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index e7a3350f2f3..b54ac75bc23 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -359,7 +359,7 @@ class Deplacement extends CommonObject $result=''; $label=$langs->trans("Show").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='trip'; diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index c2f800f4a13..69a84831b90 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -713,7 +713,7 @@ class Don extends CommonObject $result=''; $label=$langs->trans("ShowDonation").': '.$this->id; - $lien = ''; + $lien = ''; $lienfin=''; $picto='generic'; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 1a8e22a14bc..cadce3db632 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -560,7 +560,7 @@ class FactureRec extends Facture $result=''; $label=$langs->trans("ShowInvoice").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='bill'; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 03b927d28a3..32d7fa13122 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -865,7 +865,7 @@ class Facture extends CommonInvoice if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; if ($moretitle) $label.=' - '.$moretitle; - $linkstart=''; + $linkstart=''; $linkend=''; if ($withpicto) $result.=($linkstart.img_object(($max?dol_trunc($label,$max):$label), $picto, 'class="classfortooltip"').$linkend); diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index e6c3c6e0942..1512d0d39ac 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -587,7 +587,7 @@ class Localtax extends CommonObject $result=''; $label=$langs->trans("ShowVatPayment").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='payment'; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index a1d3c53052c..11a61874e7e 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -771,7 +771,7 @@ class RemiseCheque extends CommonObject $result=''; $label = $langs->trans("ShowCheckReceipt").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($label, 'payment', 'class="classfortooltip"').$lienfin); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index b303420dd15..b73eb490296 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -750,7 +750,7 @@ class Paiement extends CommonObject $result=''; $label = $langs->trans("ShowPayment").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment"), 'payment', 'class="classfortooltip"').$lienfin); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3a30cf690d3..22e0a078c23 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1120,12 +1120,12 @@ class BonPrelevement extends CommonObject $result=''; $label = $langs->trans("ShowWithdraw").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; if ($option == 'xxx') { - $lien = ''; + $lien = ''; $lienfin=''; } diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 1e2d437793c..83a1c937545 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -488,7 +488,7 @@ class PaymentSalary extends CommonObject $result=''; $label=$langs->trans("ShowSalaryPayment").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='payment'; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index d0fe9b11ea3..af8eedb617c 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -422,7 +422,7 @@ class ChargeSociales extends CommonObject if (empty($this->ref)) $this->ref=$this->lib; $label = $langs->trans("ShowSocialContribution").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($label, 'bill', 'class="classfortooltip"').$lienfin.' '); diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 55316e15b22..cf407e091f4 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -589,7 +589,7 @@ class PaymentSocialContribution extends CommonObject if (!empty($this->id)) { - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($label, 'payment', 'class="classfortooltip"').$lienfin.' '); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 4730d72e596..c32297a7e12 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -640,7 +640,7 @@ class Tva extends CommonObject $result=''; $label=$langs->trans("ShowVatPayment").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='payment'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 40be02a3ef1..f3cbeccd586 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -889,12 +889,12 @@ class Contact extends CommonObject $result=''; $label = $langs->trans("ShowContact").': '.$this->getFullName($langs); - $lien = ''; + $lien = ''; $lienfin=''; if ($option == 'xxx') { - $lien = ''; + $lien = ''; $lienfin=''; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 00dce5b3336..4d455f79369 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1684,7 +1684,7 @@ class Contrat extends CommonObject $result=''; $label=$langs->trans("ShowContract").': '.$this->ref; - $lien = ''; + $lien = ''; $lienfin=''; $picto='contract'; @@ -2213,7 +2213,7 @@ class ContratLigne extends CommonObject $result=''; $label=$langs->trans("ShowContractOfService").': '.$this->label; - $lien = ''; + $lien = ''; $lienfin=''; $picto='contract'; diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 89d05b92b79..ed5e731d896 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -60,8 +60,7 @@ class box_actions extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastActionsToDo",$max)); - if ($user->rights->agenda->myactions->read) - { + if ($user->rights->agenda->myactions->read) { $sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage,"; $sql.= " ta.code, ta.libelle as type_label,"; $sql.= " s.nom as name, s.rowid as socid"; @@ -80,15 +79,13 @@ class box_actions extends ModeleBoxes dol_syslog("Box_actions::loadBox", LOG_DEBUG); $result = $db->query($sql); - if ($result) - { + if ($result) { $now=dol_now(); $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; $num = $db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $late = ''; $objp = $db->fetch_object($result); $datelimite=$db->jdate($objp->dp); @@ -98,48 +95,68 @@ class box_actions extends ModeleBoxes //($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label) $label=empty($objp->label)?$objp->type_label:$objp->label; - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => ("action"), - 'url' => DOL_URL_ROOT."/comm/action/card.php?id=".$objp->id); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'logo' => ("action"), + 'tooltip' => $langs->trans('Action'.$objp->code).': '.$label, + 'url' => DOL_URL_ROOT."/comm/action/card.php?id=".$objp->id, + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => dol_trunc($label,32), - 'text2'=> $late, - 'url' => DOL_URL_ROOT."/comm/action/card.php?id=".$objp->id); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => dol_trunc($label,32), + 'text2'=> $late, + 'tooltip' => $langs->trans('Action'.$objp->code).': '.$label, + 'url' => DOL_URL_ROOT."/comm/action/card.php?id=".$objp->id, + ); - $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', - 'logo' => ($objp->socid?'company':''), - 'url' => ($objp->socid?DOL_URL_ROOT."/societe/soc.php?socid=".$objp->socid:'')); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="left" width="16"', + 'logo' => ($objp->socid?'company':''), + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => ($objp->socid?DOL_URL_ROOT."/societe/soc.php?socid=".$objp->socid:''), + ); - $this->info_box_contents[$i][3] = array('td' => 'align="left"', - 'text' => dol_trunc($objp->name,24), - 'url' => DOL_URL_ROOT."/societe/soc.php?socid=".$objp->socid); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="left"', + 'text' => dol_trunc($objp->name,24), + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => DOL_URL_ROOT."/societe/soc.php?socid=".$objp->socid, + ); - $this->info_box_contents[$i][4] = array('td' => 'align="left" class="nowrap"', - 'text' => dol_print_date($datelimite, "dayhour")); + $this->info_box_contents[$i][4] = array( + 'td' => 'align="left" class="nowrap"', + 'text' => dol_print_date($datelimite, "dayhour"), + ); - $this->info_box_contents[$i][5] = array('td' => 'align="right"', - 'text' => ($objp->percentage>= 0?$objp->percentage.'%':'')); + $this->info_box_contents[$i][5] = array( + 'td' => 'align="right"', + 'text' => ($objp->percentage>= 0?$objp->percentage.'%':''), + ); - $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"', - 'text' => $actionstatic->LibStatut($objp->percentage,3)); + $this->info_box_contents[$i][6] = array( + 'td' => 'align="right" width="18"', + 'text' => $actionstatic->LibStatut($objp->percentage,3), + ); - $i++; - } + $i++; + } if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoActionsToDo")); $db->free($result); - } - else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql)); - } - } - else { - $this->info_box_contents[0][0] = array('align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'align' => 'left', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); } } diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index d118bc8a4bc..9eaeb1d8cb4 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -1,6 +1,7 @@ - * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2014 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +18,9 @@ */ /** - * \file htdocs/core/boxes/box_activity.php - * \ingroup societes - * \brief Module to show box of bills, orders & propal of the current year + * \file htdocs/core/boxes/box_activity.php + * \ingroup societes + * \brief Module to show box of bills, orders & propal of the current year */ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; @@ -29,275 +30,416 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_activity extends ModeleBoxes { - var $boxcode="activity"; - var $boximg="object_bill"; - var $boxlabel='BoxGlobalActivity'; - var $depends = array("facture"); + var $boxcode="activity"; + var $boximg="object_bill"; + var $boxlabel='BoxGlobalActivity'; + var $depends = array("facture"); - var $db; - var $param; - var $enabled = 1; + var $db; + var $param; + var $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + var $info_box_head = array(); + var $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - function __construct($db,$param) - { - global $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $conf; - $this->db=$db; - // FIXME: Use a cache to save data because this slow down too much main home page. This box slow down too seriously software. - // FIXME: Removed number_format (not compatible with all languages) - // FIXME: Pb into some status - $this->enabled=$conf->global->MAIN_FEATURES_LEVEL; // Not enabled by default due to bugs (see previous comments) - } + $this->db=$db; + // FIXME: Pb into some status + $this->enabled=$conf->global->MAIN_FEATURES_LEVEL; // Not enabled by default due to bugs (see previous comments) + } - /** - * Charge les donnees en memoire pour affichage ulterieur - * - * @param int $max Maximum number of records to load - * @return void - */ - function loadBox($max=5) - { - global $conf, $user, $langs, $db; + /** + * Charge les donnees en memoire pour affichage ulterieur + * + * @param int $max Maximum number of records to load + * @return void + */ + function loadBox($max=5) + { + global $conf, $user, $langs, $db; - $totalMnt = 0; - $totalnb = 0; - $i = 0; + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + $totalMnt = 0; + $totalnb = 0; + $i = 0; + $cachetime = 3600; + $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache'; + $now = dol_now(); + $nbofyears=2; - $nbofyears=2; - if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofyears=$conf->global->MAIN_BOX_ACTIVITY_DURATION; - $textHead = $langs->trans("Activity").' ('.$nbofyears.' '.$langs->trans("DurationYears").')'; - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofyears=$conf->global->MAIN_BOX_ACTIVITY_DURATION; + $textHead = $langs->trans("Activity").' '.$nbofyears.' '.$langs->trans("DurationYears").''; + $this->info_box_head = array( + 'text' => $textHead, + 'limit'=> dol_strlen($textHead), + ); - // compute the year limit to show - $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofyears, "y"); + // compute the year limit to show + $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofyears, "y"); - // list the summary of the bills - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) - { - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $facturestatic=new Facture($db); + // list the summary of the bills + if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $facturestatic=new Facture($db); - $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE f.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; + $cachefile = DOL_DATA_ROOT.'/facture/temp/boxactivity-invoice'.$fileid; + $refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile); + $data = array(); + if ($refresh) { + $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; + $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= ")"; + $sql.= " WHERE f.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + $sql.= " AND f.fk_soc = s.rowid"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; + $sql.= " GROUP BY f.fk_statut"; + $sql.= " ORDER BY f.fk_statut DESC"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - while ($i < $num) - { - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill'); - $objp = $db->fetch_object($result); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + file_put_contents($cachefile,serialize($data),LOCK_EX); + $db->free($result); + } else { + dol_print_error($db); + } + } else { + $data = unserialize(file_get_contents($cachefile)); + } + if (! empty($data)) { + $j=0; + while ($i < count($data)) { + $billurl="viewstatut=2&paye=1&year=".$data[$j]->annee; + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'logo' => 'bill', + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1,$objp->fk_statut,0)." ".$objp->annee); - $billurl="viewstatut=2&paye=1&year=".$objp->annee; + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1,$data[$j]->fk_statut,0)." ".$data[$j]->annee, + ); - $this->info_box_contents[$i][2] = array('td' => 'align="right"', - 'text' => $objp->nb, 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills" - ); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="right"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), + 'text' => $data[$j]->nb, + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + ); - $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => price($objp->Mnttot,1,$langs,0,0,-1,$conf->currency) - ); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency) + ); - // We add only for the current year - if ($objp->annee == date("Y")) - { - $totalnb += $objp->nb; - $totalMnt += $objp->Mnttot; - } - $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1,$objp->fk_statut,3) ); - $i++; - } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices")); + // We add only for the current year + if ($data[$j]->annee == date("Y")) { + $totalnb += $data[$j]->nb; + $totalMnt += $data[$j]->Mnttot; + } + $this->info_box_contents[$i][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3), + ); + $i++; + $j++; + } + if (count($data)==0) + $this->info_box_contents[$i][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); + } - $db->free($result); - } - else dol_print_error($db); + $cachefile = DOL_DATA_ROOT.'/facture/temp/boxactivity-invoice2'.$fileid; + $refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile); - $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND paye=0"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; + if ($refresh) { + $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " AND f.fk_soc = s.rowid"; + $sql.= " AND paye=0"; + $sql.= " GROUP BY f.fk_statut"; + $sql.= " ORDER BY f.fk_statut DESC"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result) + $i; - $now=dol_now(); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result) + $i; + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + file_put_contents($cachefile,serialize($data),LOCK_EX); + $db->free($result); + } else { + dol_print_error($db); + } + } else { + $data = unserialize(file_get_contents($cachefile)); + } + if (! empty($data)) { + $j=0; - while ($i < $num) - { - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => 'bill'); - $objp = $db->fetch_object($result); + while ($i < count($data)) { + $billurl="viewstatut=".$data[$j]->fk_statut."&paye=0"; + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'logo' => 'bill', + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(0,$objp->fk_statut,0)); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), + ); - $billurl="viewstatut=".$objp->fk_statut."&paye=0"; - $this->info_box_contents[$i][2] = array('td' => 'align="right"', - 'text' => $objp->nb, 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills" - ); - $totalnb += $objp->nb; - $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => price($objp->Mnttot,1,$langs,0,0,-1,$conf->currency) - ); - $totalMnt += $objp->Mnttot; - $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut(0,$objp->fk_statut,3) - ); - $i++; - } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices")); - } else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql)); - } - } + $this->info_box_contents[$i][2] = array( + 'td' => 'align="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + ); + $totalnb += $data[$j]->nb; + $this->info_box_contents[$i][3] = array( + 'td' => 'align="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), + ); + $totalMnt += $objp->Mnttot; + $this->info_box_contents[$i][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3), + ); + $i++; + $j++; + } + if ($num==0) + $this->info_box_contents[$i][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), + ); + } + } - // list the summary of the orders - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) - { - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $commandestatic=new Commande($db); + // list the summary of the orders + if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $commandestatic=new Commande($db); - $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE c.entity = ".$conf->entity; - $sql.= " AND c.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " AND c.date_commande >= '".$db->idate($tmpdate)."'"; - $sql.= " AND c.facture=0"; - $sql.= " GROUP BY c.fk_statut"; - $sql.= " ORDER BY c.fk_statut DESC"; + $cachefile = DOL_DATA_ROOT.'/commande/temp/boxactivity-order'.$fileid; + $refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile); + $data = array(); + if ($refresh) { - $result = $db->query($sql); + $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; + $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= ")"; + $sql.= " WHERE c.entity = ".$conf->entity; + $sql.= " AND c.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + $sql.= " AND c.date_commande >= '".$db->idate($tmpdate)."'"; + $sql.= " AND c.facture=0"; + $sql.= " GROUP BY c.fk_statut"; + $sql.= " ORDER BY c.fk_statut DESC"; - if ($result) - { - $num = $db->num_rows($result) + $i; - while ($i < $num) - { - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"','logo' => 'object_order'); + $result = $db->query($sql); - $objp = $db->fetch_object($result); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' =>$langs->trans("Orders")." ".$commandestatic->LibStatut($objp->fk_statut,0,0) - ); + if ($result) { + $num = $db->num_rows($result) + $i; + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + file_put_contents($cachefile,serialize($data),LOCK_EX); + $db->free($result); + } else { + dol_print_error($db); + } + } else { + $data = unserialize(file_get_contents($cachefile)); + } + if (! empty($data)) { + $j=0; + while ($i < count($data)) { + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$data[$j]->fk_statut, + 'tooltip' => $langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut,0,0), + 'logo' => 'object_order', + ); - $this->info_box_contents[$i][2] = array('td' => 'align="right"', - 'text' => $objp->nb, - 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$objp->fk_statut - ); - $totalnb += $objp->nb; + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' =>$langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut,0,0), + ); - $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => price($objp->Mnttot,1,$langs,0,0,-1,$conf->currency) - ); - $totalMnt += $objp->Mnttot; - $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut,0,3)); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut,0,0), + 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$data[$j]->fk_statut, + ); + $totalnb += $data[$j]->nb; - $i++; - } - } - else dol_print_error($db); - } + $this->info_box_contents[$i][3] = array( + 'td' => 'align="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), + ); + $totalMnt += $data[$j]->Mnttot; + $this->info_box_contents[$i][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $commandestatic->LibStatut($data[$j]->fk_statut,0,3), + ); - // list the summary of the propals - if (! empty($conf->propal->enabled) && $user->rights->propal->lire) - { - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propalstatic=new Propal($db); + $i++; + $j++; + } + } + } - $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE p.entity = ".$conf->entity; - $sql.= " AND p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " AND p.datep >= '".$db->idate($tmpdate)."'"; - $sql.= " AND p.date_cloture IS NULL"; // just unclosed - $sql.= " GROUP BY p.fk_statut"; - $sql.= " ORDER BY p.fk_statut DESC"; + // list the summary of the propals + if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $propalstatic=new Propal($db); - $result = $db->query($sql); + $cachefile = DOL_DATA_ROOT.'/propale/temp/boxactivity-propal'.$fileid; + $refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile); + $data = array(); + if ($refresh) { + $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; + $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= ")"; + $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " AND p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + $sql.= " AND p.datep >= '".$db->idate($tmpdate)."'"; + $sql.= " AND p.date_cloture IS NULL"; // just unclosed + $sql.= " GROUP BY p.fk_statut"; + $sql.= " ORDER BY p.fk_statut DESC"; - if ($result) - { - $num = $db->num_rows($result) + $i; - while ($i < $num) - { - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"','logo' => 'object_propal'); + $result = $db->query($sql); - $objp = $db->fetch_object($result); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' =>$langs->trans("Proposals")." ".$propalstatic->LibStatut($objp->fk_statut,0) - ); + if ($result) { + $num = $db->num_rows($result) + $i; + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + file_put_contents($cachefile,serialize($data),LOCK_EX); + $db->free($result); + } else { + dol_print_error($db); + } + } else { + $data = unserialize(file_get_contents($cachefile)); + } + if (! empty($data)) { + $j=0; + while ($i < count($data)) { + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, + 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), + 'logo' => 'object_propal' + ); - $this->info_box_contents[$i][2] = array('td' => 'align="right"', - 'text' => $objp->nb, - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$objp->fk_statut - ); - $totalnb += $objp->nb; + $objp = $db->fetch_object($result); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), + ); - $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => price($objp->Mnttot,1,$langs,0,0,-1,$conf->currency) - ); - $totalMnt += $objp->Mnttot; - $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut,3)); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, + ); + $totalnb += $data[$j]->nb; - $i++; - } - } - else dol_print_error($db); - } + $this->info_box_contents[$i][3] = array( + 'td' => 'align="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), + ); + $totalMnt += $data[$j]->Mnttot; + $this->info_box_contents[$i][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3), + ); - // Add the sum in the bottom of the boxes - $this->info_box_contents[$i][1] = array('td' => 'align="left" ', 'text' => $langs->trans("Total")." ".$textHead); - $this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => $totalnb); - $this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => price($totalMnt,1,$langs,0,0,-1,$conf->currency)); - $this->info_box_contents[$i][4] = array('td' => 'align="right" ', 'text' => ""); - $this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => ""); - } + $i++; + $j++; + } + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @return void - */ - function showBox($head = null, $contents = null) - { - parent::showBox($this->info_box_head, $this->info_box_contents); - } + // Add the sum in the bottom of the boxes + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left" ', + 'text' => $langs->trans("Total")." ".$textHead, + ); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="right" ', + 'text' => $totalnb, + ); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="right" ', + 'text' => price($totalMnt,1,$langs,0,0,-1,$conf->currency) + ); + $this->info_box_contents[$i][4] = array( + 'td' => 'align="right" ', + 'text' => "", + ); + $this->info_box_contents[$i][5] = array( + 'td' => 'align="right"', + 'text' => "", + ); + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @return void + */ + function showBox($head = null, $contents = null) + { + parent::showBox($this->info_box_head, $this->info_box_contents); + } } diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 968eefef4b9..5250108f76c 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -52,10 +52,11 @@ class box_bookmarks extends ModeleBoxes $this->max=$max; - $this->info_box_head = array('text' => $langs->trans("BoxMyLastBookmarks",$max), - 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php'); - if ($user->rights->bookmark->creer) - { + $this->info_box_head = array( + 'text' => $langs->trans("BoxMyLastBookmarks",$max), + 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', + ); + if ($user->rights->bookmark->creer) { $this->info_box_head['subpicto']='object_bookmark'; $this->info_box_head['subtext']=$langs->trans("BookmarksManagement"); } @@ -81,43 +82,52 @@ class box_bookmarks extends ModeleBoxes $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); + while ($i < $num) { + $objp = $db->fetch_object($result); - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => $objp->url, - 'target' => $objp->target?'newtab':''); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => $objp->title, - 'url' => $objp->url, - 'target' => $objp->target?'newtab':''); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target?'newtab':'', + ); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => $objp->title, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target?'newtab':'', + ); - $i++; - } + $i++; + } - if ($num==0) - { - $mytxt=$langs->trans("NoRecordedBookmarks"); - if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickToAdd"); - $this->info_box_contents[$i][0] = array('td' => 'align="center" colspan="2"', 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt); - } + if ($num==0) { + $mytxt=$langs->trans("NoRecordedBookmarks"); + if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickToAdd"); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="center" colspan="2"', + 'tooltip' => $mytxt, + 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, + ); + } - $db->free($result); - } - else - { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql)); - } - } - else { - $this->info_box_contents[0][0] = array('align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed")); - } - } + $db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'align' => 'left', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); + } + } /** * Method to show box diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 4e651e8bdcc..01e0dc92635 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -104,19 +104,28 @@ class box_clients extends ModeleBoxes $datec=$db->jdate($objp->datec); $datem=$db->jdate($objp->tms); - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => $url.$objp->socid); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => $url.$objp->socid + ); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => $objp->name, + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => $url.$objp->socid + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => $objp->name, - 'url' => $url.$objp->socid); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="right"', + 'text' => dol_print_date($datem, "day") + ); - $this->info_box_contents[$i][2] = array('td' => 'align="right"', - 'text' => dol_print_date($datem, "day")); - - $this->info_box_contents[$i][3] = array('td' => 'align="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status,3)); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status,3) + ); $i++; } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 1bb6fe9b27a..670a5358d20 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -80,70 +80,85 @@ class box_commandes extends ModeleBoxes $sql.= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($result); $date=$db->jdate($objp->date_commande); - $datem=$db->jdate($objp->tms); + $datem=$db->jdate($objp->tms); - $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid); - - $this->info_box_contents[$i][] = array('td' => 'align="left"', - 'text' => $objp->ref, - 'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid); - - $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"', - 'logo' => 'company', - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); - - $this->info_box_contents[$i][] = array('td' => 'align="left"', - 'text' => $objp->name, - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); - - $this->info_box_contents[$i][] = array('td' => 'align="right"', - 'text' => price($objp->total_ht), - ); - - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) - { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$i][] = array('td' => 'align="right"', - 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), - 'url' => (($objp->fk_user_valid > 0)?DOL_URL_ROOT.'/user/card.php?id='.$objp->fk_user_valid:'') - ); - } - - $this->info_box_contents[$i][] = array('td' => 'align="right"', - 'text' => dol_print_date($date,'day'), + $this->info_box_contents[$i][] = array( + 'td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'tooltip' => $langs->trans('Order').': '.$objp->ref, + 'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid, ); - $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', - 'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3)); + $this->info_box_contents[$i][] = array( + 'td' => 'align="left"', + 'text' => $objp->ref, + 'tooltip' => $langs->trans('Order').': '.$objp->ref, + 'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid, + ); + $this->info_box_contents[$i][] = array( + 'td' => 'align="left" width="16"', + 'logo' => 'company', + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'align="left"', + 'text' => $objp->name, + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'align="right"', + 'text' => price($objp->total_ht), + ); + + if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$i][] = array( + 'td' => 'align="right"', + 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'url' => (($objp->fk_user_valid > 0)?DOL_URL_ROOT.'/user/card.php?id='.$objp->fk_user_valid:''), + ); + } + + $this->info_box_contents[$i][] = array( + 'td' => 'align="right"', + 'text' => dol_print_date($date,'day'), + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'align="right" width="18"', + 'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3), + ); $i++; } if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedOrders")); - $db->free($result); + $db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); } - else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql)); - } - } - else { - $this->info_box_contents[0][0] = array('align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + } else { + $this->info_box_contents[0][0] = array( + 'align' => 'left', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); } } diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 45c8f1a4819..5340b06f0dd 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Christophe * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2013 Juanjo Menent * * 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 @@ -76,8 +76,7 @@ class box_comptes extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); - if ($user->rights->banque->lire) - { + if ($user->rights->banque->lire) { $sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,"; $sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix as iban,"; $sql.= " domiciliation, proprio, owner_address,"; @@ -90,76 +89,87 @@ class box_comptes extends ModeleBoxes $sql.= " ORDER BY label"; $sql.= $db->plimit($max, 0); - dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); - $i = 0; - $solde_total = 0; + $i = 0; + $solde_total = array(); - $listofcurrencies=array(); - $account_static = new Account($db); - while ($i < $num) - { - $objp = $db->fetch_object($result); + $account_static = new Account($db); + while ($i < $num) { + $objp = $db->fetch_object($result); - $account_static->id = $objp->rowid; - $solde=$account_static->solde(0); + $account_static->id = $objp->rowid; + $solde=$account_static->solde(0); - $solde_total += $solde; + $solde_total[$objp->currency_code] += $solde; - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'tooltip' => $langs->trans('Account').': '.$objp->label, + 'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid, + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => $objp->label, - 'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => $objp->label, + 'tooltip' => $langs->trans('Account').': '.$objp->label, + 'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid, + ); - $this->info_box_contents[$i][2] = array('td' => 'align="left"', - 'text' => $objp->number - ); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="left"', + 'text' => $objp->number, + ); - $this->info_box_contents[$i][3] = array('td' => 'align="right"', - 'text' => price($solde, 0, $langs, 0, 0, -1, $objp->currency_code) - ); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="right"', + 'text' => price($solde, 0, $langs, 0, 0, -1, $objp->currency_code) + ); - $listofcurrencies[$objp->currency_code]=1; - $i++; - } + $i++; + } - // Total - if (count($listofcurrencies) <= 1) - { - $this->info_box_contents[$i][0] = array('tr' => 'class="liste_total"', 'td' => 'align="right" class="liste_total"', - 'text' => $langs->trans('Total') - ); - $this->info_box_contents[$i][1] = array('td' => 'align="right" class="liste_total"', - 'text' => ' ' - ); - $this->info_box_contents[$i][2] = array('td' => 'align="right" class="liste_total"', - 'text' => ' ' - ); - $totalamount=price($solde_total,0,$langs,0,0,-1,$conf->currency); - $this->info_box_contents[$i][3] = array('td' => 'align="right" class="liste_total"', - 'text' => $totalamount - ); - } + // Total + foreach ($solde_total as $key=>$solde) { + $this->info_box_contents[$i][0] = array( + 'tr' => 'class="liste_total"', + 'td' => 'align="right" class="liste_total"', + 'text' => ' ', + ); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left" class="liste_total"', + 'text' => $langs->trans('Total').' '.$key, + ); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="right" class="liste_total"', + 'text' => ' ' + ); + $totalamount=price($solde,0,$langs,0,0,-1,$key); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="right" class="liste_total"', + 'text' => $totalamount + ); + $i++; + } - $db->free($result); - } - else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql)); - } - } - else { - $this->info_box_contents[0][0] = array('td' => 'align="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed")); - } + $db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); + } } diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index e10c9ae7ed9..8ec8bf77b9c 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -73,65 +73,83 @@ class box_contacts extends ModeleBoxes $sql.= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $contactstatic=new Contact($db); $societestatic=new Societe($db); $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($result); $datec=$db->jdate($objp->datec); $datem=$db->jdate($objp->tms); - $contactstatic->lastname=$objp->lastname; + $contactstatic->lastname=$objp->lastname; $contactstatic->firstname=$objp->firstname; $contactstatic->civility_id=$objp->civility_id; $societestatic->id=$objp->fk_soc; $societestatic->name=$objp->socname; - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/contact/card.php?id=".$objp->rowid); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'tooltip' => $langs->trans('Contact').': '.$contactstatic->getFullName($langs,0), + 'url' => DOL_URL_ROOT."/contact/card.php?id=".$objp->rowid, + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => $contactstatic->getFullName($langs,0), - 'url' => DOL_URL_ROOT."/contact/card.php?id=".$objp->rowid); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => $contactstatic->getFullName($langs,0), + 'tooltip' => $langs->trans('Contact').': '.$contactstatic->getFullName($langs,0), + 'url' => DOL_URL_ROOT."/contact/card.php?id=".$objp->rowid, + ); - $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', - 'logo' => ($objp->fk_soc > 0?'company':''), - 'url' => ($objp->fk_soc > 0?DOL_URL_ROOT."/societe/soc.php?socid=".$objp->fk_soc:'')); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="left" width="16"', + 'logo' => ($objp->fk_soc > 0?'company':''), + 'tooltip' => $societestatic->name, + 'url' => ($objp->fk_soc > 0?DOL_URL_ROOT."/societe/soc.php?socid=".$objp->fk_soc:''), + ); - $this->info_box_contents[$i][3] = array('td' => 'align="left"', - 'text' => $societestatic->name, - 'url' => DOL_URL_ROOT."/societe/soc.php?socid=".$objp->fk_soc); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="left"', + 'text' => $societestatic->name, + 'tooltip' => $societestatic->name, + 'url' => DOL_URL_ROOT."/societe/soc.php?socid=".$objp->fk_soc, + ); - $this->info_box_contents[$i][4] = array('td' => 'align="right"', - 'text' => dol_print_date($datem, "day")); + $this->info_box_contents[$i][4] = array( + 'td' => 'align="right"', + 'text' => dol_print_date($datem, "day"), + ); - $i++; - } + $i++; + } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedContacts")); + if ($num==0) + $this->info_box_contents[$i][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedContacts"), + ); - $db->free($result); - } - else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql)); - } - } - else { - $this->info_box_contents[0][0] = array('align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed")); - } + $db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'align' => 'left', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); + } - } + } /** * Method to show box diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index dc0ff8e5382..c980be624da 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -79,8 +79,7 @@ class box_contracts extends ModeleBoxes $i = 0; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); $datec=$db->jdate($objp->datec); $dateterm=$db->jdate($objp->fin_validite); @@ -94,50 +93,69 @@ class box_contracts extends ModeleBoxes // fin_validite is no more on contract but on services // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'tooltip' => $langs->trans('Contract').': '.($objp->ref?$objp->ref:$objp->rowid), + 'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid, + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => ($objp->ref?$objp->ref:$objp->rowid), // Some contracts have no ref - 'text2'=> $late, - 'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => ($objp->ref?$objp->ref:$objp->rowid), // Some contracts have no ref + 'tooltip' => $langs->trans('Contract').': '.($objp->ref?$objp->ref:$objp->rowid), + 'text2'=> $late, + 'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid, + ); - $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', - 'logo' => 'company', - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="left" width="16"', + 'logo' => 'company', + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, + ); - $this->info_box_contents[$i][3] = array('td' => 'align="left"', - 'text' => dol_trunc($objp->name,40), - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="left"', + 'text' => dol_trunc($objp->name,40), + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, + ); - $this->info_box_contents[$i][4] = array('td' => 'align="right"', - 'text' => dol_print_date($datec,'day')); + $this->info_box_contents[$i][4] = array( + 'td' => 'align="right"', + 'text' => dol_print_date($datec,'day'), + ); - $this->info_box_contents[$i][5] = array('td' => 'align="right" class="nowrap"', - 'text' => $contractstatic->getLibStatut(6), - 'asis'=>1 - ); + $this->info_box_contents[$i][5] = array( + 'td' => 'align="right" class="nowrap"', + 'text' => $contractstatic->getLibStatut(6), + 'asis'=>1, + ); - $i++; - } + $i++; + } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedContracts")); + if ($num==0) + $this->info_box_contents[$i][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedContracts"), + ); - $db->free($resql); - } - else - { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql)); - } - } - else - { - $this->info_box_contents[0][0] = array('td' => 'align="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed")); - } + $db->free($resql); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); + } } /** diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 354e79151f1..689efc751c6 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -98,8 +98,12 @@ class box_external_rss extends ModeleBoxes } else { - $this->info_box_head = array('text' => $title, - 'sublink' => $link, 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(),"dayhourtext"):$langs->trans("Unknown")), 'subpicto'=>'object_bookmark'); + $this->info_box_head = array( + 'text' => $title, + 'sublink' => $link, + 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(),"dayhourtext"):$langs->trans("Unknown")), + 'subpicto'=>'object_bookmark', + ); } // INFO on items @@ -112,8 +116,8 @@ class box_external_rss extends ModeleBoxes // Feed common fields $href = $item['link']; $title = urldecode($item['title']); - $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed - if ($rssparser->getFormat() == 'rss') // If RSS + $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed + if ($rssparser->getFormat() == 'rss') // If RSS { if (! $date && isset($item['pubdate'])) $date=$item['pubdate']; if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date']; @@ -138,19 +142,27 @@ class box_external_rss extends ModeleBoxes $title=preg_replace("/^\s+/","",$title); // Supprime espaces de debut $this->info_box_contents["$href"]="$title"; - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => $href, - 'target' => 'newrss'); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'url' => $href, + 'tooltip' => $title, + 'target' => 'newrss', + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => $title, - 'url' => $href, - 'maxlength' => 64, - 'target' => 'newrss'); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => $title, + 'url' => $href, + 'tooltip' => $title, + 'maxlength' => 64, + 'target' => 'newrss', + ); - $this->info_box_contents[$i][2] = array('td' => 'align="right" nowrap="1"', - 'text' => $date); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="right" nowrap="1"', + 'text' => $date, + ); } } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index b0fdd6d9d09..84f7e61b315 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -101,55 +101,76 @@ class box_factures extends ModeleBoxes $late = ''; if ($objp->paye == 0 && ($objp->fk_statut != 2 && $objp->fk_statut != 3) && $datelimite < ($now - $conf->facture->client->warning_delay)) { $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));} - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $picto, - 'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'logo' => $picto, + 'tooltip' => $langs->trans('CustomerInvoice').': '.$objp->facnumber, + 'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid, + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => $objp->facnumber, - 'text2'=> $late, - 'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => $objp->facnumber, + 'text2'=> $late, + 'tooltip' => $langs->trans('CustomerInvoice').': '.$objp->facnumber, + 'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid, + ); - $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', - 'logo' => 'company', - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="left" width="16"', + 'logo' => 'company', + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, + ); - $this->info_box_contents[$i][3] = array('td' => 'align="left"', - 'text' => $objp->name, - 'maxlength'=>40, - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="left"', + 'text' => $objp->name, + 'maxlength'=>40, + 'tooltip' => $langs->trans('Customer').': '.$objp->name, + 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, + ); - $this->info_box_contents[$i][4] = array('td' => 'align="right"', - 'text' => price($objp->total_ht), - ); + $this->info_box_contents[$i][4] = array( + 'td' => 'align="right"', + 'text' => price($objp->total_ht), + ); - $this->info_box_contents[$i][5] = array('td' => 'align="right"', - 'text' => dol_print_date($date,'day'), - ); + $this->info_box_contents[$i][5] = array( + 'td' => 'align="right"', + 'text' => dol_print_date($date,'day'), + ); - $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3)); + $this->info_box_contents[$i][6] = array( + 'td' => 'align="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3), + ); - $i++; - } + $i++; + } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices")); + if ($num==0) + $this->info_box_contents[$i][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); - $db->free($result); - } - else - { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql)); - } + $db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } - } - else { - $this->info_box_contents[0][0] = array('td' => 'align="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed")); - } - } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); + } + } /** * Method to show box diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 914f442bea4..4e222369949 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/core/boxes/box_factures_fourn.php + * \file htdocs/core/boxes/box_factures_fourn.php * \ingroup supplier - * \brief Fichier de gestion d'une box des factures fournisseurs + * \brief Fichier de gestion d'une box des factures fournisseurs */ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; @@ -89,8 +89,7 @@ class box_factures_fourn extends ModeleBoxes $i = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)'; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($result); $datelimite=$db->jdate($objp->datelimite); $date=$db->jdate($objp->df); @@ -99,54 +98,79 @@ class box_factures_fourn extends ModeleBoxes $late = ''; if ($objp->paye == 0 && $datelimite && $datelimite < ($now - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); - $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', - 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid); + $this->info_box_contents[$i][0] = array( + 'td' => 'align="left" width="16"', + 'logo' => $this->boximg, + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, + 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, + ); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => ($objp->ref?$objp->ref:$objp->facid), - 'text2'=> $late, - 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid); + $this->info_box_contents[$i][1] = array( + 'td' => 'align="left"', + 'text' => ($objp->ref?$objp->ref:$objp->facid), + 'text2'=> $late, + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, + 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, + ); - $this->info_box_contents[$i][2] = array('td' => 'align="left"', - 'text' => $objp->ref_supplier, - 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid); + $this->info_box_contents[$i][2] = array( + 'td' => 'align="left"', + 'text' => $objp->ref_supplier, + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, + 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, + ); - $this->info_box_contents[$i][3] = array('td' => 'align="left" width="16"', - 'logo' => 'company', - 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid); + $this->info_box_contents[$i][3] = array( + 'td' => 'align="left" width="16"', + 'logo' => 'company', + 'tooltip' => $langs->trans('Supplier').': '.$objp->name, + 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid, + ); - $this->info_box_contents[$i][4] = array('td' => 'align="left"', - 'text' => $objp->name, - 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid); + $this->info_box_contents[$i][4] = array( + 'td' => 'align="left"', + 'text' => $objp->name, + 'tooltip' => $langs->trans('Supplier').': '.$objp->name, + 'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid, + ); - $this->info_box_contents[$i][5] = array('td' => 'align="right"', - 'text' => dol_print_date($date,'day')); + $this->info_box_contents[$i][5] = array( + 'td' => 'align="right"', + 'text' => dol_print_date($date,'day'), + ); - $fac = new FactureFournisseur($db); - $fac->fetch($objp->facid); - $alreadypaid=$fac->getSommePaiement(); - $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type)); + $fac = new FactureFournisseur($db); + $fac->fetch($objp->facid); + $alreadypaid=$fac->getSommePaiement(); + $this->info_box_contents[$i][6] = array( + 'td' => 'align="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type), + ); - $i++; - } + $i++; + } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoModifiedSupplierBills")); + if ($num==0) + $this->info_box_contents[$i][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoModifiedSupplierBills"), + ); - $db->free($result); - } - else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left"', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql)); - } - } - else { - $this->info_box_contents[0][0] = array('td' => 'align="left"', - 'text' => $langs->transnoentities("ReadPermissionNotAllowed")); - } - } + $db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left"', + 'text' => $langs->transnoentities("ReadPermissionNotAllowed"), + ); + } + } /** * Method to show box diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index c6b6dad7acb..aed954fea97 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -257,8 +257,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" // Loop on each TD $nbcolthisline=count($contents[$i]); - for ($j=0; $j < $nbcolthisline; $j++) - { + for ($j=0; $j < $nbcolthisline; $j++) { // Define tdparam $tdparam=''; if (isset($contents[$i][$j]['td'])) $tdparam.=' '.$contents[$i][$j]['td']; @@ -270,13 +269,15 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" $text2withnotags=preg_replace('/<([^>]+)>/i','',$text2); $textnoformat=isset($contents[$i][$j]['textnoformat'])?$contents[$i][$j]['textnoformat']:''; //print "xxx $textwithnotags y"; + if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip']=""; + $tooltip=isset($contents[$i][$j]['tooltip'])?$contents[$i][$j]['tooltip']:''; - print ''; + print ''."\n"; // Url - if (! empty($contents[$i][$j]['url'])) + if (! empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) { - print '" print isset($contents[$i][$j]['target'])?' target="'.$contents[$i][$j]['target'].'"':''; print '>'; @@ -286,7 +287,8 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" if (! empty($contents[$i][$j]['logo'])) { $logo=preg_replace("/^object_/i","",$contents[$i][$j]['logo']); - print img_object($langs->trans("Show"),$logo); + print ''; + print img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"'); } $maxlength=$MAXLENGTHBOX; @@ -304,7 +306,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" if (! empty($textnoformat)) print "\n".$textnoformat."\n"; - print "
'; //print ''; print '\n"; // Date - $date=$element->date; - if (empty($date)) $date=$element->datep; - if (empty($date)) $date=$element->date_contrat; - if (empty($date)) $date=$element->datev; //Fiche inter + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') $date=$element->date_commande; + else + { + $date=$element->date; + if (empty($date)) $date=$element->datep; + if (empty($date)) $date=$element->date_contrat; + if (empty($date)) $date=$element->datev; //Fiche inter + } print ''; // Third party print ''; - // Amount + // Amount without tax if (empty($value['disableamount'])) { print ''; - // Amount + // Amount inc tax if (empty($value['disableamount'])) { print '
'.$langs->trans("Filter").':'.$langs->trans("From").' '; From c4782f960c8c662923b64e12cf649e90c303ce10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jan 2015 19:47:53 +0100 Subject: [PATCH 147/152] Qual: Removed not cleand function --- htdocs/contrat/class/contrat.class.php | 41 -------------------------- 1 file changed, 41 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 4d455f79369..9619ae462f4 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2497,45 +2497,4 @@ class ContratLigne extends CommonObject } } - /** - * Load elements linked to contract (only intervention for the moment) - * - * @param string $type Object type - * @return array $elements array of linked elements - */ - function get_element_list($type) - { - $elements = array(); - - $sql = ''; - if ($type == 'intervention') - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "fichinter WHERE fk_contrat=" . $this->id; - if (! $sql) return -1; - - //print $sql; - dol_syslog(get_class($this)."::get_element_list", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $nump = $this->db->num_rows($result); - if ($nump) - { - $i = 0; - while ($i < $nump) - { - $obj = $this->db->fetch_object($result); - $elements[$i] = $obj->rowid; - $i++; - } - $this->db->free($result); - /* Return array */ - return $elements; - } - } - else - { - dol_print_error($this->db); - } - } - } From 7b8b189bacb41b741bd3c246505ae00d6c99099c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jan 2015 20:09:57 +0100 Subject: [PATCH 148/152] Fix: select if field is null --- htdocs/projet/class/project.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d423bc48ae1..1d24076df27 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -416,13 +416,13 @@ class Project extends CommonObject { if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; - $sql.=" AND ".$datefieldname." >= '".$this->db->idate($dates)."'"; + $sql.=" AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } if ($datee > 0) { if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; - $sql.=" AND ".$datefieldname." <= '".$this->db->idate($datee)."'"; + $sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; } if (! $sql) return -1; From 8267cec5a3adc14c0483c40148d8bf141edbeeb6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jan 2015 20:09:57 +0100 Subject: [PATCH 149/152] Fix: select if field is null --- htdocs/projet/class/project.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index c9d4ed9f546..d738256e7d4 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -416,13 +416,13 @@ class Project extends CommonObject { if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; - $sql.=" AND ".$datefieldname." >= '".$this->db->idate($dates)."'"; + $sql.=" AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } if ($datee > 0) { if (empty($datefieldname) && ! empty($this->table_element_date)) $datefieldname=$this->table_element_date; if (empty($datefieldname)) return 'Error this object has no date field defined'; - $sql.=" AND ".$datefieldname." <= '".$this->db->idate($datee)."'"; + $sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; } if (! $sql) return -1; From b7328caa9a5263fc00b8eee7208e7f2fa04fff4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jan 2015 20:40:53 +0100 Subject: [PATCH 150/152] Fixed: Bad date for supplier orders --- htdocs/projet/element.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index df420f159d7..10b540f9e50 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -356,18 +356,22 @@ foreach ($listofreferent as $key => $value) print "'.dol_print_date($date,'day').''; - if (is_object($element->client)) print $element->client->getNomUrl(1,'',48); + if (is_object($element->thirdparty)) print $element->thirdparty->getNomUrl(1,'',48); print ''; @@ -378,7 +382,7 @@ foreach ($listofreferent as $key => $value) } else print ''; From eedca43cc359339174bb3a409a5cbe0aa3721804 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jan 2015 21:31:00 +0100 Subject: [PATCH 151/152] New: Add option PROJECT_ADD_SUBTOTAL_LINES to group by supplier lines into refering project view. --- htdocs/projet/element.php | 119 +++++++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 8 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index e30a5bfffdc..39195ae3de3 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -275,7 +275,7 @@ foreach ($listofreferent as $key => $value) { print ''; print ''; - print ''; + print ''; print ''; //print ''; print '\n"; // Date - $date=$element->date; - if (empty($date)) $date=$element->datep; - if (empty($date)) $date=$element->date_contrat; - if (empty($date)) $date=$element->datev; //Fiche inter + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') $date=$element->date_commande; + else + { + $date=$element->date; + if (empty($date)) $date=$element->datep; + if (empty($date)) $date=$element->date_contrat; + if (empty($date)) $date=$element->datev; //Fiche inter + } print ''; // Third party print ''; - // Amount + // Amount without tax if (empty($value['disableamount'])) { print ''; - // Amount + // Amount inc tax if (empty($value['disableamount'])) { print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $total_ht_by_third = 0; + $total_ttc_by_third = 0; + $var=true; + } } } @@ -533,3 +576,63 @@ print "
'.$langs->trans("Filter").':'.$langs->trans("From").' '; @@ -331,6 +331,15 @@ foreach ($listofreferent as $key => $value) $var=true; $total_ht = 0; $total_ttc = 0; + + $total_ht_by_third = 0; + $total_ttc_by_third = 0; + + if (canApplySubtotalOn($tablename)) { + // Appel du mon code de tri : + $elementarray = sortElementsByClientName($elementarray); + } + $num=count($elementarray); for ($i = 0; $i < $num; $i++) { @@ -356,18 +365,22 @@ foreach ($listofreferent as $key => $value) print "'.dol_print_date($date,'day').''; - if (is_object($element->client)) print $element->client->getNomUrl(1,'',48); + if (is_object($element->thirdparty)) print $element->thirdparty->getNomUrl(1,'',48); print ''; @@ -378,7 +391,7 @@ foreach ($listofreferent as $key => $value) } else print ''; @@ -398,6 +411,36 @@ foreach ($listofreferent as $key => $value) { $total_ht = $total_ht + $element->total_ht; $total_ttc = $total_ttc + $element->total_ttc; + + $total_ht_by_third += $element->total_ht; + $total_ttc_by_third += $element->total_ttc; + } + + // Autre partie de mon code : + if (canApplySubtotalOn($tablename)) + { + $next_third_id = (isset($elementarray[$i+1])) ? $elementarray[$i+1] : ''; + $third_id = $element->thirdparty->id; + if ($third_id != $next_third_id) + { + print '
'; + print ''; + print ''; + print $langs->trans('SubTotal').' : '; + if (is_object($element->thirdparty)) print $element->thirdparty->getNomUrl(0,'',48); + print ''.price($total_ht).''.price($total_ttc).'
"; llxFooter(); $db->close(); + + + +/** + * Return if we should do a group by customer with sub-total + * + * @param string $tablename Name of table + * @return boolean True to tell to make a group by sub-total + */ +function canApplySubtotalOn($tablename) +{ + global $conf; + + if (empty($conf->global->PROJECT_ADD_SUBTOTAL_LINES)) return false; + return in_array($tablename, array('facture_fourn', 'commande_fournisseur')); +} + +/** + * getClientName + * + * @param unknown_type $id + */ +function getClientName($id) { + global $db, $classname; + $element = new $classname($db); + $element->fetch($id); + $element->fetch_thirdparty(); + return $element->thirdparty->name; +} + +/** + * getClientNameArray + * + * @param unknown_type $elementarray + */ +function getClientNameArray($elementarray) { + $clientname = array(); + foreach ($elementarray as $key => $id) { + $clientname[$id] = getClientName($id); + } + return $clientname; +} + +/** + * sortElementsByClientName + * + * @param unknown_type $elementarray + */ +function sortElementsByClientName($elementarray) { + $clientname = getClientNameArray($elementarray); + asort($clientname); + + $elementarray = array(); + foreach ($clientname as $id => $name) { + $elementarray[] = $id; + } + + return $elementarray; +} + From b7cff09ce681fd940fa7deb778da7ed525da1c78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jan 2015 21:46:22 +0100 Subject: [PATCH 152/152] Fixed travis errors --- dev/codesniffer/ruleset.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dev/codesniffer/ruleset.xml b/dev/codesniffer/ruleset.xml index 9cff30f457d..9f20324da3f 100755 --- a/dev/codesniffer/ruleset.xml +++ b/dev/codesniffer/ruleset.xml @@ -213,6 +213,7 @@ 0 + 0 @@ -228,6 +229,23 @@ 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + 0