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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] =?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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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/940] 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 08b9e054251fb8f05de6173ca1f71e90467547b6 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 21 Sep 2014 17:42:38 +0200 Subject: [PATCH 027/940] New Module : Manage Financial Loan --- htdocs/admin/loan.php | 119 ++++ htdocs/compta/loan/card.php | 467 ++++++++++++++ htdocs/compta/loan/class/index.html | 0 htdocs/compta/loan/class/loan.class.php | 477 ++++++++++++++ .../compta/loan/class/paymentloan.class.php | 603 ++++++++++++++++++ htdocs/compta/loan/document.php | 178 ++++++ htdocs/compta/loan/index.html | 0 htdocs/compta/loan/index.php | 208 ++++++ htdocs/compta/loan/info.php | 65 ++ htdocs/core/lib/loan.lib.php | 66 ++ htdocs/core/menus/standard/eldy.lib.php | 19 +- htdocs/core/modules/modLoan.class.php | 173 +++++ htdocs/install/mysql/tables/llx_loan.sql | 47 ++ .../install/mysql/tables/llx_payment_loan.sql | 33 + 14 files changed, 2450 insertions(+), 5 deletions(-) create mode 100644 htdocs/admin/loan.php create mode 100644 htdocs/compta/loan/card.php create mode 100644 htdocs/compta/loan/class/index.html create mode 100644 htdocs/compta/loan/class/loan.class.php create mode 100644 htdocs/compta/loan/class/paymentloan.class.php create mode 100644 htdocs/compta/loan/document.php create mode 100644 htdocs/compta/loan/index.html create mode 100644 htdocs/compta/loan/index.php create mode 100644 htdocs/compta/loan/info.php create mode 100644 htdocs/core/lib/loan.lib.php create mode 100644 htdocs/core/modules/modLoan.class.php create mode 100644 htdocs/install/mysql/tables/llx_loan.sql create mode 100644 htdocs/install/mysql/tables/llx_payment_loan.sql diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php new file mode 100644 index 00000000000..4cd22ef2c8c --- /dev/null +++ b/htdocs/admin/loan.php @@ -0,0 +1,119 @@ + + * + * 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/loan.php + * \ingroup loan + * \brief Setup page to configure loan module + */ + +require '../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +$langs->load("admin"); +$langs->load("loan"); + +// Security check +if (!$user->admin) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); + +// Other parameters LOAN_* +$list = array ( + 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', + 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', + 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' +); + +/* + * Actions + */ + +if ($action == 'update') +{ + $error = 0; + + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); + + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans('ConfigLoan'),$linkback,'setup'); + +print '
'; +print ''; +print ''; + +/* + * Params + */ +print ''; +print ''; +print ''; +print "\n"; + +foreach ($list as $key) +{ + $var=!$var; + + print ''; + + // Param + $label = $langs->trans($key); + print ''; + + // Value + print ''; +} + +print ''; + +print ''; +print "
' . $langs->trans('Options') . '
'; + print ''; + print '
\n"; + +print '
'; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php new file mode 100644 index 00000000000..f8cf4d29327 --- /dev/null +++ b/htdocs/compta/loan/card.php @@ -0,0 +1,467 @@ + + * + * 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/compta/loan/card.php + * \ingroup loan + * \brief Loan card + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; + +$langs->load("compta"); +$langs->load("bills"); +$langs->load("loan"); + +$id=GETPOST('id','int'); +$action=GETPOST("action"); +$confirm=GETPOST('confirm'); + +// Security check +$socid = GETPOST('socid','int'); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'loan', $id, '',''); + +/* + * Actions + */ + +// Classify paid +if ($action == 'confirm_paid' && $confirm == 'yes') +{ + $loan = new Loan($db); + $loan->fetch($id); + $result = $loan->set_paid($user); +} + +// Delete loan +if ($action == 'confirm_delete' && $confirm == 'yes') +{ + $loan = new Loan($db); + $loan->fetch($id); + $result=$loan->delete($user); + if ($result > 0) + { + header("Location: index.php"); + exit; + } + else + { + setEventMessage($loan->error, 'errors'); + } +} + + +// Add loan +if ($action == 'add' && $user->rights->loan->write) +{ + $dateech=@dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]); + $dateperiod=@dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]); + if (! $dateech) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors'); + $action = 'create'; + } + elseif (! $dateperiod) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors'); + $action = 'create'; + } + elseif (! $_POST["capital"]) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Capital")), 'errors'); + $action = 'create'; + } + else + { + $loan = new Loan($db); + + $loan->label = $_POST["label"]; + $loan->date_ech = $dateech; + $loan->periode = $dateperiod; + $loan->capital = $_POST["capital"]; + + $id=$loan->create($user); + if ($id <= 0) + { + setEventMessage($loan->error, 'errors'); + } + } +} + + +if ($action == 'update' && ! $_POST["cancel"] && $user->rights->loan->write) +{ + $dateech=dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]); + $dateperiod=dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]); + if (! $dateech) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors'); + $action = 'edit'; + } + elseif (! $dateperiod) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors'); + $action = 'edit'; + } + else + { + $loan = new Loan($db); + $result=$loan->fetch($_GET["id"]); + + $loan->lib=$_POST["label"]; + $loan->date_ech=$dateech; + $loan->periode=$dateperiod; + + $result=$loan->update($user); + if ($result <= 0) + { + setEventMessage($loan->error, 'errors'); + } + } +} + + + +/* + * View + */ + +$form = new Form($db); + +$help_url='EN:Module_Loan|FR:Module Emprunt'; +llxHeader("",$langs->trans("Loan"),$help_url); + + +// Create mode +if ($action == 'create') +{ + //WYSIWYG Editor + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + + print_fiche_titre($langs->trans("NewLoan")); + + $datec = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); + + print '
' . "\n"; + print ''; + print ''; + + print ''; + + // Label + print ''; + + // Bank account + if (! empty($conf->banque->enabled)) + { + print ''; + } + else + { + print ''; + } + + // Capital + print ''; + + // Date Start + print ""; + print ''; + + // Date End + print ""; + print ''; + + // Number of terms + print ''; + + // Rate + print ''; + + // Note + print ''; + print ''; + print ''; + print '
'.$langs->trans("Label").'
'.$langs->trans("Account").''; + $form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Show list of bank account with courant + print '
'.$langs->trans("Account").''; + print $langs->trans("NoBankAccountDefined"); + print '
'.$langs->trans("Capital").'
'.$langs->trans("DateStart").''; + print $form->select_date($datestart?$datestart:-1,'','','','','add',1,1); + print '
'.$langs->trans("DateEnd").''; + print $form->select_date($dateend?$dateend:-1,'','','','','add',1,1); + print '
'.$langs->trans("Nbterms").'
'.$langs->trans("Rate").'
'.$langs->trans('Note').''; + + $doleditor = new DolEditor('note', GETPOST('note', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, 100); + print $doleditor->Create(1); + + print '
'; + + print '
'; + + // Accountancy + print ''; + + if ($conf->accounting->enabled) + { + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + } + else + { + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + } + + print '
'.$langs->trans("LoanAccountancyCapitalCode").''; + print '
'.$langs->trans("LoanAccountancyInsuranceCode").''; + print '
'.$langs->trans("LoanAccountancyInterestCode").''; + print '
'.$langs->trans("LoanAccountancyCapitalCode").''; + print '
'.$langs->trans("LoanAccountancyInsuranceCode").''; + print '
'.$langs->trans("LoanAccountancyInterestCode").''; + print '
'; + + print '
    '; + print ''; +} + +// View +if ($id > 0) +{ + $object = new Loan($db); + $result=$object->fetch($id); + + if ($result > 0) + { + $head=loan_prepare_head($object); + + dol_fiche_head($head, 'card', $langs->trans("Loan"),0,'bill'); + + // Confirm for loan + if ($action == 'paid') + { + $text=$langs->trans('ConfirmPayLoan'); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans('PayLoan'),$text,"confirm_paid",'','',2); + } + + if ($action == 'delete') + { + $text=$langs->trans('ConfirmDeleteLoan'); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('DeleteLoan'),$text,'confirm_delete','','',2); + } + + if ($action == 'edit') + { + print "id&action=update\" method=\"post\">"; + print ''; + } + + print ''; + + // Ref + print '"; + + // Label + if ($action == 'edit') + { + print ''; + } + else + { + print ''; + } + + $rowspan=5; + print '"; + + print ""; + + // Period end date + print ""; + print ""; + + // Due date + if ($action == 'edit') + { + print '"; + } + else { + print ""; + } + + // Amount + print ''; + + // Status + print ''; + + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'id'); + print "
'.$langs->trans("Label").''; + print ''; + print '
'.$langs->trans("Label").''.$object->label.'
'; + + /* + * Payments + */ + $sql = "SELECT p.rowid, p.num_payment, datep as dp, p.amount,"; + $sql.= "c.libelle as paiement_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; + $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; + $sql.= ", ".MAIN_DB_PREFIX."loan as l"; + $sql.= " WHERE p.fk_loan = ".$id; + $sql.= " AND p.fk_loan = l.rowid"; + $sql.= " AND l.entity = ".$conf->entity; + $sql.= " AND p.fk_typepayment = c.id"; + $sql.= " ORDER BY dp DESC"; + + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + echo ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print "'; + print '\n"; + print "\n"; + print '\n"; + print ""; + $totalpaye += $objp->amount; + $i++; + } + + if ($object->paye == 0) + { + print "\n"; + print "\n"; + + $resteapayer = $object->amount - $totalpaye; + + print ""; + print "\n"; + } + print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Amount").' 
"; + print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaye)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("RemainderToPay")." :".price($resteapayer)." ".$langs->trans("Currency".$conf->currency)."
"; + $db->free($resql); + } + else + { + dol_print_error($db); + } + print "
".$langs->trans("PeriodEndDate").""; + if ($action == 'edit') + { + print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1); + } + else + { + print dol_print_date($object->periode,"day"); + } + print "
'.$langs->trans("DateDue").""; + print $form->select_date($object->date_ech, 'ech', 0, 0, 0, 'charge', 1); + print "
".$langs->trans("DateDue")."".dol_print_date($object->date_ech,'day')."
'.$langs->trans("AmountTTC").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("Status").''.$object->getLibStatut(4, $totalpaye).'
'; + + if ($action == 'edit') + { + print '
'; + print ''; + print '   '; + print ''; + print '\n"; + + dol_fiche_end(); + + + /* + * Boutons actions + */ + if ($action != 'edit') + { + print "
\n"; + + // Edit + if ($user->rights->loan->write) + { + print "id&action=edit\">".$langs->trans("Modify").""; + } + + // Emettre paiement + if ($object->paye == 0 && ((price2num($object->amount) < 0 && round($resteapayer) < 0) || (price2num($object->amount) > 0 && round($resteapayer) > 0)) && $user->rights->loan->write) + { + print "id&action=create\">".$langs->trans("DoPayment").""; + } + + // Classify 'paid' + if ($object->paye == 0 && round($resteapayer) <=0 && $user->rights->loan->write) + { + print "id&action=paid\">".$langs->trans("ClassifyPaid").""; + } + + // Delete + if ($user->rights->loan->delete) + { + print "id&action=delete\">".$langs->trans("Delete").""; + } + + print "
"; + } + } + else + { + // Loan not find + dol_print_error('',$object->error); + } +} + + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/loan/class/index.html b/htdocs/compta/loan/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/compta/loan/class/loan.class.php b/htdocs/compta/loan/class/loan.class.php new file mode 100644 index 00000000000..74aed1d048b --- /dev/null +++ b/htdocs/compta/loan/class/loan.class.php @@ -0,0 +1,477 @@ + + * + * 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/compta/loan/class/loan.class.php + * \ingroup loan + * \brief Class for loan module + */ +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + + +/** \class Loan + * \brief Class to manage loan + */ +class Loan extends CommonObject +{ + public $element='loan'; + public $table='loan'; + public $table_element='loan'; + + var $id; + var $ref; + var $date_start; + var $dateend; + var $label; + var $capital; + var $nbterm; + var $rate; + var $note; + var $account_capital; + var $account_insurance; + var $account_interest; + var $date_creation; + var $date_modification; + var $date_validation; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + return 1; + } + + /** + * Load object in memory from database + * + * @param int $id id object + * @return void + */ + function fetch($id) + { + $sql = "SELECT l.rowid, l.datestart,"; + $sql.= " l.label, l.capital"; + $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; + $sql.= " WHERE l.rowid = ".$id; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->datestart = $this->db->jdate($obj->datestart); + $this->label = $obj->label; + $this->capital = $obj->capital; + + return 1; + } + else + { + return 0; + } + $this->db->free($resql); + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } + + + /** + * Create a social contribution into database + * + * @param User $user User making creation + * @return int <0 if KO, id if OK + */ + function create($user) + { + global $conf; + + // clean parameters + $newcapital=price2num($this->capital,'MT'); + + // Validation parametres + if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode)) + { + $this->error="ErrorBadParameter"; + return -2; + } + + $this->db->begin(); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, libelle, date_ech, periode, amount, entity)"; + $sql.= " VALUES (".$this->type.",'".$this->db->escape($this->lib)."',"; + $sql.= " '".$this->db->idate($this->date_ech)."','".$this->db->idate($this->periode)."',"; + $sql.= " '".price2num($newamount)."',"; + $sql.= " ".$conf->entity; + $sql.= ")"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); + + //dol_syslog("ChargesSociales::create this->id=".$this->id); + $this->db->commit(); + return $this->id; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + + + /** + * Delete a social contribution + * + * @param User $user Object user making delete + * @return int <0 if KO, >0 if OK + */ + function delete($user) + { + $error=0; + + $this->db->begin(); + + // Get bank transaction lines for this social contributions + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $account=new Account($this->db); + $lines_url=$account->get_url('',$this->id,'sc'); + + // Delete bank urls + foreach ($lines_url as $line_url) + { + if (! $error) + { + $accountline=new AccountLine($this->db); + $accountline->fetch($line_url['fk_bank']); + $result=$accountline->delete_urls($user); + if ($result < 0) + { + $error++; + } + } + } + + // Delete payments + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge where fk_charge='".$this->id."'"; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + $error++; + $this->error=$this->db->lasterror(); + } + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales where rowid='".$this->id."'"; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + $error++; + $this->error=$this->db->lasterror(); + } + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + + } + + + /** + * Met a jour une charge sociale + * + * @param User $user Utilisateur qui modifie + * @return int <0 si erreur, >0 si ok + */ + function update($user) + { + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; + $sql.= " SET libelle='".$this->db->escape($this->lib)."',"; + $sql.= " date_ech='".$this->db->idate($this->date_ech)."',"; + $sql.= " periode='".$this->db->idate($this->periode)."'"; + $sql.= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** + * Enter description here ... + * + * @param int $year Year + * @return number + */ + function solde($year = 0) + { + global $conf; + + $sql = "SELECT SUM(f.amount) as amount"; + $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; + $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " AND paye = 0"; + + if ($year) { + $sql .= " AND f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' "; + } + + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + return $obj->amount; + } + else + { + return 0; + } + + $this->db->free($result); + + } + else + { + print $this->db->error(); + return -1; + } + } + + /** + * Tag social contribution as payed completely + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + function set_paid($user) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; + $sql.= " paye = 1"; + $sql.= " WHERE rowid = ".$this->id; + $return = $this->db->query($sql); + if ($return) return 1; + else return -1; + } + + /** + * Retourne le libelle du statut d'une charge (impaye, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @return string Label + */ + function getLibStatut($mode=0,$alreadypaid=-1) + { + return $this->LibStatut($this->paye,$mode,$alreadypaid); + } + + /** + * Return label for given status + * + * @param int $statut Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @return string Label + */ + function LibStatut($statut,$mode=0,$alreadypaid=-1) + { + global $langs; + $langs->load('customers'); + $langs->load('bills'); + + if ($mode == 0) + { + if ($statut == 0) return $langs->trans("Unpaid"); + if ($statut == 1) return $langs->trans("Paid"); + } + if ($mode == 1) + { + if ($statut == 0) return $langs->trans("Unpaid"); + if ($statut == 1) return $langs->trans("Paid"); + } + if ($mode == 2) + { + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + } + if ($mode == 3) + { + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); + } + if ($mode == 4) + { + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + } + if ($mode == 5) + { + if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + } + + return "Error, mode/status not found"; + } + + + /** + * Return clicable name (with eventually the picto) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen Label max length + * @return string Chaine with URL + */ + function getNameUrl($withpicto=0,$maxlen=0) + { + global $langs; + + $result=''; + + if (empty($this->ref)) $this->ref=$this->lib; + + $lien = ''; + $lienfin=''; + + if ($withpicto) $result.=($lien.img_object($langs->trans("ShowSocialContribution").': '.$this->lib,'bill').$lienfin.' '); + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin; + return $result; + } + + /** + * Return amount of payments already done + * + * @return int Amount of payment already done, <0 if KO + */ + function getSumPayment() + { + $table='payment_loan'; + $field='fk_loan'; + + $sql = 'SELECT sum(amount) as amount'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$table; + $sql.= ' WHERE '.$field.' = '.$this->id; + + dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $amount=0; + + $obj = $this->db->fetch_object($resql); + if ($obj) $amount=$obj->amount?$obj->amount:0; + + $this->db->free($resql); + return $amount; + } + else + { + return -1; + } + } + + /** + * Information on record + * + * @param int $id Id of record + * @return void + */ + function info($id) + { + $sql = "SELECT l.rowid, l.tms as datem, l.datec as datec"; + $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; + $sql.= " WHERE l.rowid = ".$id; + + dol_syslog(get_class($this)."::info", LOG_DEBUG); + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + + $this->id = $obj->rowid; + + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + + } + + $this->db->free($result); + + } + else + { + dol_print_error($this->db); + } + } +} + diff --git a/htdocs/compta/loan/class/paymentloan.class.php b/htdocs/compta/loan/class/paymentloan.class.php new file mode 100644 index 00000000000..972fa762b96 --- /dev/null +++ b/htdocs/compta/loan/class/paymentloan.class.php @@ -0,0 +1,603 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/sociales/class/paymentsocialcontribution.class.php + * \ingroup facture + * \brief File of class to manage payment of social contributions + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + + +/** \class PaymentSocialContribution + * \brief Class to manage payments of social contributions + */ +class PaymentSocialContribution extends CommonObject +{ + public $element='paiementcharge'; //!< Id that identify managed objects + public $table_element='paiementcharge'; //!< Name of table without prefix where object is stored + + var $id; + var $ref; + + var $fk_charge; + var $datec=''; + var $tms=''; + var $datep=''; + var $amount; // Total amount of payment + var $amounts=array(); // Array of amounts + var $fk_typepaiement; + var $num_paiement; + var $note; + var $fk_bank; + var $fk_user_creat; + var $fk_user_modif; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + + /** + * Create payment of social contribution into database. + * Use this->amounts to have list of lines for the payment + * + * @param User $user User making payment + * @return int <0 if KO, id of payment if OK + */ + function create($user) + { + global $conf, $langs; + + $error=0; + + $now=dol_now(); + + // Validate parametres + if (! $this->datepaye) + { + $this->error='ErrorBadValueForParameter'; + return -1; + } + + // Clean parameters + if (isset($this->fk_charge)) $this->fk_charge=trim($this->fk_charge); + if (isset($this->amount)) $this->amount=trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement=trim($this->fk_typepaiement); + if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); + if (isset($this->note)) $this->note=trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + + $totalamount = 0; + foreach ($this->amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $this->amounts[$key] = $newvalue; + $totalamount += $newvalue; + } + $totalamount = price2num($totalamount); + + // Check parameters + if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + + + $this->db->begin(); + + if ($totalamount != 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,"; + $sql.= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; + $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql.= " '".$this->db->idate($this->datepaye)."',"; + $sql.= " ".$totalamount.","; + $sql.= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql.= " 0)"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge"); + } + else + { + $error++; + } + + } + + if ($totalamount != 0 && ! $error) + { + $this->amount=$totalamount; + $this->total=$totalamount; // deprecated + $this->db->commit(); + return $this->id; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + function fetch($id) + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.fk_charge,"; + $sql.= " t.datec,"; + $sql.= " t.tms,"; + $sql.= " t.datep,"; + $sql.= " t.amount,"; + $sql.= " t.fk_typepaiement,"; + $sql.= " t.num_paiement,"; + $sql.= " t.note,"; + $sql.= " t.fk_bank,"; + $sql.= " t.fk_user_creat,"; + $sql.= " t.fk_user_modif,"; + $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; + $sql.= ' b.fk_account'; + $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."paiementcharge as t)"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; + $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepaiement = pt.id"; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + + $this->fk_charge = $obj->fk_charge; + $this->datec = $this->db->jdate($obj->datec); + $this->tms = $this->db->jdate($obj->tms); + $this->datep = $this->db->jdate($obj->datep); + $this->amount = $obj->amount; + $this->fk_typepaiement = $obj->fk_typepaiement; + $this->num_paiement = $obj->num_paiement; + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_creat = $obj->fk_user_creat; + $this->fk_user_modif = $obj->fk_user_modif; + + $this->type_code = $obj->type_code; + $this->type_libelle = $obj->type_libelle; + + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user=0, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + + if (isset($this->fk_charge)) $this->fk_charge=trim($this->fk_charge); + if (isset($this->amount)) $this->amount=trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement=trim($this->fk_typepaiement); + if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); + if (isset($this->note)) $this->note=trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + + + + // Check parameters + // Put here code to add control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET"; + + $sql.= " fk_charge=".(isset($this->fk_charge)?$this->fk_charge:"null").","; + $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; + $sql.= " fk_typepaiement=".(isset($this->fk_typepaiement)?$this->fk_typepaiement:"null").","; + $sql.= " num_paiement=".(isset($this->num_paiement)?"'".$this->db->escape($this->num_paiement)."'":"null").","; + $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; + $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; + $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; + $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; + + + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + $this->db->begin(); + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; + $sql.= " WHERE type='payment_sc' AND url_id=".$this->id; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge"; + $sql.= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + 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; + } + } + + + + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + function createFromClone($fromid) + { + global $user,$langs; + + $error=0; + + $object=new PaymentSocialContribution($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + $object->id=0; + $object->statut=0; + + // Clear fields + // ... + + // Create clone + $result=$object->create($user); + + // Other options + if ($result < 0) + { + $this->error=$object->error; + $error++; + } + + if (! $error) + { + + + + } + + // End + if (! $error) + { + $this->db->commit(); + return $object->id; + } + else + { + $this->db->rollback(); + return -1; + } + } + + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + function initAsSpecimen() + { + $this->id=0; + + $this->fk_charge=''; + $this->datec=''; + $this->tms=''; + $this->datep=''; + $this->amount=''; + $this->fk_typepaiement=''; + $this->num_paiement=''; + $this->note=''; + $this->fk_bank=''; + $this->fk_user_creat=''; + $this->fk_user_modif=''; + + + } + + + /** + * Add record into bank for payment with links between this bank record and invoices of payment. + * All payment properties must have been set first like after a call to create(). + * + * @param User $user Object of user making payment + * @param string $mode 'payment_sc' + * @param string $label Label to use in bank record + * @param int $accountid Id of bank account to do link with + * @param string $emetteur_nom Name of transmitter + * @param string $emetteur_banque Name of bank + * @return int <0 if KO, >0 if OK + */ + function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque) + { + global $conf; + + $error=0; + + if (! empty($conf->banque->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $acc = new Account($this->db); + $acc->fetch($accountid); + + $total=$this->total; + if ($mode == 'payment_sc') $total=-$total; + + // Insert payment into llx_bank + $bank_line_id = $acc->addline( + $this->datepaye, + $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") + $label, + $total, + $this->num_paiement, + '', + $user, + $emetteur_nom, + $emetteur_banque + ); + + // Mise a jour fk_bank dans llx_paiement. + // On connait ainsi le paiement qui a genere l'ecriture bancaire + if ($bank_line_id > 0) + { + $result=$this->update_fk_bank($bank_line_id); + if ($result <= 0) + { + $error++; + dol_print_error($this->db); + } + + // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction + $url=''; + if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='; + if ($url) + { + $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + if ($result <= 0) + { + $error++; + dol_print_error($this->db); + } + } + + // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) + $linkaddedforthirdparty=array(); + foreach ($this->amounts as $key => $value) + { + if ($mode == 'payment_sc') + { + $socialcontrib = new ChargeSociales($this->db); + $socialcontrib->fetch($key); + $result=$acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''),'sc'); + if ($result <= 0) dol_print_error($this->db); + } + } + } + else + { + $this->error=$acc->error; + $error++; + } + } + + if (! $error) + { + return 1; + } + else + { + return -1; + } + } + + + /** + * Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee + * + * @param int $id_bank Id if bank + * @return int >0 if OK, <=0 if KO + */ + function update_fk_bank($id_bank) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + return 1; + } + else + { + $this->error=$this->db->error(); + return 0; + } + } + + /** + * Renvoie nom clicable (avec eventuellement le picto) + * + * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + * @param int $maxlen Longueur max libelle + * @return string Chaine avec URL + */ + function getNomUrl($withpicto=0,$maxlen=0) + { + global $langs; + + $result=''; + + if (empty($this->ref)) $this->ref=$this->lib; + + if (!empty($this->id)) + { + $lien = ''; + $lienfin=''; + + if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$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/loan/document.php b/htdocs/compta/loan/document.php new file mode 100644 index 00000000000..ad5af8f84c2 --- /dev/null +++ b/htdocs/compta/loan/document.php @@ -0,0 +1,178 @@ + + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2013 Cédric Salvador + * + * 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/compta/sociales/document.php + * \ingroup tax + * \brief Page with attached files on social contributions + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +$langs->load("other"); +$langs->load("companies"); +$langs->load("compta"); +$langs->load("bills"); + +$id = GETPOST('id','int'); +$action = GETPOST("action"); +$confirm = GETPOST('confirm', 'alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'tax', $id, 'chargesociales','charges'); + + +// Get parameters +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { + $page = 0; +} +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + + +$object = new ChargeSociales($db); +if ($id > 0) $object->fetch($id); + +$upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref); +$modulepart='tax'; + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; + + +/* + * View + */ + +$form = new Form($db); + +$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; +llxHeader("",$langs->trans("SocialContribution"),$help_url); + +if ($object->id) +{ + $alreadypayed=$object->getSommePaiement(); + + $head=tax_prepare_head($object, $user); + + dol_fiche_head($head, 'documents', $langs->trans("SocialContribution"), 0, 'bill'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + // Ref + print '"; + + // Label + if ($action == 'edit') + { + print ''; + } + else + { + print ''; + } + + // Type + print ""; + + // Period end date + print ""; + print ""; + print ""; + + // Due date + if ($action == 'edit') + { + print '"; + } + else { + print ""; + } + + // Amount + print ''; + + // Status + print ''; + + print ''; + print ''; + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'id'); + print "
'.$langs->trans("Label").''; + print ''; + print '
'.$langs->trans("Label").''.$object->lib.'
".$langs->trans("Type")."".$object->type_libelle."
".$langs->trans("PeriodEndDate").""; + if ($action == 'edit') + { + print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1); + } + else + { + print dol_print_date($object->periode,"day"); + } + print "
'.$langs->trans("DateDue").""; + print $form->select_date($object->date_ech, 'ech', 0, 0, 0, 'charge', 1); + print "
".$langs->trans("DateDue")."".dol_print_date($object->date_ech,'day')."
'.$langs->trans("AmountTTC").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("Status").''.$object->getLibStatut(4,$alreadypayed).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print '
'; + + $modulepart = 'tax'; + $permission = $user->rights->tax->charges->creer; + $param = '&id=' . $object->id; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + print $langs->trans("ErrorUnknown"); +} + + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/loan/index.html b/htdocs/compta/loan/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/compta/loan/index.php b/htdocs/compta/loan/index.php new file mode 100644 index 00000000000..d84d1897c24 --- /dev/null +++ b/htdocs/compta/loan/index.php @@ -0,0 +1,208 @@ + + * + * 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/compta/loan/index.php + * \ingroup loan + * \brief Page to list all loans + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; + +$langs->load("loan"); +$langs->load("compta"); +$langs->load("banks"); +$langs->load("bills"); + +// Security check +$socid = isset($_GET["socid"])?$_GET["socid"]:''; +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'loan', '', '', ''); + +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +$limit = $conf->liste_limit; +if (! $sortfield) $sortfield="l.rowid"; +if (! $sortorder) $sortorder="DESC"; + +$year=$_GET["year"]; +$filtre=$_GET["filtre"]; + +/* + * View + */ + +$form = new Form($db); +$loan = new Loan($db); + +llxHeader(); + +$sql = "SELECT cs.rowid as id, cs.fk_type as type, "; +$sql.= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; +$sql.= " c.libelle as type_lib,"; +$sql.= " SUM(pc.amount) as alreadypayed"; +$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; +$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; +$sql.= " WHERE cs.fk_type = c.id"; +$sql.= " AND cs.entity = ".$conf->entity; +if (GETPOST("search_label")) $sql.=" AND cs.libelle LIKE '%".$db->escape(GETPOST("search_label"))."%'"; +if ($year > 0) +{ + $sql .= " AND ("; + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " (cs.periode IS NOT NULL AND date_format(cs.periode, '%Y') = '".$year."') "; + $sql .= "OR (cs.periode IS NULL AND date_format(cs.date_ech, '%Y') = '".$year."')"; + $sql .= ")"; +} +if ($filtre) { + $filtre=str_replace(":","=",$filtre); + $sql .= " AND ".$filtre; +} +if ($typeid) { + $sql .= " AND cs.fk_type=".$typeid; +} +$sql.= " GROUP BY cs.rowid, cs.fk_type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle"; +$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->plimit($limit+1,$offset); + + +$resql=$db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + $var=true; + + $param=''; + if ($year) $param.='&year='.$year; + if ($typeid) $param.='&typeid='.$typeid; + + if ($year) + { + print_fiche_titre($langs->trans("SocialContributions"),($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":"")); + } + else + { + print_barre_liste($langs->trans("SocialContributions"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines); + } + + if (empty($mysoc->country_id) && empty($mysoc->country_code)) + { + print '
'; + $langs->load("errors"); + $countrynotdefined=$langs->trans("ErrorSetACountryFirst"); + print $countrynotdefined; + print '
'; + } + else + { + + print ''; + + print ""; + + print ""; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"id","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"cs.libelle","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"periode","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cs.paye","",$param,'align="right"',$sortfield,$sortorder); + print "\n"; + + print ''; + print ''; + print ''; + // Type + print ''; + // Period end date + print ''; + print ''; + print ''; + print ''; + print "\n"; + + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); + + $var = !$var; + print ""; + + // Ref + print ''; + + // Label + print ''; + + // Type + print ''; + + // Date end period + print ''; + + print ''; + + // Due date + print ''; + + print ''; + + print ''; + $i++; + } + + print '
 '; + $formsocialcontrib->select_type_socialcontrib($typeid,'typeid',1,16,0); + print '   '; + print ''; + print '
'; + $loan->id=$obj->id; + $loan->lib=$obj->id; + $loan->ref=$obj->id; + print $loan->getNomUrl(1,'20'); + print ''.dol_trunc($obj->libelle,42).''.dol_trunc($obj->type_lib,16).''; + if ($obj->periode) + { + print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode),'day').''; + } + else + { + print ' '; + } + print ''.price($obj->amount).''.dol_print_date($db->jdate($obj->date_ech), 'day').''.$loan->LibStatut($obj->paye,5,$obj->alreadypayed).'
'; + + print ''; + } +} +else +{ + dol_print_error($db); +} + +$db->close(); + +llxFooter(); diff --git a/htdocs/compta/loan/info.php b/htdocs/compta/loan/info.php new file mode 100644 index 00000000000..c41787b7d08 --- /dev/null +++ b/htdocs/compta/loan/info.php @@ -0,0 +1,65 @@ + + * + * 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/compta/sociales/info.php + * \ingroup tax + * \brief Page with info about social contribution + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + +$langs->load("compta"); +$langs->load("bills"); + +$id=GETPOST('id','int'); +$action=GETPOST("action"); + +// Security check +$socid = GETPOST('socid','int'); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'tax', $id, 'chargesociales','charges'); + + +/* + * View + */ + +$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; +llxHeader("",$langs->trans("SocialContribution"),$help_url); + +$chargesociales = new ChargeSociales($db); +$chargesociales->fetch($id); +$chargesociales->info($id); + +$head = tax_prepare_head($chargesociales); + +dol_fiche_head($head, 'info', $langs->trans("SocialContribution"), 0, 'bill'); + + +print '
'; +dol_print_object_info($chargesociales); +print '
'; + +print ''; + +llxFooter(); + +$db->close(); diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php new file mode 100644 index 00000000000..58ebaef7bfd --- /dev/null +++ b/htdocs/core/lib/loan.lib.php @@ -0,0 +1,66 @@ + + * + * 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/lib/loan.lib.php + * \ingroup loan + * \brief Library for loan module + */ + + +/** + * Prepare array with list of tabs + * + * @param Object $object Object related to tabs + * @return array Array of tabs to show + */ +function loan_prepare_head($object) +{ + global $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/compta/loan/card.php?id='.$object->id; + $head[$h][1] = $langs->trans('Card'); + $head[$h][2] = 'card'; + $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,'loan'); + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); + $head[$h][0] = DOL_URL_ROOT.'/compta/loan/document.php?id='.$object->id; + $head[$h][1] = $langs->trans("Documents"); + if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; + $head[$h][2] = 'documents'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/loan/info.php?id='.$object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + + complete_head_from_modules($conf,$langs,$object,$head,$h,'loan','remove'); + + return $head; +} \ No newline at end of file diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 1d7aa1a5a9a..fd37ccacaf9 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -134,9 +134,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0) } // Financial - $tmpentry=array('enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->don->enabled) || ! empty($conf->tax->enabled) || ! empty($conf->salaries->enabled)), - 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->plancompte->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read)), - 'module'=>'comptabilite|accounting|facture|don|tax|salaries'); + $tmpentry=array('enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->don->enabled) || ! empty($conf->tax->enabled) || ! empty($conf->salaries->enabled) || ! empty($conf->loan->enabled)), + 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->plancompte->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->loan->read)), + 'module'=>'comptabilite|accounting|facture|don|tax|salaries|loan'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { @@ -802,11 +802,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // Taxes and social contributions - if (! empty($conf->tax->enabled) || ! empty($conf->salaries->enabled)) + if (! empty($conf->tax->enabled) || ! empty($conf->salaries->enabled) || ! empty($conf->loan->enabled)) { global $mysoc; - $permtoshowmenu=((! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && $user->rights->salaries->read)); + $permtoshowmenu=((! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && $user->rights->salaries->read) || (! empty($conf->loan->enabled) && $user->rights->loan->read)); $newmenu->add("/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy",$langs->trans("MenuSpecialExpenses"), 0, $permtoshowmenu, '', $mainmenu, 'tax'); // Salaries @@ -817,6 +817,15 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/fiche.php?leftmenu=tax_salary&action=create",$langs->trans("NewPayment"),2,$user->rights->salaries->write); if (empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary",$langs->trans("Payments"),2,$user->rights->salaries->read); } + + // Loan + if (! empty($conf->loan->enabled)) + { + $langs->load("loan"); + $newmenu->add("/compta/loan/index.php?leftmenu=tax_loan&mainmenu=accountancy",$langs->trans("Loans"),1,$user->rights->loan->read, '', $mainmenu, 'tax_loan'); + if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/card.php?leftmenu=tax_loan&action=create",$langs->trans("NewLoan"),2,$user->rights->loan->write); + if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/index.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read); + } // Social contributions if (! empty($conf->tax->enabled)) diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php new file mode 100644 index 00000000000..fb2de1e3a02 --- /dev/null +++ b/htdocs/core/modules/modLoan.class.php @@ -0,0 +1,173 @@ + + * + * 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/ + */ + +/** + * \defgroup tax Module Loans + * \brief Module to include loans management + * \file htdocs/core/modules/modLoan.class.php + * \ingroup loan + * \brief File to activate module loan + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +/** + * Class to manage loan module + */ +class modLoan extends DolibarrModules +{ + + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf; + + $this->db = $db; + $this->numero = 520; + + $this->family = "financial"; + // 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)); + // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Loans management"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; + + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->special = 0; + $this->picto='bill'; + + // Data directories to create when module is enabled + $this->dirs = array("/loan/temp"); + + // Config pages + $this->config_page_url = array('loan.php'); + + // Dependances + $this->depends = array(); + $this->requiredby = array(); + $this->conflictwith = array(); + $this->langfiles = array("loan"); + + // Constants + $this->const = array(); + $this->const[0] = array( + "LOAN_ACCOUNTING_ACCOUNT_CAPITAL", + "chaine", + "164" + ); + $this->const[1] = array( + "LOAN_ACCOUNTING_ACCOUNT_INTEREST", + "chaine", + "6611" + ); + $this->const[1] = array( + "LOAN_ACCOUNTING_ACCOUNT_INSURANCE", + "chaine", + "6162" + ); + + // Boxes + $this->boxes = array(); + + // Permissions + $this->rights = array(); + $this->rights_class = 'loan'; + $r=0; + + $r++; + $this->rights[$r][0] = 520; + $this->rights[$r][1] = 'Read loans'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'read'; + $this->rights[$r][5] = ''; + + $r++; + $this->rights[$r][0] = 522; + $this->rights[$r][1] = 'Create/modify loans'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'write'; + $this->rights[$r][5] = ''; + + $r++; + $this->rights[$r][0] = 524; + $this->rights[$r][1] = 'Delete loans'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'delete'; + $this->rights[$r][5] = ''; + + $r++; + $this->rights[$r][0] = 527; + $this->rights[$r][1] = 'Export loans'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'export'; + $this->rights[$r][5] = ''; + + + // Exports + //-------- + $r=0; + + } + + + /** + * 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='') + { + global $conf; + + // Clean before activation + $this->remove($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/install/mysql/tables/llx_loan.sql b/htdocs/install/mysql/tables/llx_loan.sql new file mode 100644 index 00000000000..2ca026ba417 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_loan.sql @@ -0,0 +1,47 @@ +-- ======================================================================== +-- Copyright (C) 2014 Alexandre Spangaro +-- +-- 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_loan +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, + datec datetime, + tms timestamp, + + label varchar(80) NOT NULL, + fk_bank integer, + + capital real default 0 NOT NULL, + datestart date, + dateend date, + nbterm real, + rate double NOT NULL, + + note text, + + capital_position real default 0, -- If not a new loan, just have the position of capital + date_position date, + + accountancy_account_capital varchar(32), + accountancy_account_insurance varchar(32), + accountancy_account_interest varchar(32), + + fk_user_author integer DEFAULT NULL, + fk_user_modif integer DEFAULT NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_payment_loan.sql b/htdocs/install/mysql/tables/llx_payment_loan.sql new file mode 100644 index 00000000000..83bb3ac2548 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_payment_loan.sql @@ -0,0 +1,33 @@ +-- =================================================================== +-- Copyright (C) 2014 Alexandre Spangaro +-- +-- 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_payment_loan +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_loan integer, + datec datetime, -- creation date + tms timestamp, + datep datetime, -- payment date + amount real DEFAULT 0, + fk_typepayment integer NOT NULL, + num_payment varchar(50), + note text, + fk_bank integer NOT NULL, + fk_user_creat integer, -- creation user + fk_user_modif integer -- last modification user +)ENGINE=innodb; From 1409c8f4503c7f527f7faf538d7031bbbfdc6adc Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 21 Sep 2014 21:38:33 +0200 Subject: [PATCH 028/940] Continue to work --- htdocs/compta/loan/card.php | 40 +++++++++++++++---------- htdocs/compta/loan/class/loan.class.php | 22 +++++++------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index f8cf4d29327..3e7ce94520a 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -24,6 +24,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("compta"); $langs->load("bills"); @@ -71,16 +72,16 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // Add loan if ($action == 'add' && $user->rights->loan->write) { - $dateech=@dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]); - $dateperiod=@dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]); - if (! $dateech) + $datestart=dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); + $dateend=dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + if (! $datestart) { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors'); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors'); $action = 'create'; } - elseif (! $dateperiod) + elseif (! $dateend) { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors'); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateEnd")), 'errors'); $action = 'create'; } elseif (! $_POST["capital"]) @@ -92,10 +93,17 @@ if ($action == 'add' && $user->rights->loan->write) { $loan = new Loan($db); - $loan->label = $_POST["label"]; - $loan->date_ech = $dateech; - $loan->periode = $dateperiod; - $loan->capital = $_POST["capital"]; + $loan->label = GETPOST("label"); + $loan->fk_bank = GETPOST("accountid"); + $loan->capital = GETPOST("capital"); + $loan->datestart = $datestart; + $loan->dateend = $dateend; + $loan->nbterm = GETPOST("nbterm"); + $loan->rate = GETPOST("rate"); + + $loan->account_capital = GETPOST("accountancy_account_capital"); + $loan->account_insurance = GETPOST("accountancy_account_insurance"); + $loan->account_interest = GETPOST("accountancy_account_interest"); $id=$loan->create($user); if ($id <= 0) @@ -125,9 +133,9 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->loan->write) $loan = new Loan($db); $result=$loan->fetch($_GET["id"]); - $loan->lib=$_POST["label"]; - $loan->date_ech=$dateech; - $loan->periode=$dateperiod; + $loan->label=$_POST["label"]; + $loan->datestart=$datestart; + $loan->dateend=$dateend; $result=$loan->update($user); if ($result <= 0) @@ -188,13 +196,13 @@ if ($action == 'create') // Date Start print ""; print ''.$langs->trans("DateStart").''; - print $form->select_date($datestart?$datestart:-1,'','','','','add',1,1); + print $form->select_date($datestart?$datestart:-1,'start','','','','add',1,1); print ''; // Date End print ""; print ''.$langs->trans("DateEnd").''; - print $form->select_date($dateend?$dateend:-1,'','','','','add',1,1); + print $form->select_date($dateend?$dateend:-1,'end','','','','add',1,1); print ''; // Number of terms @@ -430,7 +438,7 @@ if ($id > 0) // Edit if ($user->rights->loan->write) { - print "id&action=edit\">".$langs->trans("Modify").""; + print "id&action=edit\">".$langs->trans("Modify").""; } // Emettre paiement diff --git a/htdocs/compta/loan/class/loan.class.php b/htdocs/compta/loan/class/loan.class.php index 74aed1d048b..8b6bba2abf5 100644 --- a/htdocs/compta/loan/class/loan.class.php +++ b/htdocs/compta/loan/class/loan.class.php @@ -34,7 +34,7 @@ class Loan extends CommonObject var $id; var $ref; - var $date_start; + var $datestart; var $dateend; var $label; var $capital; @@ -116,8 +116,8 @@ class Loan extends CommonObject // clean parameters $newcapital=price2num($this->capital,'MT'); - // Validation parametres - if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode)) + // Check parameters + if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend)) { $this->error="ErrorBadParameter"; return -2; @@ -125,10 +125,10 @@ class Loan extends CommonObject $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, libelle, date_ech, periode, amount, entity)"; - $sql.= " VALUES (".$this->type.",'".$this->db->escape($this->lib)."',"; - $sql.= " '".$this->db->idate($this->date_ech)."','".$this->db->idate($this->periode)."',"; - $sql.= " '".price2num($newamount)."',"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, date_ech, periode, amount, entity)"; + $sql.= " VALUES ('".$this->db->escape($this->label)."',"; + $sql.= " '".$this->db->idate($this->datestart)."','".$this->db->idate($this->dateend)."',"; + $sql.= " '".price2num($newcapital)."',"; $sql.= " ".$conf->entity; $sql.= ")"; @@ -136,9 +136,9 @@ class Loan extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."loan"); - //dol_syslog("ChargesSociales::create this->id=".$this->id); + //dol_syslog("Loans::create this->id=".$this->id); $this->db->commit(); return $this->id; } @@ -152,7 +152,7 @@ class Loan extends CommonObject /** - * Delete a social contribution + * Delete a loan * * @param User $user Object user making delete * @return int <0 if KO, >0 if OK @@ -223,7 +223,7 @@ class Loan extends CommonObject /** - * Met a jour une charge sociale + * Update loan * * @param User $user Utilisateur qui modifie * @return int <0 si erreur, >0 si ok From f51df9da705e6f42230f03e4f787f3d836b951f1 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 22 Sep 2014 08:24:58 +0200 Subject: [PATCH 029/940] Add loan language file --- .tx/config | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.tx/config b/.tx/config index a89b56c1013..bf62f32d9d6 100644 --- a/.tx/config +++ b/.tx/config @@ -176,6 +176,12 @@ source_file = htdocs/langs/en_US/link.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.loan] +file_filter = htdocs/langs//loan.lang +source_file = htdocs/langs/en_US/loan.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.mailmanspip] file_filter = htdocs/langs//mailmanspip.lang source_file = htdocs/langs/en_US/mailmanspip.lang From c53663c8858801ba1002a2be7a27c9127e2b2366 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 22 Sep 2014 08:25:39 +0200 Subject: [PATCH 030/940] Continue to work --- htdocs/compta/loan/card.php | 174 +++++++++--------- htdocs/compta/loan/class/loan.class.php | 54 +++++- .../compta/loan/class/paymentloan.class.php | 6 +- htdocs/compta/loan/document.php | 77 ++++---- htdocs/compta/loan/info.php | 31 ++-- 5 files changed, 189 insertions(+), 153 deletions(-) diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index 3e7ce94520a..6b075e3d758 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -153,7 +153,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->loan->write) $form = new Form($db); -$help_url='EN:Module_Loan|FR:Module Emprunt'; +$help_url='EN:Module_Loan|FR:Module_Emprunt'; llxHeader("",$langs->trans("Loan"),$help_url); @@ -268,7 +268,7 @@ if ($action == 'create') if ($id > 0) { $object = new Loan($db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result > 0) { @@ -313,101 +313,41 @@ if ($id > 0) { print ''.$langs->trans("Label").''.$object->label.''; } + + // Capital + print ''.$langs->trans("Capital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).''; - $rowspan=5; - print ''; - - /* - * Payments - */ - $sql = "SELECT p.rowid, p.num_payment, datep as dp, p.amount,"; - $sql.= "c.libelle as paiement_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; - $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; - $sql.= ", ".MAIN_DB_PREFIX."loan as l"; - $sql.= " WHERE p.fk_loan = ".$id; - $sql.= " AND p.fk_loan = l.rowid"; - $sql.= " AND l.entity = ".$conf->entity; - $sql.= " AND p.fk_typepayment = c.id"; - $sql.= " ORDER BY dp DESC"; - - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; $total = 0; - echo ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print "'; - print '\n"; - print "\n"; - print '\n"; - print ""; - $totalpaye += $objp->amount; - $i++; - } - - if ($object->paye == 0) - { - print "\n"; - print "\n"; - - $resteapayer = $object->amount - $totalpaye; - - print ""; - print "\n"; - } - print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Amount").' 
"; - print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaye)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("RemainderToPay")." :".price($resteapayer)." ".$langs->trans("Currency".$conf->currency)."
"; - $db->free($resql); - } - else - { - dol_print_error($db); - } - print ""; - - print ""; - - // Period end date - print "".$langs->trans("PeriodEndDate").""; + // Date start + print "".$langs->trans("DateStart").""; print ""; if ($action == 'edit') { - print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1); + print $form->select_date($object->datestart, 'start', 0, 0, 0, 'update', 1); } else { - print dol_print_date($object->periode,"day"); + print dol_print_date($object->datestart,"day"); } print ""; - // Due date + // Date end + print "".$langs->trans("DateEnd").""; + print ""; if ($action == 'edit') { - print ''.$langs->trans("DateDue").""; - print $form->select_date($object->date_ech, 'ech', 0, 0, 0, 'charge', 1); - print ""; + print $form->select_date($object->dateend, 'end', 0, 0, 0, 'update', 1); } - else { - print "".$langs->trans("DateDue")."".dol_print_date($object->date_ech,'day').""; + else + { + print dol_print_date($object->dateend,"day"); } - - // Amount - print ''.$langs->trans("AmountTTC").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).''; + print ""; + + // Nbterms + print ''.$langs->trans("Nbterms").''.$object->nbterm.''; + + // Rate + print ''.$langs->trans("Rate").''.$object->rate.''; // Status print ''.$langs->trans("Status").''.$object->getLibStatut(4, $totalpaye).''; @@ -461,6 +401,74 @@ if ($id > 0) print ""; } + + print '
'; + print ''; + print '"; + print "
'; + + /* + * Payments + */ + $sql = "SELECT p.rowid, p.num_payment, datep as dp, p.amount,"; + $sql.= "c.libelle as paiement_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; + $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; + $sql.= ", ".MAIN_DB_PREFIX."loan as l"; + $sql.= " WHERE p.fk_loan = ".$id; + $sql.= " AND p.fk_loan = l.rowid"; + $sql.= " AND l.entity = ".$conf->entity; + $sql.= " AND p.fk_typepayment = c.id"; + $sql.= " ORDER BY dp DESC"; + + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + echo ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print "'; + print '\n"; + print "\n"; + print '\n"; + print ""; + $totalpaye += $objp->amount; + $i++; + } + + if ($object->paye == 0) + { + print "\n"; + print "\n"; + + $resteapayer = $object->amount - $totalpaye; + + print ""; + print "\n"; + } + print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Amount").' 
"; + print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaye)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("RemainderToPay")." :".price($resteapayer)." ".$langs->trans("Currency".$conf->currency)."
"; + $db->free($resql); + } + else + { + dol_print_error($db); + } + print "
"; } else { diff --git a/htdocs/compta/loan/class/loan.class.php b/htdocs/compta/loan/class/loan.class.php index 8b6bba2abf5..b63f9b32eff 100644 --- a/htdocs/compta/loan/class/loan.class.php +++ b/htdocs/compta/loan/class/loan.class.php @@ -47,6 +47,9 @@ class Loan extends CommonObject var $date_creation; var $date_modification; var $date_validation; + var $fk_bank; + var $fk_user_creat; + var $fk_user_modif; /** @@ -68,8 +71,7 @@ class Loan extends CommonObject */ function fetch($id) { - $sql = "SELECT l.rowid, l.datestart,"; - $sql.= " l.label, l.capital"; + $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; $sql.= " WHERE l.rowid = ".$id; @@ -84,8 +86,12 @@ class Loan extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->datestart = $this->db->jdate($obj->datestart); + $this->dateend = $this->db->jdate($obj->dateend); $this->label = $obj->label; $this->capital = $obj->capital; + $this->nbterm = $obj->nbterm; + $this->rate = $obj->rate; + $this->note = $obj->note; return 1; } @@ -112,9 +118,20 @@ class Loan extends CommonObject function create($user) { global $conf; + + $error=0; + + $now=dol_now(); // clean parameters $newcapital=price2num($this->capital,'MT'); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->account_capital)) $this->account_capital = trim($this->account_capital); + if (isset($this->account_insurance)) $this->account_insurance = trim($this->account_insurance); + if (isset($this->account_interest)) $this->account_interest = trim($this->account_interest); + if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); // Check parameters if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend)) @@ -122,14 +139,31 @@ class Loan extends CommonObject $this->error="ErrorBadParameter"; return -2; } + if (($conf->accounting->enabled) && empty($this->account_capital) && empty($this->account_insurance) && empty($this->account_interest)) + { + $this->error="ErrorAccountingParameter"; + return -2; + } $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, date_ech, periode, amount, entity)"; - $sql.= " VALUES ('".$this->db->escape($this->label)."',"; - $sql.= " '".$this->db->idate($this->datestart)."','".$this->db->idate($this->dateend)."',"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note"; + $sql.= " ,accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity"; + $sql.= " ,datec, fk_user_author)"; + $sql.= " VALUES ('".$this->db->escape($this->label)."',"; + $sql.= " '".$this->db->escape($this->fk_bank)."',"; $sql.= " '".price2num($newcapital)."',"; - $sql.= " ".$conf->entity; + $sql.= " '".$this->db->idate($this->datestart)."',"; + $sql.= " '".$this->db->idate($this->dateend)."',"; + $sql.= " '".$this->db->escape($this->nbterm)."',"; + $sql.= " '".$this->db->escape($this->rate)."',"; + $sql.= " '".$this->db->escape($this->note)."',"; + $sql.= " '".$this->db->escape($this->account_capital)."',"; + $sql.= " '".$this->db->escape($this->account_insurance)."',"; + $sql.= " '".$this->db->escape($this->account_interest)."',"; + $sql.= " ".$conf->entity.","; + $sql.= " '".$this->db->idate($now)."',"; + $sql.= " ".$user->id; $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -440,7 +474,7 @@ class Loan extends CommonObject */ function info($id) { - $sql = "SELECT l.rowid, l.tms as datem, l.datec as datec"; + $sql = "SELECT l.rowid, l.tms as datem, l.fk_user_author as user_author, l.datec as datec"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; $sql.= " WHERE l.rowid = ".$id; @@ -454,10 +488,10 @@ class Loan extends CommonObject $this->id = $obj->rowid; - if ($obj->fk_user_author) { + if ($obj->user_author) { $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $cuser->fetch($obj->user_author); + $this->user_creation = $cuser; } $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/compta/loan/class/paymentloan.class.php b/htdocs/compta/loan/class/paymentloan.class.php index 972fa762b96..24d59fb417b 100644 --- a/htdocs/compta/loan/class/paymentloan.class.php +++ b/htdocs/compta/loan/class/paymentloan.class.php @@ -28,10 +28,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** \class PaymentSocialContribution * \brief Class to manage payments of social contributions */ -class PaymentSocialContribution extends CommonObject +class PaymentLoan extends CommonObject { - public $element='paiementcharge'; //!< Id that identify managed objects - public $table_element='paiementcharge'; //!< Name of table without prefix where object is stored + public $element='payment_loan'; //!< Id that identify managed objects + public $table_element='payment_loan'; //!< Name of table without prefix where object is stored var $id; var $ref; diff --git a/htdocs/compta/loan/document.php b/htdocs/compta/loan/document.php index ad5af8f84c2..022340270ad 100644 --- a/htdocs/compta/loan/document.php +++ b/htdocs/compta/loan/document.php @@ -1,11 +1,5 @@ - * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2013 Cédric Salvador +/* Copyright (C) 2014 Alexandre Spangaro * * 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,22 +16,23 @@ */ /** - * \file htdocs/compta/sociales/document.php - * \ingroup tax - * \brief Page with attached files on social contributions + * \file htdocs/compta/loan/document.php + * \ingroup loan + * \brief Page with attached files on loan */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $langs->load("other"); $langs->load("companies"); $langs->load("compta"); $langs->load("bills"); +$langs->load("loan"); $id = GETPOST('id','int'); $action = GETPOST("action"); @@ -45,8 +40,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'tax', $id, 'chargesociales','charges'); - +$result = restrictedArea($user, 'loan', $id, '',''); // Get parameters $sortfield = GETPOST("sortfield",'alpha'); @@ -61,12 +55,11 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; - -$object = new ChargeSociales($db); +$object = new Loan($db); if ($id > 0) $object->fetch($id); -$upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref); -$modulepart='tax'; +$upload_dir = $conf->loan->dir_output.'/'.dol_sanitizeFileName($object->ref); +$modulepart='loan'; /* @@ -82,16 +75,16 @@ include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php $form = new Form($db); -$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; -llxHeader("",$langs->trans("SocialContribution"),$help_url); +$help_url='EN:Module_Loan|FR:Module_Emprunt'; +llxHeader("",$langs->trans("Loan"),$help_url); if ($object->id) { - $alreadypayed=$object->getSommePaiement(); + $alreadypayed=$object->getSumPayment(); - $head=tax_prepare_head($object, $user); + $head = loan_prepare_head($object, $user); - dol_fiche_head($head, 'documents', $langs->trans("SocialContribution"), 0, 'bill'); + dol_fiche_head($head, 'documents', $langs->trans("Loan"), 0, 'bill'); // Construit liste des fichiers @@ -114,44 +107,44 @@ if ($object->id) if ($action == 'edit') { print ''.$langs->trans("Label").''; - print ''; + print ''; print ''; } else { - print ''.$langs->trans("Label").''.$object->lib.''; + print ''.$langs->trans("Label").''.$object->label.''; } - // Type - print "".$langs->trans("Type")."".$object->type_libelle.""; + // Amount + print ''.$langs->trans("Capital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).''; - // Period end date - print "".$langs->trans("PeriodEndDate").""; + // Date start + print "".$langs->trans("Datestart").""; print ""; if ($action == 'edit') { - print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1); + print $form->select_date($object->datestart, 'start', 0, 0, 0, 'loan', 1); } else { - print dol_print_date($object->periode,"day"); + print dol_print_date($object->datestart,"day"); } print ""; print ""; - // Due date + // Date end + print "".$langs->trans("Dateend").""; + print ""; if ($action == 'edit') { - print ''.$langs->trans("DateDue").""; - print $form->select_date($object->date_ech, 'ech', 0, 0, 0, 'charge', 1); - print ""; + print $form->select_date($object->dateend, 'end', 0, 0, 0, 'loan', 1); } - else { - print "".$langs->trans("DateDue")."".dol_print_date($object->date_ech,'day').""; + else + { + print dol_print_date($object->dateend,"day"); } - - // Amount - print ''.$langs->trans("AmountTTC").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).''; + print ""; + print ""; // Status print ''.$langs->trans("Status").''.$object->getLibStatut(4,$alreadypayed).''; @@ -162,8 +155,8 @@ if ($object->id) print ''; - $modulepart = 'tax'; - $permission = $user->rights->tax->charges->creer; + $modulepart = 'loan'; + $permission = $user->rights->loan->write; $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } diff --git a/htdocs/compta/loan/info.php b/htdocs/compta/loan/info.php index c41787b7d08..74319ba40b8 100644 --- a/htdocs/compta/loan/info.php +++ b/htdocs/compta/loan/info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014 Alexandre Spangaro * * 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,18 +16,19 @@ */ /** - * \file htdocs/compta/sociales/info.php - * \ingroup tax - * \brief Page with info about social contribution + * \file htdocs/compta/loan/info.php + * \ingroup loan + * \brief Page with info about loan */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("compta"); $langs->load("bills"); +$langs->load("loan"); $id=GETPOST('id','int'); $action=GETPOST("action"); @@ -35,27 +36,27 @@ $action=GETPOST("action"); // Security check $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'tax', $id, 'chargesociales','charges'); +$result = restrictedArea($user, 'loan', $id, '',''); /* * View */ -$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; -llxHeader("",$langs->trans("SocialContribution"),$help_url); +$help_url='EN:Module_Loan|FR:Module_Emprunt'; +llxHeader("",$langs->trans("Loan"),$help_url); -$chargesociales = new ChargeSociales($db); -$chargesociales->fetch($id); -$chargesociales->info($id); +$loan = new Loan($db); +$loan->fetch($id); +$loan->info($id); -$head = tax_prepare_head($chargesociales); +$head = loan_prepare_head($loan); -dol_fiche_head($head, 'info', $langs->trans("SocialContribution"), 0, 'bill'); +dol_fiche_head($head, 'info', $langs->trans("Loan"), 0, 'bill'); print '
'; -dol_print_object_info($chargesociales); +dol_print_object_info($loan); print '
'; print ''; From 1e15474495ec854b1baa4a62d4a56720cc518800 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 23 Sep 2014 21:21:38 +0200 Subject: [PATCH 031/940] Continue working --- htdocs/compta/loan/class/loan.class.php | 10 +-- htdocs/compta/loan/index.php | 92 +++++++------------------ 2 files changed, 28 insertions(+), 74 deletions(-) diff --git a/htdocs/compta/loan/class/loan.class.php b/htdocs/compta/loan/class/loan.class.php index b63f9b32eff..afd15ced451 100644 --- a/htdocs/compta/loan/class/loan.class.php +++ b/htdocs/compta/loan/class/loan.class.php @@ -423,14 +423,14 @@ class Loan extends CommonObject $result=''; - if (empty($this->ref)) $this->ref=$this->lib; + if (empty($this->ref)) $this->ref=$this->label; - $lien = ''; - $lienfin=''; + $link = ''; + $linkend=''; - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowSocialContribution").': '.$this->lib,'bill').$lienfin.' '); + if ($withpicto) $result.=($link.img_object($langs->trans("ShowLoan").': '.$this->label,'bill').$linkend.' '); if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin; + if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend; return $result; } diff --git a/htdocs/compta/loan/index.php b/htdocs/compta/loan/index.php index d84d1897c24..41299668dd1 100644 --- a/htdocs/compta/loan/index.php +++ b/htdocs/compta/loan/index.php @@ -45,7 +45,6 @@ $limit = $conf->liste_limit; if (! $sortfield) $sortfield="l.rowid"; if (! $sortorder) $sortorder="DESC"; -$year=$_GET["year"]; $filtre=$_GET["filtre"]; /* @@ -57,33 +56,19 @@ $loan = new Loan($db); llxHeader(); -$sql = "SELECT cs.rowid as id, cs.fk_type as type, "; -$sql.= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; -$sql.= " c.libelle as type_lib,"; -$sql.= " SUM(pc.amount) as alreadypayed"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; -$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; -$sql.= " WHERE cs.fk_type = c.id"; -$sql.= " AND cs.entity = ".$conf->entity; -if (GETPOST("search_label")) $sql.=" AND cs.libelle LIKE '%".$db->escape(GETPOST("search_label"))."%'"; -if ($year > 0) -{ - $sql .= " AND ("; - // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, - // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql .= " (cs.periode IS NOT NULL AND date_format(cs.periode, '%Y') = '".$year."') "; - $sql .= "OR (cs.periode IS NULL AND date_format(cs.date_ech, '%Y') = '".$year."')"; - $sql .= ")"; -} +$sql = "SELECT l.rowid as id, l.label, l.capital, l.datestart, l.dateend,"; +$sql.= " SUM(pl.amount) as alreadypayed"; +$sql.= " FROM ".MAIN_DB_PREFIX."loan as l,"; +$sql.= " ".MAIN_DB_PREFIX."payment_loan as pl"; +$sql.= " WHERE pl.fk_loan = l.rowid"; +$sql.= " AND l.entity = ".$conf->entity; +if (GETPOST("search_label")) $sql.=" AND l.label LIKE '%".$db->escape(GETPOST("search_label"))."%'"; + if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; } -if ($typeid) { - $sql .= " AND cs.fk_type=".$typeid; -} -$sql.= " GROUP BY cs.rowid, cs.fk_type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle"; + $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1,$offset); @@ -96,18 +81,9 @@ if ($resql) $var=true; $param=''; - if ($year) $param.='&year='.$year; - if ($typeid) $param.='&typeid='.$typeid; - - if ($year) - { - print_fiche_titre($langs->trans("SocialContributions"),($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":"")); - } - else - { - print_barre_liste($langs->trans("SocialContributions"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines); - } - + + print_fiche_titre($langs->trans("Loans")); + if (empty($mysoc->country_id) && empty($mysoc->country_code)) { print '
'; @@ -125,24 +101,16 @@ if ($resql) print ""; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"id","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"cs.libelle","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"periode","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cs.paye","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"l.label","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Capital"),$_SERVER["PHP_SELF"],"l.capital","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"l.datestart","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"l.paid","",$param,'align="right"',$sortfield,$sortorder); print "\n"; print ''; print ' '; print ''; - // Type - print ''; - $formsocialcontrib->select_type_socialcontrib($typeid,'typeid',1,16,0); - print ''; - // Period end date print ' '; - print ' '; print ' '; print ''; print ''; @@ -161,33 +129,19 @@ if ($resql) $loan->id=$obj->id; $loan->lib=$obj->id; $loan->ref=$obj->id; - print $loan->getNomUrl(1,'20'); + print $loan->getNameUrl(1,'20'); print ''; // Label - print ''.dol_trunc($obj->libelle,42).''; + print ''.dol_trunc($obj->label,42).''; - // Type - print ''.dol_trunc($obj->type_lib,16).''; + // Capital + print ''.price($obj->capital).''; - // Date end period - print ''; - if ($obj->periode) - { - print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode),'day').''; - } - else - { - print ' '; - } - print ''; + // Date start + print ''.dol_print_date($db->jdate($obj->datestart), 'day').''; - print ''.price($obj->amount).''; - - // Due date - print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''; - - print ''.$loan->LibStatut($obj->paye,5,$obj->alreadypayed).''; + print ''.$loan->LibStatut($obj->paid,5,$obj->alreadypayed).''; print ''; $i++; From 3d23319226f5b4054151ba7d59fef1d2cdb76821 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 24 Sep 2014 04:10:29 +0200 Subject: [PATCH 032/940] Update --- htdocs/compta/loan/index.php | 103 +++++++++++++---------------- htdocs/compta/prelevement/list.php | 2 +- 2 files changed, 46 insertions(+), 59 deletions(-) diff --git a/htdocs/compta/loan/index.php b/htdocs/compta/loan/index.php index 41299668dd1..16b9a10c054 100644 --- a/htdocs/compta/loan/index.php +++ b/htdocs/compta/loan/index.php @@ -72,8 +72,8 @@ if ($filtre) { $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1,$offset); - $resql=$db->query($sql); + if ($resql) { $num = $db->num_rows($resql); @@ -84,73 +84,60 @@ if ($resql) print_fiche_titre($langs->trans("Loans")); - if (empty($mysoc->country_id) && empty($mysoc->country_code)) - { - print '
'; - $langs->load("errors"); - $countrynotdefined=$langs->trans("ErrorSetACountryFirst"); - print $countrynotdefined; - print '
'; - } - else + print '
'; + + print ""; + + print ""; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"id","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"l.label","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Capital"),$_SERVER["PHP_SELF"],"l.capital","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"l.datestart","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"l.paid","",$param,'align="right"',$sortfield,$sortorder); + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + while ($i < min($num,$limit)) { + $obj = $db->fetch_object($resql); - print ''; + $var = !$var; + print ""; - print "
   '; + print ''; + print '
"; - - print ""; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"id","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"l.label","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Capital"),$_SERVER["PHP_SELF"],"l.capital","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"l.datestart","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"l.paid","",$param,'align="right"',$sortfield,$sortorder); - print "\n"; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); + // Label + print ''; - $var = !$var; - print ""; + // Capital + print ''; - // Ref - print ''; + // Date start + print ''; - // Label - print ''; + print ''; - // Capital - print ''; - - // Date start - print ''; - - print ''; - - print ''; - $i++; - } - - print '
   '; - print ''; + // Ref + print ''; + $loan->id=$obj->id; + $loan->label=$obj->id; + $loan->ref=$obj->id; + print $loan->getNameUrl(1,'20'); print '
'.dol_trunc($obj->label,42).'
'.price($obj->capital).''; - $loan->id=$obj->id; - $loan->lib=$obj->id; - $loan->ref=$obj->id; - print $loan->getNameUrl(1,'20'); - print ''.dol_print_date($db->jdate($obj->datestart), 'day').''.dol_trunc($obj->label,42).''.$loan->LibStatut($obj->paid,5,$obj->alreadypayed).''.price($obj->capital).''.dol_print_date($db->jdate($obj->datestart), 'day').''.$loan->LibStatut($obj->paid,5,$obj->alreadypayed).'
'; - - print '
'; + print ''; + $i++; } + + print ''; + print ''; } else { diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 819d879b098..0608ea70431 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -120,7 +120,7 @@ if ($result) print ' '; print ''; - print '
'; + print ''; print ''; print ''; print ''; From d3252d1348cb736fe4cd4e809f313f9f30f76d82 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 29 Sep 2014 20:37:51 +0200 Subject: [PATCH 033/940] Update --- htdocs/compta/loan/card.php | 86 +++-- htdocs/compta/loan/class/loan.class.php | 76 +--- .../compta/loan/class/paymentloan.class.php | 168 +++------ htdocs/compta/loan/index.php | 48 ++- htdocs/compta/loan/payment.php | 331 ++++++++++++++++++ .../install/mysql/migration/3.6.0-3.7.0.sql | 42 +++ htdocs/install/mysql/tables/llx_loan.sql | 2 + 7 files changed, 498 insertions(+), 255 deletions(-) create mode 100644 htdocs/compta/loan/payment.php diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index 6b075e3d758..b3e31324cb0 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -367,42 +367,6 @@ if ($id > 0) dol_fiche_end(); - - /* - * Boutons actions - */ - if ($action != 'edit') - { - print "
\n"; - - // Edit - if ($user->rights->loan->write) - { - print "id&action=edit\">".$langs->trans("Modify").""; - } - - // Emettre paiement - if ($object->paye == 0 && ((price2num($object->amount) < 0 && round($resteapayer) < 0) || (price2num($object->amount) > 0 && round($resteapayer) > 0)) && $user->rights->loan->write) - { - print "id&action=create\">".$langs->trans("DoPayment").""; - } - - // Classify 'paid' - if ($object->paye == 0 && round($resteapayer) <=0 && $user->rights->loan->write) - { - print "id&action=paid\">".$langs->trans("ClassifyPaid").""; - } - - // Delete - if ($user->rights->loan->delete) - { - print "id&action=delete\">".$langs->trans("Delete").""; - } - - print "
"; - } - - print '
'; print ''; print ''; + print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print '\n"; - print "\n"; + print "\n"; print '\n"; print ""; - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } - if ($object->paye == 0) + if ($object->paid == 0) { - print "\n"; - print "\n"; + print "\n"; + print "\n"; - $resteapayer = $object->amount - $totalpaye; + $staytopay = $object->capital - $totalpaid; print ""; - print "\n"; + print "\n"; } print "
'; @@ -441,24 +405,24 @@ if ($id > 0) $objp = $db->fetch_object($resql); $var=!$var; print "
"; - print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$objp->paiement_type.' '.$objp->num_paiement."".$objp->paiement_type.' '.$objp->num_payment."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaye)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaid)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->capital)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("RemainderToPay")." :".price($resteapayer)." ".$langs->trans("Currency".$conf->currency)."
".price($staytopay)." ".$langs->trans("Currency".$conf->currency)."
"; $db->free($resql); @@ -469,6 +433,40 @@ if ($id > 0) } print ""; print ""; + + /* + * Boutons actions + */ + if ($action != 'edit') + { + print "
\n"; + + // Edit + if ($user->rights->loan->write) + { + print "id&action=edit\">".$langs->trans("Modify").""; + } + + // Emit payment + if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) + { + print "id&action=create\">".$langs->trans("DoPayment").""; + } + + // Classify 'paid' + if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) + { + print "rowid&action=paid\">".$langs->trans("ClassifyPaid").""; + } + + // Delete + if ($user->rights->loan->delete) + { + print "id&action=delete\">".$langs->trans("Delete").""; + } + + print "
"; + } } else { diff --git a/htdocs/compta/loan/class/loan.class.php b/htdocs/compta/loan/class/loan.class.php index afd15ced451..a0cbf9a8224 100644 --- a/htdocs/compta/loan/class/loan.class.php +++ b/htdocs/compta/loan/class/loan.class.php @@ -33,6 +33,7 @@ class Loan extends CommonObject public $table_element='loan'; var $id; + var $rowid; var $ref; var $datestart; var $dateend; @@ -41,6 +42,7 @@ class Loan extends CommonObject var $nbterm; var $rate; var $note; + var $paid; var $account_capital; var $account_insurance; var $account_interest; @@ -71,7 +73,8 @@ class Loan extends CommonObject */ function fetch($id) { - $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note"; + $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note,"; + $sql.= " l.paid"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; $sql.= " WHERE l.rowid = ".$id; @@ -92,6 +95,7 @@ class Loan extends CommonObject $this->nbterm = $obj->nbterm; $this->rate = $obj->rate; $this->note = $obj->note; + $this->paid = $obj->paid; return 1; } @@ -220,7 +224,7 @@ class Loan extends CommonObject // Delete payments if (! $error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge where fk_charge='".$this->id."'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan='".$this->id."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) @@ -232,7 +236,7 @@ class Loan extends CommonObject if (! $error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales where rowid='".$this->id."'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid='".$this->id."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) @@ -266,10 +270,10 @@ class Loan extends CommonObject { $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; - $sql.= " SET libelle='".$this->db->escape($this->lib)."',"; - $sql.= " date_ech='".$this->db->idate($this->date_ech)."',"; - $sql.= " periode='".$this->db->idate($this->periode)."'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."loan"; + $sql.= " SET label='".$this->db->escape($this->label)."',"; + $sql.= " datestart='".$this->db->idate($this->datestart)."',"; + $sql.= " dateend='".$this->db->idate($this->dateend)."'"; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -288,57 +292,15 @@ class Loan extends CommonObject } /** - * Enter description here ... - * - * @param int $year Year - * @return number - */ - function solde($year = 0) - { - global $conf; - - $sql = "SELECT SUM(f.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; - $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND paye = 0"; - - if ($year) { - $sql .= " AND f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' "; - } - - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - return $obj->amount; - } - else - { - return 0; - } - - $this->db->free($result); - - } - else - { - print $this->db->error(); - return -1; - } - } - - /** - * Tag social contribution as payed completely + * Tag loan as payed completely * * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ function set_paid($user) { - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql.= " paye = 1"; + $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; + $sql.= " paid = 1"; $sql.= " WHERE rowid = ".$this->id; $return = $this->db->query($sql); if ($return) return 1; @@ -346,22 +308,22 @@ class Loan extends CommonObject } /** - * Retourne le libelle du statut d'une charge (impaye, payee) + * Return label of loan status (unpaid, paid) * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @param int $mode 0=label, 1=short label, 2=Picto + Short label, 3=Picto, 4=Picto + Label * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ function getLibStatut($mode=0,$alreadypaid=-1) { - return $this->LibStatut($this->paye,$mode,$alreadypaid); + return $this->LibStatut($this->paid,$mode,$alreadypaid); } /** * Return label for given status * * @param int $statut Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=Label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Label, 5=Short label + Picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ @@ -425,7 +387,7 @@ class Loan extends CommonObject if (empty($this->ref)) $this->ref=$this->label; - $link = ''; + $link = ''; $linkend=''; if ($withpicto) $result.=($link.img_object($langs->trans("ShowLoan").': '.$this->label,'bill').$linkend.' '); diff --git a/htdocs/compta/loan/class/paymentloan.class.php b/htdocs/compta/loan/class/paymentloan.class.php index 24d59fb417b..c0cdb3cdb85 100644 --- a/htdocs/compta/loan/class/paymentloan.class.php +++ b/htdocs/compta/loan/class/paymentloan.class.php @@ -1,6 +1,5 @@ - * Copyright (C) 2004-2007 Laurent Destailleur +/* Copyright (C) 2014 Alexandre Spangaro * * 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 +16,9 @@ */ /** - * \file htdocs/compta/sociales/class/paymentsocialcontribution.class.php + * \file htdocs/compta/loan/class/paymentloan.class.php * \ingroup facture - * \brief File of class to manage payment of social contributions + * \brief File of class to manage payment of loans */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; @@ -36,7 +35,7 @@ class PaymentLoan extends CommonObject var $id; var $ref; - var $fk_charge; + var $fk_loan; var $datec=''; var $tms=''; var $datep=''; @@ -74,18 +73,18 @@ class PaymentLoan extends CommonObject $now=dol_now(); - // Validate parametres - if (! $this->datepaye) + // Validate parameters + if (! $this->datepaid) { $this->error='ErrorBadValueForParameter'; return -1; } // Clean parameters - if (isset($this->fk_charge)) $this->fk_charge=trim($this->fk_charge); + if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan); if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement=trim($this->fk_typepaiement); - if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); + if (isset($this->fk_typepayment)) $this->fk_typepaiement=trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note)) $this->note=trim($this->note); if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); @@ -101,26 +100,26 @@ class PaymentLoan extends CommonObject $totalamount = price2num($totalamount); // Check parameters - if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null $this->db->begin(); if ($totalamount != 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,"; - $sql.= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_loan (fk_loan, datec, datep, amount,"; + $sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->idate($this->datepaye)."',"; + $sql.= " '".$this->db->idate($this->datepaid)."',"; $sql.= " ".$totalamount.","; - $sql.= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.","; $sql.= " 0)"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan"); } else { @@ -155,22 +154,22 @@ class PaymentLoan extends CommonObject global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; - $sql.= " t.fk_charge,"; + $sql.= " t.fk_loan,"; $sql.= " t.datec,"; $sql.= " t.tms,"; $sql.= " t.datep,"; $sql.= " t.amount,"; - $sql.= " t.fk_typepaiement,"; - $sql.= " t.num_paiement,"; + $sql.= " t.fk_typepayment,"; + $sql.= " t.num_payment,"; $sql.= " t.note,"; $sql.= " t.fk_bank,"; $sql.= " t.fk_user_creat,"; $sql.= " t.fk_user_modif,"; $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; $sql.= ' b.fk_account'; - $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."paiementcharge as t)"; + $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_loan as t)"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; - $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepaiement = pt.id"; + $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); @@ -183,13 +182,13 @@ class PaymentLoan extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; - $this->fk_charge = $obj->fk_charge; + $this->fk_loan = $obj->fk_loan; $this->datec = $this->db->jdate($obj->datec); $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); $this->amount = $obj->amount; - $this->fk_typepaiement = $obj->fk_typepaiement; - $this->num_paiement = $obj->num_paiement; + $this->fk_typepayment = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; $this->note = $obj->note; $this->fk_bank = $obj->fk_bank; $this->fk_user_creat = $obj->fk_user_creat; @@ -227,36 +226,33 @@ class PaymentLoan extends CommonObject // Clean parameters - if (isset($this->fk_charge)) $this->fk_charge=trim($this->fk_charge); + if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan); if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement=trim($this->fk_typepaiement); - if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); + if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note)) $this->note=trim($this->note); if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); - - // Check parameters // Put here code to add control on parameters values // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET"; - $sql.= " fk_charge=".(isset($this->fk_charge)?$this->fk_charge:"null").","; + $sql.= " fk_loan=".(isset($this->fk_loan)?$this->fk_loan:"null").","; $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; - $sql.= " fk_typepaiement=".(isset($this->fk_typepaiement)?$this->fk_typepaiement:"null").","; - $sql.= " num_paiement=".(isset($this->num_paiement)?"'".$this->db->escape($this->num_paiement)."'":"null").","; + $sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").","; + $sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").","; $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; - $sql.= " WHERE rowid=".$this->id; $this->db->begin(); @@ -317,7 +313,7 @@ class PaymentLoan extends CommonObject if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql.= " WHERE type='payment_sc' AND url_id=".$this->id; + $sql.= " WHERE type='payment_loan' AND url_id=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); @@ -326,7 +322,7 @@ class PaymentLoan extends CommonObject if (! $error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan"; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); @@ -368,96 +364,12 @@ class PaymentLoan extends CommonObject } } - - - /** - * Load an object from its id and create a new one in database - * - * @param int $fromid Id of object to clone - * @return int New id of clone - */ - function createFromClone($fromid) - { - global $user,$langs; - - $error=0; - - $object=new PaymentSocialContribution($this->db); - - $this->db->begin(); - - // Load source object - $object->fetch($fromid); - $object->id=0; - $object->statut=0; - - // Clear fields - // ... - - // Create clone - $result=$object->create($user); - - // Other options - if ($result < 0) - { - $this->error=$object->error; - $error++; - } - - if (! $error) - { - - - - } - - // End - if (! $error) - { - $this->db->commit(); - return $object->id; - } - else - { - $this->db->rollback(); - return -1; - } - } - - - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - function initAsSpecimen() - { - $this->id=0; - - $this->fk_charge=''; - $this->datec=''; - $this->tms=''; - $this->datep=''; - $this->amount=''; - $this->fk_typepaiement=''; - $this->num_paiement=''; - $this->note=''; - $this->fk_bank=''; - $this->fk_user_creat=''; - $this->fk_user_modif=''; - - - } - - /** * Add record into bank for payment with links between this bank record and invoices of payment. * All payment properties must have been set first like after a call to create(). * * @param User $user Object of user making payment - * @param string $mode 'payment_sc' + * @param string $mode 'payment_loan' * @param string $label Label to use in bank record * @param int $accountid Id of bank account to do link with * @param string $emetteur_nom Name of transmitter @@ -482,11 +394,11 @@ class PaymentLoan extends CommonObject // Insert payment into llx_bank $bank_line_id = $acc->addline( - $this->datepaye, - $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") + $this->datepaid, + $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") $label, $total, - $this->num_paiement, + $this->num_payment, '', $user, $emetteur_nom, @@ -506,10 +418,10 @@ class PaymentLoan extends CommonObject // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction $url=''; - if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='; + if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/compta/loan/payment/card.php?id='; if ($url) { - $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode); if ($result <= 0) { $error++; @@ -578,7 +490,7 @@ class PaymentLoan extends CommonObject * @param int $maxlen Longueur max libelle * @return string Chaine avec URL */ - function getNomUrl($withpicto=0,$maxlen=0) + function getNameUrl($withpicto=0,$maxlen=0) { global $langs; @@ -588,7 +500,7 @@ class PaymentLoan extends CommonObject if (!empty($this->id)) { - $lien = ''; + $lien = ''; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$lienfin.' '); diff --git a/htdocs/compta/loan/index.php b/htdocs/compta/loan/index.php index 16b9a10c054..8bef47ff66e 100644 --- a/htdocs/compta/loan/index.php +++ b/htdocs/compta/loan/index.php @@ -41,17 +41,17 @@ if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$limit = $conf->liste_limit; if (! $sortfield) $sortfield="l.rowid"; if (! $sortorder) $sortorder="DESC"; +$limit = $conf->liste_limit; +$search_label=GETPOST('search_label','alpha'); $filtre=$_GET["filtre"]; /* * View */ -$form = new Form($db); $loan = new Loan($db); llxHeader(); @@ -68,34 +68,29 @@ if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; } - $sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($limit+1,$offset); +$sql.= $db->plimit($limit + 1, $offset); +//print $sql; $resql=$db->query($sql); - if ($resql) { $num = $db->num_rows($resql); - $i = 0; - $var=true; - $param=''; - print_fiche_titre($langs->trans("Loans")); - - print ''; - print ""; - - print ""; + $i = 0; + print ''."\n"; + print '
'; + print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"id","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"l.label","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Capital"),$_SERVER["PHP_SELF"],"l.capital","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"l.datestart","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"l.paid","",$param,'align="right"',$sortfield,$sortorder); - print "\n"; + print "\n"; + // Filters lines print ''; print ''; print ''; @@ -103,9 +98,9 @@ if ($resql) print ''; print ''; - print "\n"; - + print "\n"; + + $var=true; while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); @@ -115,9 +110,9 @@ if ($resql) // Ref print ''; @@ -132,18 +127,19 @@ if ($resql) print ''; - print ''; + print "\n"; + $i++; } - print '
  '; print ''; - print '
'; - $loan->id=$obj->id; - $loan->label=$obj->id; - $loan->ref=$obj->id; + $loan->id=$obj->rowid; + $loan->label=$obj->rowid; + $loan->ref=$obj->rowid; print $loan->getNameUrl(1,'20'); print ''.$loan->LibStatut($obj->paid,5,$obj->alreadypayed).'
'; - print ''; + print ""; + print "\n"; + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } - $db->close(); llxFooter(); diff --git a/htdocs/compta/loan/payment.php b/htdocs/compta/loan/payment.php new file mode 100644 index 00000000000..a513ba212cd --- /dev/null +++ b/htdocs/compta/loan/payment.php @@ -0,0 +1,331 @@ + + * + * 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/compta/loan/payment.php + * \ingroup Loan + * \brief Page to add payment of a loan + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/paymentloan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +$langs->load("bills"); + +$chid=GETPOST("id"); +$action=GETPOST('action'); +$amounts = array(); + +// Security check +$socid=0; +if ($user->societe_id > 0) +{ + $socid = $user->societe_id; +} + +/* + * Actions + */ + +if ($action == 'add_payment') +{ + $error=0; + + if ($_POST["cancel"]) + { + $loc = DOL_URL_ROOT.'/compta/loan/card.php?id='.$chid; + header("Location: ".$loc); + exit; + } + + $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + + if (! $_POST["paymenttype"] > 0) + { + $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); + $error++; + } + if ($datepaid == '') + { + $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")); + $error++; + } + if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0) + { + $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit")); + $error++; + } + + if (! $error) + { + $paymentid = 0; + + // Read possible payments + foreach ($_POST as $key => $value) + { + if (substr($key,0,7) == 'amount_') + { + $other_chid = substr($key,7); + $amounts[$other_chid] = price2num($_POST[$key]); + } + } + + if (count($amounts) <= 0) + { + $error++; + $errmsg='ErrorNoPaymentDefined'; + } + + if (! $error) + { + $db->begin(); + + // Create a line of payments + $paiement = new PaymentSocialContribution($db); + $paiement->chid = $chid; + $paiement->datepaid = $datepaid; + $paiement->amounts = $amounts; // Tableau de montant + $paiement->paymenttype = $_POST["paymenttype"]; + $paiement->num_payment = $_POST["num_payment"]; + $paiement->note = $_POST["note"]; + + if (! $error) + { + $paymentid = $payment->create($user); + if ($paymentid < 0) + { + $errmsg=$paiement->error; + $error++; + } + } + + if (! $error) + { + $result=$paiement->addPaymentToBank($user,'payment_sc','(SocialContributionPayment)',$_POST['accountid'],'',''); + if (! $result > 0) + { + $errmsg=$paiement->error; + $error++; + } + } + + if (! $error) + { + $db->commit(); + $loc = DOL_URL_ROOT.'/compta/loan/card.php?id='.$chid; + header('Location: '.$loc); + exit; + } + else + { + $db->rollback(); + } + } + } + + $_GET["action"]='create'; +} + + +/* + * View + */ + +llxHeader(); + +$form=new Form($db); + + +// Form to create loan's payment +if ($_GET["action"] == 'create') +{ + + $loan = new Loan($db); + $loan->fetch($chid); + + $total = $loan->capital; + + print_fiche_titre($langs->trans("DoPayment")); + print "
\n"; + + if ($mesg) + { + print "
$mesg
"; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ""; + + print ''; + print '\n"; + print '\n"; + print ''; + + $sql = "SELECT sum(p.amount) as total"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; + $sql.= " WHERE p.fk_loan = ".$chid; + $resql = $db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + $sumpaid = $obj->total; + $db->free(); + } + print ''; + print ''; + print ''; + + print '
".$langs->trans("Loan")."
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Period")."".dol_print_date($loan->datestart,'day')."
'.$langs->trans("Label").''.$loan->label."
'.$langs->trans("Amount")."".price($loan->capital,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'; + + print '
'; + + print ''; + print ''; + print "'; + print ''; + + print '"; + print ''; + + print '\n"; + print ''; + + print ''; + print ''; + print ''; + + // Number + print ''; + print ''."\n"; + + print ''; + print ''; + print ''; + print ''; + + print '
".$langs->trans("Payment").'
'.$langs->trans("Date").''; + $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0; + $form->select_date($datepayment,'','','','',"add_payment",1,1); + print "
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(isset($_POST["paymenttype"])?$_POST["paymenttype"]:$loan->paymenttype, "paymenttype"); + print "
'.$langs->trans('AccountToDebit').''; + $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '',1); // Show opend bank account list + print '
'.$langs->trans('Number'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans("Comments").'
'; + + print '
'; + + /* + * Autres charges impayees + */ + $num = 1; + $i = 0; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=True; + $total=0; + $totalrecu=0; + + while ($i < $num) + { + $objp = $loan; + + $var=!$var; + + print ""; + + if ($objp->datestart > 0) + { + print "\n"; + } + else + { + print "\n"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print "\n"; + $total+=$objp->total; + $total_ttc+=$objp->total_ttc; + $totalrecu+=$objp->am; + $i++; + } + if ($i > 1) + { + // Print total + print ""; + print ''; + print ""; + print ""; + print ""; + print ''; + print "\n"; + } + + print "
'.$langs->trans("DateDue").''.$langs->trans("Amount").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").'
".dol_print_date($objp->datestart,'day')."!!!'.price($objp->capital)."'.price($sumpaid)."'.price($objp->capital - $sumpaid)."'; + if ($sumpaid < $objp->capital) + { + $namef = "amount_".$objp->id; + print ''; + } + else + { + print '-'; + } + print "
'.$langs->trans("Total").':".price($total_ttc)."".price($totalrecu)."".price($total_ttc - $totalrecu)." 
"; + + print '
'; + + print ''; + print '   '; + print ''; + + print '
'; + + print "
\n"; +} + + +$db->close(); + +llxFooter(); 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 9e109cd311f..5bffbc0e5be 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -1083,3 +1083,45 @@ CREATE TABLE llx_usergroup_extrafields ( ) ENGINE=innodb; ALTER TABLE llx_usergroup_extrafields ADD INDEX idx_usergroup_extrafields (fk_object); + +-- Loan +create table llx_loan +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, + datec datetime, + tms timestamp, + label varchar(80) NOT NULL, + fk_bank integer, + capital real default 0 NOT NULL, + datestart date, + dateend date, + nbterm real, + rate double NOT NULL, + note text, + capital_position real default 0, + date_position date, + paid smallint default 0 NOT NULL, + accountancy_account_capital varchar(32), + accountancy_account_insurance varchar(32), + accountancy_account_interest varchar(32), + fk_user_author integer DEFAULT NULL, + fk_user_modif integer DEFAULT NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; + +create table llx_payment_loan +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_loan integer, + datec datetime, + tms timestamp, + datep datetime, + amount real DEFAULT 0, + fk_typepayment integer NOT NULL, + num_payment varchar(50), + note text, + fk_bank integer NOT NULL, + fk_user_creat integer, + fk_user_modif integer +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_loan.sql b/htdocs/install/mysql/tables/llx_loan.sql index 2ca026ba417..bc152099a04 100644 --- a/htdocs/install/mysql/tables/llx_loan.sql +++ b/htdocs/install/mysql/tables/llx_loan.sql @@ -37,6 +37,8 @@ create table llx_loan capital_position real default 0, -- If not a new loan, just have the position of capital date_position date, + paid smallint default 0 NOT NULL, + accountancy_account_capital varchar(32), accountancy_account_insurance varchar(32), accountancy_account_interest varchar(32), From 3627f157d2d208882366ddd7615ed5eb0b2f525c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 1 Oct 2014 07:16:29 +0200 Subject: [PATCH 034/940] Add langs & debug --- htdocs/compta/bank/account.php | 24 ++ htdocs/compta/loan/card.php | 25 +- htdocs/compta/loan/class/loan.class.php | 14 +- .../compta/loan/class/paymentloan.class.php | 62 ++-- htdocs/compta/loan/document.php | 4 +- htdocs/compta/loan/index.php | 4 +- htdocs/compta/loan/payment/card.php | 308 ++++++++++++++++++ htdocs/compta/loan/payment/index.html | 0 htdocs/compta/loan/{ => payment}/payment.php | 32 +- htdocs/langs/en_US/admin.lang | 6 + htdocs/langs/en_US/loan.lang | 15 + htdocs/langs/fr_FR/admin.lang | 6 + htdocs/langs/fr_FR/loan.lang | 15 + 13 files changed, 442 insertions(+), 73 deletions(-) create mode 100644 htdocs/compta/loan/payment/card.php create mode 100644 htdocs/compta/loan/payment/index.html rename htdocs/compta/loan/{ => payment}/payment.php (89%) create mode 100644 htdocs/langs/en_US/loan.lang create mode 100644 htdocs/langs/fr_FR/loan.lang diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 14b586c6d80..57329e9e93b 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php' require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -44,6 +45,7 @@ $langs->load("banks"); $langs->load("categories"); $langs->load("bills"); $langs->load("companies"); +$langs->load("loan"); $id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int')); $ref = GETPOST('ref','alpha'); @@ -148,6 +150,7 @@ llxHeader(); $societestatic=new Societe($db); $userstatic=new User($db); $chargestatic=new ChargeSociales($db); +$loanstatic=new Loan($db); $memberstatic=new Adherent($db); $paymentstatic=new Paiement($db); $paymentsupplierstatic=new PaiementFourn($db); @@ -606,6 +609,12 @@ if ($id > 0 || ! empty($ref)) $paymentsalstatic->ref=$links[$key]['url_id']; print ' '.$paymentsalstatic->getNomUrl(2); } + elseif ($links[$key]['type']=='payment_loan') + { + print ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print ''; + } elseif ($links[$key]['type']=='banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. @@ -705,6 +714,21 @@ if ($id > 0 || ! empty($ref)) $chargestatic->ref=$chargestatic->lib; print $chargestatic->getNomUrl(1,16); } + else if ($links[$key]['type']=='loan') + { + $loanstatic->id=$links[$key]['url_id']; + if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) + { + if ($reg[1]=='loan') $reg[1]='Loan'; + $loanstatic->label=$langs->trans($reg[1]); + } + else + { + $loanstatic->label=$links[$key]['label']; + } + $loanstatic->ref=$loanstatic->label; + print $loanstatic->getNameUrl(1,16); + } else if ($links[$key]['type']=='member') { $memberstatic->id=$links[$key]['url_id']; diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index b3e31324cb0..d2dc5362915 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -116,16 +116,16 @@ if ($action == 'add' && $user->rights->loan->write) if ($action == 'update' && ! $_POST["cancel"] && $user->rights->loan->write) { - $dateech=dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]); - $dateperiod=dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]); - if (! $dateech) + $datestart=dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); + $dateend=dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + if (! $datestart) { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")), 'errors'); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors'); $action = 'edit'; } - elseif (! $dateperiod) + elseif (! $dateend) { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")), 'errors'); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateEnd")), 'errors'); $action = 'edit'; } else @@ -298,7 +298,7 @@ if ($id > 0) print ''; // Ref - print '"; @@ -360,10 +360,9 @@ if ($id > 0) print ''; print '   '; print ''; - print '\n"; + print ''; + print ''; + } dol_fiche_end(); @@ -450,13 +449,13 @@ if ($id > 0) // Emit payment if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) { - print "id&action=create\">".$langs->trans("DoPayment").""; + print "id&action=create\">".$langs->trans("DoPayment").""; } // Classify 'paid' if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) { - print "rowid&action=paid\">".$langs->trans("ClassifyPaid").""; + print "id&action=paid\">".$langs->trans("ClassifyPaid").""; } // Delete diff --git a/htdocs/compta/loan/class/loan.class.php b/htdocs/compta/loan/class/loan.class.php index a0cbf9a8224..07b842b708e 100644 --- a/htdocs/compta/loan/class/loan.class.php +++ b/htdocs/compta/loan/class/loan.class.php @@ -87,7 +87,7 @@ class Loan extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->ref = $obj->rowid; $this->datestart = $this->db->jdate($obj->datestart); $this->dateend = $this->db->jdate($obj->dateend); $this->label = $obj->label; @@ -114,7 +114,7 @@ class Loan extends CommonObject /** - * Create a social contribution into database + * Create a loan into database * * @param User $user User making creation * @return int <0 if KO, id if OK @@ -201,10 +201,10 @@ class Loan extends CommonObject $this->db->begin(); - // Get bank transaction lines for this social contributions + // Get bank transaction lines for this loan include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $account=new Account($this->db); - $lines_url=$account->get_url('',$this->id,'sc'); + $lines_url=$account->get_url('',$this->id,'loan'); // Delete bank urls foreach ($lines_url as $line_url) @@ -385,14 +385,12 @@ class Loan extends CommonObject $result=''; - if (empty($this->ref)) $this->ref=$this->label; - - $link = ''; + $link = ''; $linkend=''; if ($withpicto) $result.=($link.img_object($langs->trans("ShowLoan").': '.$this->label,'bill').$linkend.' '); if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend; + if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend; return $result; } diff --git a/htdocs/compta/loan/class/paymentloan.class.php b/htdocs/compta/loan/class/paymentloan.class.php index c0cdb3cdb85..0a558fc9bf4 100644 --- a/htdocs/compta/loan/class/paymentloan.class.php +++ b/htdocs/compta/loan/class/paymentloan.class.php @@ -24,8 +24,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -/** \class PaymentSocialContribution - * \brief Class to manage payments of social contributions +/** \class PaymentLoan + * \brief Class to manage payments of loans */ class PaymentLoan extends CommonObject { @@ -41,8 +41,8 @@ class PaymentLoan extends CommonObject var $datep=''; var $amount; // Total amount of payment var $amounts=array(); // Array of amounts - var $fk_typepaiement; - var $num_paiement; + var $fk_typepayment; + var $num_payment; var $note; var $fk_bank; var $fk_user_creat; @@ -59,7 +59,7 @@ class PaymentLoan extends CommonObject } /** - * Create payment of social contribution into database. + * Create payment of loan into database. * Use this->amounts to have list of lines for the payment * * @param User $user User making payment @@ -81,14 +81,14 @@ class PaymentLoan extends CommonObject } // Clean parameters - if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan); - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepayment)) $this->fk_typepaiement=trim($this->fk_typepayment); - if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); - if (isset($this->note)) $this->note=trim($this->note); - if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); - if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); - if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + if (isset($this->fk_loan)) $this->fk_loan = trim($this->fk_loan); + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat = trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif = trim($this->fk_user_modif); $totalamount = 0; foreach ($this->amounts as $key => $value) // How payment is dispatch @@ -390,7 +390,7 @@ class PaymentLoan extends CommonObject $acc->fetch($accountid); $total=$this->total; - if ($mode == 'payment_sc') $total=-$total; + if ($mode == 'payment_loan') $total=-$total; // Insert payment into llx_bank $bank_line_id = $acc->addline( @@ -405,8 +405,8 @@ class PaymentLoan extends CommonObject $emetteur_banque ); - // Mise a jour fk_bank dans llx_paiement. - // On connait ainsi le paiement qui a genere l'ecriture bancaire + // Update fk_bank into llx_paiement. + // We know the payment who generated the account write if ($bank_line_id > 0) { $result=$this->update_fk_bank($bank_line_id); @@ -416,7 +416,7 @@ class PaymentLoan extends CommonObject dol_print_error($this->db); } - // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction + // Add link 'payment_loan' in bank_url between payment and bank transaction $url=''; if ($mode == 'payment_loan') $url=DOL_URL_ROOT.'/compta/loan/payment/card.php?id='; if ($url) @@ -433,11 +433,11 @@ class PaymentLoan extends CommonObject $linkaddedforthirdparty=array(); foreach ($this->amounts as $key => $value) { - if ($mode == 'payment_sc') + if ($mode == 'payment_loan') { - $socialcontrib = new ChargeSociales($this->db); - $socialcontrib->fetch($key); - $result=$acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''),'sc'); + $loan = new Loan($this->db); + $loan->fetch($key); + $result=$acc->add_url_line($bank_line_id, $loan->id, DOL_URL_ROOT.'/compta/loan/card.php?id=', $loan->type_libelle.(($loan->lib && $loan->lib!=$loan->type_libelle)?' ('.$loan->lib.')':''),'loan'); if ($result <= 0) dol_print_error($this->db); } } @@ -461,14 +461,14 @@ class PaymentLoan extends CommonObject /** - * Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee + * Update link between loan's payment and the line generate in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ function update_fk_bank($id_bank) { - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); @@ -484,11 +484,11 @@ class PaymentLoan extends CommonObject } /** - * Renvoie nom clicable (avec eventuellement le picto) + * Return clicable name (with eventually a picto) * - * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - * @param int $maxlen Longueur max libelle - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=No picto + * @param int $maxlen Max length label + * @return string Chaine with URL */ function getNameUrl($withpicto=0,$maxlen=0) { @@ -500,12 +500,12 @@ class PaymentLoan extends CommonObject if (!empty($this->id)) { - $lien = ''; - $lienfin=''; + $link = ''; + $linkend=''; - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$lienfin.' '); + if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment").': '.$this->ref,'payment').$linkend.' '); if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin; + if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend; } return $result; diff --git a/htdocs/compta/loan/document.php b/htdocs/compta/loan/document.php index 022340270ad..b263fa1687d 100644 --- a/htdocs/compta/loan/document.php +++ b/htdocs/compta/loan/document.php @@ -119,7 +119,7 @@ if ($object->id) print ''; // Date start - print ""; + print ""; print ""; // Date end - print ""; + print ""; print "'; diff --git a/htdocs/compta/loan/payment/card.php b/htdocs/compta/loan/payment/card.php new file mode 100644 index 00000000000..d08c5f8ce0f --- /dev/null +++ b/htdocs/compta/loan/payment/card.php @@ -0,0 +1,308 @@ + + * + * 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/compta/loan/payment/card.php + * \ingroup loan + * \brief Payment's card of loan + */ + +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/paymentloan.class.php'; +// require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +// require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; +if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +$langs->load('bills'); +$langs->load('banks'); +$langs->load('companies'); +$langs->load('loan'); + +// Security check +$id=GETPOST("id"); +$action=GETPOST("action"); +$confirm=GETPOST('confirm'); +if ($user->societe_id) $socid=$user->societe_id; +// TODO ajouter regle pour restreindre acces paiement +//$result = restrictedArea($user, 'facture', $id,''); + +$payment = new PaymentLoan($db); +if ($id > 0) +{ + $result=$payment->fetch($id); + if (! $result) dol_print_error($db,'Failed to get payment id '.$id); +} + + +/* + * Actions + */ + +// Delete payment +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) +{ + $db->begin(); + + $result = $payment->delete($user); + if ($result > 0) + { + $db->commit(); + header("Location: ".DOL_URL_ROOT."/compta/loan/index.php"); + exit; + } + else + { + setEventMessage($payment->error, 'errors'); + $db->rollback(); + } +} + +// Create payment +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->loan->write) +{ + $db->begin(); + + $result=$payment->valide(); + + if ($result > 0) + { + $db->commit(); + + $factures=array(); // TODO Get all id of invoices linked to this payment + foreach($factures as $id) + { + $fac = new Facture($db); + $fac->fetch($id); + + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $fac->generateDocument($fac->modelpdf, $outputlangs); + } + } + + header('Location: card.php?id='.$payment->id); + exit; + } + else + { + setEventMessage($payment->error); + $db->rollback(); + } +} + + +/* + * View + */ + +llxHeader(); + +$loan = new Loan($db); + +$form = new Form($db); + +$h=0; + +$head[$h][0] = DOL_URL_ROOT.'/compta/loan/payment/card.php?id='.$_GET["id"]; +$head[$h][1] = $langs->trans("Card"); +$hselected = $h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), 0, 'payment'); + +/* + * Confirm deletion of the payment + */ +if ($action == 'delete') +{ + print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2); + +} + +/* + * Confirm validation of the payment + */ +if ($action == 'valide') +{ + $facid = $_GET['facid']; + print $form->formconfirm('card.php?id='.$payment->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); + +} + + +print '
'.$langs->trans("Ref").''; + print '
'.$langs->trans("Ref").''; print $form->showrefnav($object,'id'); print "
'.$langs->trans("Capital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'
".$langs->trans("Datestart")."
".$langs->trans("DateStart").""; if ($action == 'edit') { @@ -133,7 +133,7 @@ if ($object->id) print "
".$langs->trans("Dateend")."
".$langs->trans("DateEnd").""; if ($action == 'edit') { diff --git a/htdocs/compta/loan/index.php b/htdocs/compta/loan/index.php index 8bef47ff66e..a4432ba9ced 100644 --- a/htdocs/compta/loan/index.php +++ b/htdocs/compta/loan/index.php @@ -110,9 +110,7 @@ if ($resql) // Ref print ''; - $loan->id=$obj->rowid; - $loan->label=$obj->rowid; - $loan->ref=$obj->rowid; + $loan->id = $obj->id; print $loan->getNameUrl(1,'20'); print '
'; + +// Ref +print ''; +print ''; + +// Date +print ''; + +// Mode +print ''; + +// Number +print ''; + +// Amount +print ''; + +// Note +print ''; + +// Bank account +if (! empty($conf->banque->enabled)) +{ + if ($payment->bank_account) + { + $bankline=new AccountLine($db); + $bankline->fetch($payment->bank_line); + + print ''; + print ''; + print ''; + print ''; + } +} + +print '
'.$langs->trans('Ref').''; +print $form->showrefnav($payment,'id','',1,'rowid','id'); +print '
'.$langs->trans('Date').''.dol_print_date($payment->datep,'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$payment->type_code).'
'.$langs->trans('Number').''.$payment->num_payment.'
'.$langs->trans('Amount').''.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($payment->note).'
'.$langs->trans('BankTransactionLine').''; + print $bankline->getNomUrl(1,0,'showall'); + print '
'; + + +/* + * List of loans payed + */ + +$disable_delete = 0; +$sql = 'SELECT l.rowid as id, l.label, l.paid, l.capital as capital, pl.amount'; +$sql.= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl,'.MAIN_DB_PREFIX.'loan as l'; +$sql.= ' WHERE pl.fk_loan = l.rowid'; +$sql.= ' AND l.entity = '.$conf->entity; +$sql.= ' AND pl.rowid = '.$payment->id; + +dol_syslog("compta/loan/payment/card.php", LOG_DEBUG); +$resql=$db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + + $i = 0; + $total = 0; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + if ($num > 0) + { + $var=True; + + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $var=!$var; + print ''; + // Ref + print '\n"; + // Label + print ''; + // Expected to pay + print ''; + // Status + print ''; + // Amount payed + print ''; + print "\n"; + if ($objp->paye == 1) // If at least one invoice is paid, disable delete + { + $disable_delete = 1; + } + $total = $total + $objp->amount; + $i++; + } + } + $var=!$var; + + print "
'.$langs->trans('Loan').''.$langs->trans('Label').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('PayedByThisPayment').'
'; + $loan->fetch($objp->id); + print $loan->getNameUrl(1); + print "'.$objp->label.''.price($objp->capital).''.$loan->getLibStatut(4,$objp->amount).''.price($objp->amount).'
\n"; + $db->free($resql); +} +else +{ + dol_print_error($db); +} + +print '
'; + + +/* + * Boutons Actions + */ +print '
'; + +/* +if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) +{ + if ($user->societe_id == 0 && $payment->statut == 0 && $_GET['action'] == '') + { + if ($user->rights->facture->paiement) + { + print ''.$langs->trans('Valid').''; + } + } +} +*/ + +if ($_GET['action'] == '') +{ + if ($user->rights->loan->delete) + { + if (! $disable_delete) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').''; + } + } +} + +print '
'; + + + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/loan/payment/index.html b/htdocs/compta/loan/payment/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/compta/loan/payment.php b/htdocs/compta/loan/payment/payment.php similarity index 89% rename from htdocs/compta/loan/payment.php rename to htdocs/compta/loan/payment/payment.php index a513ba212cd..ed249d8f246 100644 --- a/htdocs/compta/loan/payment.php +++ b/htdocs/compta/loan/payment/payment.php @@ -21,12 +21,13 @@ * \brief Page to add payment of a loan */ -require '../../main.inc.php'; +require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/paymentloan.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("bills"); +$langs->load("loan"); $chid=GETPOST("id"); $action=GETPOST('action'); @@ -42,7 +43,6 @@ if ($user->societe_id > 0) /* * Actions */ - if ($action == 'add_payment') { $error=0; @@ -97,30 +97,30 @@ if ($action == 'add_payment') $db->begin(); // Create a line of payments - $paiement = new PaymentSocialContribution($db); - $paiement->chid = $chid; - $paiement->datepaid = $datepaid; - $paiement->amounts = $amounts; // Tableau de montant - $paiement->paymenttype = $_POST["paymenttype"]; - $paiement->num_payment = $_POST["num_payment"]; - $paiement->note = $_POST["note"]; + $payment = new PaymentLoan($db); + $payment->chid = $chid; + $payment->datepaid = $datepaid; + $payment->amounts = $amounts; // Tableau de montant + $payment->paymenttype = $_POST["paymenttype"]; + $payment->num_payment = $_POST["num_payment"]; + $payment->note = $_POST["note"]; if (! $error) { $paymentid = $payment->create($user); if ($paymentid < 0) { - $errmsg=$paiement->error; + $errmsg=$payment->error; $error++; } } if (! $error) { - $result=$paiement->addPaymentToBank($user,'payment_sc','(SocialContributionPayment)',$_POST['accountid'],'',''); + $result=$payment->addPaymentToBank($user,'payment_loan','(LoanPayment)',$_POST['accountid'],'',''); if (! $result > 0) { - $errmsg=$paiement->error; + $errmsg=$payment->error; $error++; } } @@ -180,7 +180,7 @@ if ($_GET["action"] == 'create') print "".$langs->trans("Loan").""; print ''.$langs->trans("Ref").''.$chid.''; - print ''.$langs->trans("Period")."".dol_print_date($loan->datestart,'day')."\n"; + print ''.$langs->trans("DateStart")."".dol_print_date($loan->datestart,'day')."\n"; print ''.$langs->trans("Label").''.$loan->label."\n"; print ''.$langs->trans("Amount")."".price($loan->capital,0,$outputlangs,1,-1,-1,$conf->currency).''; @@ -222,14 +222,14 @@ if ($_GET["action"] == 'create') print ''; print ''.$langs->trans('AccountToDebit').''; print ''; - $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '',1); // Show opend bank account list + $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$loan->accountid, "accountid", 0, '',1); // Show opend bank account list print ''; // Number print ''.$langs->trans('Number'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print ''; - print ''."\n"; + print ''."\n"; print ''; print ''.$langs->trans("Comments").''; @@ -241,7 +241,7 @@ if ($_GET["action"] == 'create') print '
'; /* - * Autres charges impayees + * Other loan unpaid */ $num = 1; $i = 0; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index fae312ee8e8..7650b14950e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -483,6 +483,8 @@ Module500Name=Special expenses (tax, social contributions, dividends) Module500Desc=Management of special expenses like taxes, social contribution, dividends and salaries Module510Name=Salaries Module510Desc=Management of employees salaries and payments +Module520Name=Loan +Module520Desc=Management of loans Module600Name=Notifications Module600Desc=Send notifications by email on some Dolibarr business events to third party contacts Module700Name=Donations @@ -696,6 +698,10 @@ Permission510=Read Salaries Permission512=Create/modify salaries Permission514=Delete salaries Permission517=Export salaries +Permission520=Read Loans +Permission522=Create/modify loans +Permission524=Delete loans +Permission527=Export loans Permission531=Read services Permission532=Create/modify services Permission534=Delete services diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang new file mode 100644 index 00000000000..6be2f13a101 --- /dev/null +++ b/htdocs/langs/en_US/loan.lang @@ -0,0 +1,15 @@ +# Dolibarr language file - Source file is en_US - loan +Loan=Loan +Loans=Loans +NewLoan=New Loan +ShowLoan=Show Loan +PaymentLoan=Loan payment +Capital=Capital +Nbterms=Number of terms +LoanAccountancyCapitalCode=Accountancy code capital +LoanAccountancyInsuranceCode=Accountancy code insurance +LoanAccountancyInterestCode=Accountancy code interest +ConfigLoan=Configuration of the module loan +LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default +LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accountancy code interest by default +LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Accountancy code insurance by default \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 0ea2d9d51f4..d8f1e3b0c16 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -482,6 +482,8 @@ Module500Name=Dépenses spéciales (taxes, charges, dividendes) Module500Desc=Gestion des dépenses spéciales comme les taxes, charges sociales et dividendes Module510Name=Salaires Module510Desc=Gestion des paiements des salaires des employés +Module520Name=Emprunts +Module520Desc=Suivi des emprunts Module600Name=Notifications Module600Desc=Envoi de notifications (par email) aux contacts de tiers sur certains événements métiers Module700Name=Dons @@ -695,6 +697,10 @@ Permission510=Consulter les salaires Permission512=Créer/modifier les salaires Permission514=Supprimer les salaires Permission517=Exporter les salaires +Permission520=Consulter les emprunts +Permission522=Créer/modifier les emprunts +Permission524=Supprimer les emprunts +Permission527=Exporter les emprunts Permission531=Consulter les services Permission532=Créer/modifier les services Permission534=Supprimer les services diff --git a/htdocs/langs/fr_FR/loan.lang b/htdocs/langs/fr_FR/loan.lang new file mode 100644 index 00000000000..d230f7f0582 --- /dev/null +++ b/htdocs/langs/fr_FR/loan.lang @@ -0,0 +1,15 @@ +# Dolibarr language file - Source file is en_US - loan +Loan=Emprunt +Loans=Emprunts +NewLoan=Nouvel emprunt +ShowLoan=Voir emprunt +PaymentLoan=Règlement d'emprunt +Capital=Capital +Nbterms=Nombre d'échéances +LoanAccountancyCapitalCode=Compte comptable capital +LoanAccountancyInsuranceCode=Compte comptable assurance +LoanAccountancyInterestCode=Compte comptable intérêts +ConfigLoan=Configuration du module emprunt +LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Compte comptable capital par défaut +LOAN_ACCOUNTING_ACCOUNT_INTEREST=Compte comptable intérêts par défaut +LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Compte comptable assurance par défaut \ No newline at end of file From a0b4a0a3cd33eb1c5926f50aad858ada3f835e22 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 1 Oct 2014 07:32:03 +0200 Subject: [PATCH 035/940] Update menu auguria --- htdocs/core/menus/init_menu_auguria.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 36a59d33109..3dfa9a546ba 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -12,7 +12,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('societe|fournisseur', '( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)', 2__+MAX_llx_menu__, __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('product|service', '$conf->product->enabled || $conf->service->enabled', 3__+MAX_llx_menu__, __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'Products/Services', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 30, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('propal|commande|fournisseur|contrat|ficheinter', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled || $conf->tax->enabled', 5__+MAX_llx_menu__, __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 40, __ENTITY__); -insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting|facture|deplacement|don|tax|salaries', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled || $conf->tax->enabled || $conf->salaries->enabled', 6__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=', 'MenuFinancial', -1, 'compta', '$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 || $user->rights->salaries->read', '', 2, 50, __ENTITY__); +insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting|facture|deplacement|don|tax|salaries|loan', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled || $conf->don->enabled || $conf->tax->enabled || $conf->salaries->enabled || $conf->loan->enabled', 6__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=', 'MenuFinancial', -1, 'compta', '$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 || $user->rights->salaries->read || $user->rights->loan->read', '', 2, 50, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('banque|prelevement', '$conf->banque->enabled || $conf->prelevement->enabled', 14__+MAX_llx_menu__, __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/index.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->rights->banque->lire || $user->rights->prelevement->bons->lire', '', 0, 60, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('projet', '$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 70, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('mailing|export|import|opensurvey', '$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled || $conf->opensurvey->enabled', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run || $user->rights->opensurvey->read', '', 2, 90, __ENTITY__); @@ -179,6 +179,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'accountancy', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=accountancy', 'Salaries', 1, 'salaries', '$user->rights->salaries->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2211__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/salaries/card.php?leftmenu=tax_salary&action=create', 'NewPayment', 2, 'companies', '$user->rights->salaries->write', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->read', '', 0, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled', __HANDLER__, 'left', 2220__+MAX_llx_menu__, 'accountancy', 'tax_loan', 2200__+MAX_llx_menu__, '/compta/loan/index.php?leftmenu=tax_loan&mainmenu=accountancy', 'Loans', 1, 'loan', '$user->rights->loan->read', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/loan/card.php?leftmenu=tax_loan&action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/loan/index.php?leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2250__+MAX_llx_menu__, 'accountancy', 'tax_social', 2200__+MAX_llx_menu__, '/compta/sociales/index.php?leftmenu=tax_social', 'SocialContributions', 1, '', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2251__+MAX_llx_menu__, 'accountancy', '', 2250__+MAX_llx_menu__, '/compta/sociales/charges.php?leftmenu=tax_social&action=create', 'MenuNewSocialContribution', 2, '', '$user->rights->tax->charges->creer', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2252__+MAX_llx_menu__, 'accountancy', '', 2250__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly', 'Payments', 2, '', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); From ba7a4d6f8802fda8adcedd6e2cdb2aac7f4ae069 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 2 Oct 2014 19:56:41 +0200 Subject: [PATCH 036/940] Update card --- htdocs/compta/loan/card.php | 87 ++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index d2dc5362915..c97ca6d84b0 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -31,8 +31,9 @@ $langs->load("bills"); $langs->load("loan"); $id=GETPOST('id','int'); -$action=GETPOST("action"); +$action=GETPOST('action'); $confirm=GETPOST('confirm'); +$cancel=GETPOST('cancel'); // Security check $socid = GETPOST('socid','int'); @@ -46,17 +47,17 @@ $result = restrictedArea($user, 'loan', $id, '',''); // Classify paid if ($action == 'confirm_paid' && $confirm == 'yes') { - $loan = new Loan($db); - $loan->fetch($id); - $result = $loan->set_paid($user); + $object = new Loan($db); + $object->fetch($id); + $result = $object->set_paid($user); } // Delete loan if ($action == 'confirm_delete' && $confirm == 'yes') { - $loan = new Loan($db); - $loan->fetch($id); - $result=$loan->delete($user); + $object = new Loan($db); + $object->fetch($id); + $result=$object->delete($user); if ($result > 0) { header("Location: index.php"); @@ -72,8 +73,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // Add loan if ($action == 'add' && $user->rights->loan->write) { - $datestart=dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); - $dateend=dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + $datestart=dol_mktime(12,0,0, $GETPOST("startmonth"), $GETPOST("startday"), $GETPOST("startyear")); + $dateend=dol_mktime(12,0,0, $GETPOST("endmonth"), $GETPOST("endday"), $GETPOST("endyear")); if (! $datestart) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors'); @@ -91,33 +92,33 @@ if ($action == 'add' && $user->rights->loan->write) } else { - $loan = new Loan($db); + $object = new Loan($db); - $loan->label = GETPOST("label"); - $loan->fk_bank = GETPOST("accountid"); - $loan->capital = GETPOST("capital"); - $loan->datestart = $datestart; - $loan->dateend = $dateend; - $loan->nbterm = GETPOST("nbterm"); - $loan->rate = GETPOST("rate"); + $object->label = GETPOST("label"); + $object->fk_bank = GETPOST("accountid"); + $object->capital = GETPOST("capital"); + $object->datestart = $datestart; + $object->dateend = $dateend; + $object->nbterm = GETPOST("nbterm"); + $object->rate = GETPOST("rate"); - $loan->account_capital = GETPOST("accountancy_account_capital"); - $loan->account_insurance = GETPOST("accountancy_account_insurance"); - $loan->account_interest = GETPOST("accountancy_account_interest"); + $object->account_capital = GETPOST("accountancy_account_capital"); + $object->account_insurance = GETPOST("accountancy_account_insurance"); + $object->account_interest = GETPOST("accountancy_account_interest"); - $id=$loan->create($user); + $id=$object->create($user); if ($id <= 0) { - setEventMessage($loan->error, 'errors'); + setEventMessage($object->error, 'errors'); } } } -if ($action == 'update' && ! $_POST["cancel"] && $user->rights->loan->write) +if ($action == 'update' && ! $cancel && $user->rights->loan->write) { - $datestart=dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); - $dateend=dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + $datestart=dol_mktime(12,0,0, $GETPOST("startmonth"), $GETPOST("startday"), $GETPOST("startyear")); + $dateend=dol_mktime(12,0,0, $GETPOST("endmonth"), $GETPOST("endday"), $GETPOST("endyear")); if (! $datestart) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors'); @@ -130,17 +131,22 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->loan->write) } else { - $loan = new Loan($db); - $result=$loan->fetch($_GET["id"]); - - $loan->label=$_POST["label"]; - $loan->datestart=$datestart; - $loan->dateend=$dateend; - - $result=$loan->update($user); - if ($result <= 0) + $object = new Loan($db); + if ($object->fetch($id)) { - setEventMessage($loan->error, 'errors'); + $object->label = $GETPOST("label"); + $object->datestart = $datestart; + $object->dateend = $dateend; + } + + if ($object->update($id, $user) > 0) + { + $action = ''; + } + else + { + $action = 'edit'; + setEventMessage($object->error, 'errors'); } } } @@ -180,7 +186,7 @@ if ($action == 'create') if (! empty($conf->banque->enabled)) { print ''.$langs->trans("Account").''; - $form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Show list of bank account with courant + $form->select_comptes($GETPOST["accountid"],"accountid",0,"courant=1",1); // Show list of bank account with courant print ''; } else @@ -259,7 +265,7 @@ if ($action == 'create') print ''; print '
    '; - print '
'; print ''; } @@ -434,8 +440,8 @@ if ($id > 0) print ""; /* - * Boutons actions - */ + * Buttons actions + */ if ($action != 'edit') { print "
\n"; @@ -474,7 +480,6 @@ if ($id > 0) } } - llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file From dca4591cdf7615eb400c53dd21da5cf1a98c004c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 2 Oct 2014 20:00:35 +0200 Subject: [PATCH 037/940] Add calculator --- htdocs/compta/loan/calculator.php | 223 ++++++++++++++++++++++++ htdocs/compta/loan/calculator.tpl | 150 ++++++++++++++++ htdocs/core/menus/standard/eldy.lib.php | 1 + htdocs/langs/en_US/loan.lang | 6 + htdocs/langs/fr_FR/loan.lang | 6 + 5 files changed, 386 insertions(+) create mode 100644 htdocs/compta/loan/calculator.php create mode 100644 htdocs/compta/loan/calculator.tpl diff --git a/htdocs/compta/loan/calculator.php b/htdocs/compta/loan/calculator.php new file mode 100644 index 00000000000..562ce2c27d5 --- /dev/null +++ b/htdocs/compta/loan/calculator.php @@ -0,0 +1,223 @@ + + * + * 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/compta/loan/calculator.php + * \ingroup loan + * \brief Calculator for loan + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; + +$langs->load("loan"); +$langs->load("compta"); +$langs->load("banks"); +$langs->load("bills"); + +// Security check +$socid = isset($GETPOST["socid"])?$GETPOST["socid"]:''; +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'loan', '', '', ''); + +$action=GETPOST("action"); + +/* Defining Variables */ +$periods = array( + 52 => $langs->trans("Weekly"), + 26 => $langs->trans("Bi-weekly"), + 12 => $langs->trans("Monthly"), + 6 => $langs->trans("Bi-monthly"), + 4 => $langs->trans("Quarterly"), + 2 => $langs->trans("Semi-annually"), + 1 => $langs->trans("Annually") + ); + +$loan_capital = isset($GETPOST("loan_capital")) ? $GETPOST("loan_capital") : 0; +$loan_length = isset($GETPOST("loan_length")) ? $GETPOST("loan_length") : 0; +$loan_interest = isset(GETPOST("loan_interest")) ? $GETPOST("loan_interest") : 0; +$pay_periodicity = isset(GETPOST("pay_periodicity")) ? $GETPOST("pay_periodicity") : 12; +$periodicity = $periods[$pay_periodicity]; + +$pay_periods = ''; +foreach($periods as $value => $name) +{ + $selected = ($pay_periodicity == $value) ? 'selected' : ''; +} + +if ($action == 'calculate') +{ + /* Checking Variables */ + $error = 0; + + if(!is_numeric($loan_capital) || $loan_capital <= 0) + { + // $this->error="ErrorLoanCapital"; + return -1; + } + if(!is_numeric($loan_length) || $loan_length <= 0) + { + // $this->error="ErrorLoanLength"; + return -1; + } + if(!is_numeric($loan_interest) or $loan_interest <= 0) + { + // $this->error="ErrorLoanInterest"; + return -1; + } + + /* + * Calculating + */ + if(isset($_GET['action'])) + { + $c_balance = $loan_capital; + $total_periods = $loan_length * $pay_periodicity; + $interest_percent = $loan_interest / 100; + $period_interest = $interest_percent / $pay_periodicity; + $c_period_payment = $loan_capital * ($period_interest / (1 - pow((1 + $period_interest), -($total_periods)))); + $total_paid = number_format($c_period_payment * $total_periods, 2, '.', ' '); + $total_interest = number_format($c_period_payment * $total_periods - $loan_capital, 2, '.', ' '); + $total_principal = number_format($loan_capital, 2, '.', ' '); + + $loan_capital = number_format($loan_capital, 2, '.', ' '); + $loan_interest = number_format($loan_interest, 2, '.', ' '); + $period_payment = number_format($c_period_payment, 2, '.', ' '); + + for($period = 1; $period <= $total_periods; $period++) + { + $c_interest = $c_balance * $period_interest; + $c_principal = $c_period_payment - $c_interest; + $c_balance -= $c_principal; + + $interest = number_format($c_interest, 2, '.', ' '); + $principal = number_format($c_principal, 2, '.', ' '); + $balance = number_format($c_balance, 2, '.', ' '); + + $evenrow_row_modifier = ($period % 2) ? '' : 'class=evenrow'; + } + } + else + { + $amortization_table = ''; + $loan_summary = ''; + } +} + +/* + * View + */ + +$help_url='EN:Module_Loan|FR:Module_Emprunt'; +llxHeader("",$langs->trans("Loan"),$help_url); + +print_fiche_titre($langs->trans("CalculatorLoan")); + +print ''; + +print '' . "\n"; +print ''; +print ''; + +// Capital +print ''; + +// Length +print ''; + +// Interest +print ''; + +print '
'.$langs->trans("Capital").'
'.$langs->trans("LengthByYears").'
'.$langs->trans("Interest").' %
'; + +print '
'; + +print ''; + +if ($action == 'calculate') +{ +/* + + + + + + {amortization_table_rows} + + + +
PeriodInterest PaidPrincipal PaidRemaining Balance
Totals:{total_interest}${total_principal}$ 
+ + + + + {period} + {interest}$ + {principal}$ + {balance}$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Loan Summary
Loan amount:{loan_amount}$
Loan length:{loan_length} years
Annual interest:{annual_interest}%
Pay periodicity:{periodicity}
{periodicity} payment:{period_payment}$
Total paid:{total_paid}$
Total interest:{total_interest}$
Total periods:{total_periods}
+ + */ +} +else +{ + +} + +$db->close(); + +llxFooter(); diff --git a/htdocs/compta/loan/calculator.tpl b/htdocs/compta/loan/calculator.tpl new file mode 100644 index 00000000000..7efbca9924b --- /dev/null +++ b/htdocs/compta/loan/calculator.tpl @@ -0,0 +1,150 @@ + + + + Loan Calculator + + + + + + + + + + +
+ {error} + + + + + +
+ {loan_summary} + {loan_parameters_form} + + {amortization_table} +
+
+ + + +
+ + + + + + + + + + +
Loan Parameters
+ + + + + + + + + + + + + + + + + + + + +
Loan amount: $
Loan length: years
Annual interest: %
Pay periodicity: + +
+
Powered by PC Calculators
+
+ + + + + + + + + + + + {amortization_table_rows} + + + +
PeriodInterest PaidPrincipal PaidRemaining Balance
Totals:{total_interest}${total_principal}$ 
+ + + + + {period} + {interest}$ + {principal}$ + {balance}$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Loan Summary
Loan amount:{loan_amount}$
Loan length:{loan_length} years
Annual interest:{annual_interest}%
Pay periodicity:{periodicity}
{periodicity} payment:{period_payment}$
Total paid:{total_paid}$
Total interest:{total_interest}$
Total periods:{total_periods}
+ + + + + + diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c3df5b82fff..bea92481d12 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -825,6 +825,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/loan/index.php?leftmenu=tax_loan&mainmenu=accountancy",$langs->trans("Loans"),1,$user->rights->loan->read, '', $mainmenu, 'tax_loan'); if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/card.php?leftmenu=tax_loan&action=create",$langs->trans("NewLoan"),2,$user->rights->loan->write); if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/index.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read); + if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/calculator.php?leftmenu=tax_loan",$langs->trans("Calculator"),2,$user->rights->loan->read); } // Social contributions diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index 6be2f13a101..37523b7408b 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -9,6 +9,12 @@ Nbterms=Number of terms LoanAccountancyCapitalCode=Accountancy code capital LoanAccountancyInsuranceCode=Accountancy code insurance LoanAccountancyInterestCode=Accountancy code interest +Calculator=Simulator +CalculatorLoan=Loan simulator +ErrorLoanCapital=Loan amount has to be numeric and greater than zero. +ErrorLoanLength=Loan length has to be numeric and greater than zero. +ErrorLoanInterest=Annual interest has to be numeric and greater than zero. +# Admin ConfigLoan=Configuration of the module loan LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accountancy code interest by default diff --git a/htdocs/langs/fr_FR/loan.lang b/htdocs/langs/fr_FR/loan.lang index d230f7f0582..c699388e0c0 100644 --- a/htdocs/langs/fr_FR/loan.lang +++ b/htdocs/langs/fr_FR/loan.lang @@ -9,6 +9,12 @@ Nbterms=Nombre d'échéances LoanAccountancyCapitalCode=Compte comptable capital LoanAccountancyInsuranceCode=Compte comptable assurance LoanAccountancyInterestCode=Compte comptable intérêts +Calculator=Simulateur +CalculatorLoan=Simulateur d'emprunt +ErrorLoanCapital=Le capital de l'emprunt doit être au format numérique et supérieur à zéro. +ErrorLoanLength=La durée de l'emprunt doit être au format numérique et supérieur à zéro. +ErrorLoanInterest=Les intérêts d'emprunt doivent être au format numérique et supérieur à zéro. +# Admin ConfigLoan=Configuration du module emprunt LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Compte comptable capital par défaut LOAN_ACCOUNTING_ACCOUNT_INTEREST=Compte comptable intérêts par défaut From 7fa2b6b3ebea20771d330ed97a5c339d2cdf2e2a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 6 Oct 2014 05:34:45 +0200 Subject: [PATCH 038/940] Update --- htdocs/compta/loan/calculator.php | 223 ------------------------ htdocs/compta/loan/calculator.tpl | 150 ---------------- htdocs/compta/loan/card.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 1 - htdocs/langs/en_US/loan.lang | 4 +- htdocs/langs/fr_FR/loan.lang | 4 +- 6 files changed, 5 insertions(+), 379 deletions(-) delete mode 100644 htdocs/compta/loan/calculator.php delete mode 100644 htdocs/compta/loan/calculator.tpl diff --git a/htdocs/compta/loan/calculator.php b/htdocs/compta/loan/calculator.php deleted file mode 100644 index 562ce2c27d5..00000000000 --- a/htdocs/compta/loan/calculator.php +++ /dev/null @@ -1,223 +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/compta/loan/calculator.php - * \ingroup loan - * \brief Calculator for loan - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/loan/class/loan.class.php'; - -$langs->load("loan"); -$langs->load("compta"); -$langs->load("banks"); -$langs->load("bills"); - -// Security check -$socid = isset($GETPOST["socid"])?$GETPOST["socid"]:''; -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'loan', '', '', ''); - -$action=GETPOST("action"); - -/* Defining Variables */ -$periods = array( - 52 => $langs->trans("Weekly"), - 26 => $langs->trans("Bi-weekly"), - 12 => $langs->trans("Monthly"), - 6 => $langs->trans("Bi-monthly"), - 4 => $langs->trans("Quarterly"), - 2 => $langs->trans("Semi-annually"), - 1 => $langs->trans("Annually") - ); - -$loan_capital = isset($GETPOST("loan_capital")) ? $GETPOST("loan_capital") : 0; -$loan_length = isset($GETPOST("loan_length")) ? $GETPOST("loan_length") : 0; -$loan_interest = isset(GETPOST("loan_interest")) ? $GETPOST("loan_interest") : 0; -$pay_periodicity = isset(GETPOST("pay_periodicity")) ? $GETPOST("pay_periodicity") : 12; -$periodicity = $periods[$pay_periodicity]; - -$pay_periods = ''; -foreach($periods as $value => $name) -{ - $selected = ($pay_periodicity == $value) ? 'selected' : ''; -} - -if ($action == 'calculate') -{ - /* Checking Variables */ - $error = 0; - - if(!is_numeric($loan_capital) || $loan_capital <= 0) - { - // $this->error="ErrorLoanCapital"; - return -1; - } - if(!is_numeric($loan_length) || $loan_length <= 0) - { - // $this->error="ErrorLoanLength"; - return -1; - } - if(!is_numeric($loan_interest) or $loan_interest <= 0) - { - // $this->error="ErrorLoanInterest"; - return -1; - } - - /* - * Calculating - */ - if(isset($_GET['action'])) - { - $c_balance = $loan_capital; - $total_periods = $loan_length * $pay_periodicity; - $interest_percent = $loan_interest / 100; - $period_interest = $interest_percent / $pay_periodicity; - $c_period_payment = $loan_capital * ($period_interest / (1 - pow((1 + $period_interest), -($total_periods)))); - $total_paid = number_format($c_period_payment * $total_periods, 2, '.', ' '); - $total_interest = number_format($c_period_payment * $total_periods - $loan_capital, 2, '.', ' '); - $total_principal = number_format($loan_capital, 2, '.', ' '); - - $loan_capital = number_format($loan_capital, 2, '.', ' '); - $loan_interest = number_format($loan_interest, 2, '.', ' '); - $period_payment = number_format($c_period_payment, 2, '.', ' '); - - for($period = 1; $period <= $total_periods; $period++) - { - $c_interest = $c_balance * $period_interest; - $c_principal = $c_period_payment - $c_interest; - $c_balance -= $c_principal; - - $interest = number_format($c_interest, 2, '.', ' '); - $principal = number_format($c_principal, 2, '.', ' '); - $balance = number_format($c_balance, 2, '.', ' '); - - $evenrow_row_modifier = ($period % 2) ? '' : 'class=evenrow'; - } - } - else - { - $amortization_table = ''; - $loan_summary = ''; - } -} - -/* - * View - */ - -$help_url='EN:Module_Loan|FR:Module_Emprunt'; -llxHeader("",$langs->trans("Loan"),$help_url); - -print_fiche_titre($langs->trans("CalculatorLoan")); - -print ''; - -print '' . "\n"; -print ''; -print ''; - -// Capital -print ''; - -// Length -print ''; - -// Interest -print ''; - -print '
'.$langs->trans("Capital").'
'.$langs->trans("LengthByYears").'
'.$langs->trans("Interest").' %
'; - -print '
'; - -print ''; - -if ($action == 'calculate') -{ -/* - - - - - - {amortization_table_rows} - - - -
PeriodInterest PaidPrincipal PaidRemaining Balance
Totals:{total_interest}${total_principal}$ 
- - - - - {period} - {interest}$ - {principal}$ - {balance}$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Loan Summary
Loan amount:{loan_amount}$
Loan length:{loan_length} years
Annual interest:{annual_interest}%
Pay periodicity:{periodicity}
{periodicity} payment:{period_payment}$
Total paid:{total_paid}$
Total interest:{total_interest}$
Total periods:{total_periods}
- - */ -} -else -{ - -} - -$db->close(); - -llxFooter(); diff --git a/htdocs/compta/loan/calculator.tpl b/htdocs/compta/loan/calculator.tpl deleted file mode 100644 index 7efbca9924b..00000000000 --- a/htdocs/compta/loan/calculator.tpl +++ /dev/null @@ -1,150 +0,0 @@ - - - - Loan Calculator - - - - - - - - - - -
- {error} - - - - - -
- {loan_summary} - {loan_parameters_form} - - {amortization_table} -
-
- - - -
- - - - - - - - - - -
Loan Parameters
- - - - - - - - - - - - - - - - - - - - -
Loan amount: $
Loan length: years
Annual interest: %
Pay periodicity: - -
-
Powered by PC Calculators
-
- - - - - - - - - - - - {amortization_table_rows} - - - -
PeriodInterest PaidPrincipal PaidRemaining Balance
Totals:{total_interest}${total_principal}$ 
- - - - - {period} - {interest}$ - {principal}$ - {balance}$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Loan Summary
Loan amount:{loan_amount}$
Loan length:{loan_length} years
Annual interest:{annual_interest}%
Pay periodicity:{periodicity}
{periodicity} payment:{period_payment}$
Total paid:{total_paid}$
Total interest:{total_interest}$
Total periods:{total_periods}
- - - - - - diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index c97ca6d84b0..e49aee1b61f 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -297,7 +297,7 @@ if ($id > 0) if ($action == 'edit') { - print "
id&action=update\" method=\"post\">"; + print 'id&action=update" method="POST">'; print ''; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 86e74cfcc5f..1e4f1197cb0 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -834,7 +834,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/loan/index.php?leftmenu=tax_loan&mainmenu=accountancy",$langs->trans("Loans"),1,$user->rights->loan->read, '', $mainmenu, 'tax_loan'); if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/card.php?leftmenu=tax_loan&action=create",$langs->trans("NewLoan"),2,$user->rights->loan->write); if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/index.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read); - if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/calculator.php?leftmenu=tax_loan",$langs->trans("Calculator"),2,$user->rights->loan->read); } // Social contributions diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index 37523b7408b..10fb0249f6d 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -9,8 +9,8 @@ Nbterms=Number of terms LoanAccountancyCapitalCode=Accountancy code capital LoanAccountancyInsuranceCode=Accountancy code insurance LoanAccountancyInterestCode=Accountancy code interest -Calculator=Simulator -CalculatorLoan=Loan simulator +ConfirmDeleteLoan=Confirm deleting this loan +ConfirmPayLoan=Confirm classify paid this loan ErrorLoanCapital=Loan amount has to be numeric and greater than zero. ErrorLoanLength=Loan length has to be numeric and greater than zero. ErrorLoanInterest=Annual interest has to be numeric and greater than zero. diff --git a/htdocs/langs/fr_FR/loan.lang b/htdocs/langs/fr_FR/loan.lang index c699388e0c0..1e54f90e2be 100644 --- a/htdocs/langs/fr_FR/loan.lang +++ b/htdocs/langs/fr_FR/loan.lang @@ -9,8 +9,8 @@ Nbterms=Nombre d'échéances LoanAccountancyCapitalCode=Compte comptable capital LoanAccountancyInsuranceCode=Compte comptable assurance LoanAccountancyInterestCode=Compte comptable intérêts -Calculator=Simulateur -CalculatorLoan=Simulateur d'emprunt +ConfirmDeleteLoan=Confirmation de supression de cet emprunt +ConfirmPayLoan=Confirmation que cet emprunt est classé comme payé ErrorLoanCapital=Le capital de l'emprunt doit être au format numérique et supérieur à zéro. ErrorLoanLength=La durée de l'emprunt doit être au format numérique et supérieur à zéro. ErrorLoanInterest=Les intérêts d'emprunt doivent être au format numérique et supérieur à zéro. From eebf107d5fb984ca92906706495771c8b5f22ead Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 27 Oct 2014 10:54:50 +0100 Subject: [PATCH 039/940] includes and show_documents --- htdocs/comm/action/card.php | 50 ++++++++++++++++++----- htdocs/core/class/html.formfile.class.php | 7 ++++ 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 607f8e14c4e..33e470d1445 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -28,19 +28,20 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; +dol_include_once('/core/lib/agenda.lib.php'); +dol_include_once('/core/lib/date.lib.php'); +dol_include_once('/contact/class/contact.class.php'); +dol_include_once('/user/class/user.class.php'); +dol_include_once('/comm/action/class/cactioncomm.class.php'); +dol_include_once('/comm/action/class/actioncomm.class.php'); +dol_include_once('/core/class/html.formactions.class.php'); +dol_include_once('/core/class/html.formfile.class.php'); if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + dol_include_once('/projet/class/project.class.php'); + dol_include_once('/core/class/html.formprojet.class.php'); } -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +dol_include_once('/core/class/extrafields.class.php'); $langs->load("companies"); $langs->load("commercial"); @@ -74,6 +75,7 @@ $cactioncomm = new CActionComm($db); $object = new ActionComm($db); $contact = new Contact($db); $extrafields = new ExtraFields($db); +$formfile = new FormFile($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); @@ -1243,6 +1245,34 @@ if ($id > 0) if ($action != 'edit') { + + if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) { + print '
'; + print ''; // ancre + + /* + * Documents generes + */ + + $filedir=$conf->agenda->multidir_output[$conf->entity].'/'.$object->id; + $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; + + $genallowed=$user->rights->agenda->myactions->create; + $delallowed=$user->rights->agenda->myactions->delete; + + $var=true; + + $somethingshown=$formfile->show_documents('agenda',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,0,0,'','','',$object->default_lang); + + print '
'; + + + print '
'; + + print '
 
'; + } + + // Link to agenda views print '
'; print ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 674be61311d..2e316841696 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -301,6 +301,12 @@ class FormFile $modellist=ModeleThirdPartyDoc::liste_modeles($this->db); } } + + else if ($modulepart == 'agenda') + { + null; + } + else if ($modulepart == 'propal') { if (is_array($genallowed)) $modellist=$genallowed; @@ -433,6 +439,7 @@ class FormFile } else { + // For normalized standard modules $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); if (file_exists($file)) From 4e1f9babaf4e8f823824371f67f9cb6b2dab5185 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 3 Nov 2014 21:58:14 +0100 Subject: [PATCH 040/940] Merge --- htdocs/fichinter/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 77c7e17ffb5..4ffc31c9cab 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -748,10 +748,10 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg = dol_concatdesc($actionmsg, $message); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref); } From af7f9e17077763232e967b6fbadca7536b8e5102 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 4 Nov 2014 16:08:07 +0100 Subject: [PATCH 041/940] no dol_include --- htdocs/comm/action/card.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 33e470d1445..3d899a14cbe 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -28,20 +28,21 @@ */ require '../../main.inc.php'; -dol_include_once('/core/lib/agenda.lib.php'); -dol_include_once('/core/lib/date.lib.php'); -dol_include_once('/contact/class/contact.class.php'); -dol_include_once('/user/class/user.class.php'); -dol_include_once('/comm/action/class/cactioncomm.class.php'); -dol_include_once('/comm/action/class/actioncomm.class.php'); -dol_include_once('/core/class/html.formactions.class.php'); -dol_include_once('/core/class/html.formfile.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + if (! empty($conf->projet->enabled)) { - dol_include_once('/projet/class/project.class.php'); - dol_include_once('/core/class/html.formprojet.class.php'); + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -dol_include_once('/core/class/extrafields.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("companies"); $langs->load("commercial"); From aecb9856593d36d2226a6e952d51c433a052f1d9 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 4 Nov 2014 20:53:07 +0100 Subject: [PATCH 042/940] Update work --- htdocs/compta/loan/card.php | 28 ++++++++++++++-------------- htdocs/compta/loan/index.php | 23 +++++++++++++++++------ htdocs/compta/salaries/card.php | 2 +- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index e49aee1b61f..49e3884562c 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -69,12 +69,12 @@ if ($action == 'confirm_delete' && $confirm == 'yes') } } - // Add loan if ($action == 'add' && $user->rights->loan->write) { - $datestart=dol_mktime(12,0,0, $GETPOST("startmonth"), $GETPOST("startday"), $GETPOST("startyear")); - $dateend=dol_mktime(12,0,0, $GETPOST("endmonth"), $GETPOST("endday"), $GETPOST("endyear")); + $datestart=@dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); + $dateend=@dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + if (! $datestart) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors'); @@ -94,17 +94,17 @@ if ($action == 'add' && $user->rights->loan->write) { $object = new Loan($db); - $object->label = GETPOST("label"); - $object->fk_bank = GETPOST("accountid"); - $object->capital = GETPOST("capital"); - $object->datestart = $datestart; - $object->dateend = $dateend; - $object->nbterm = GETPOST("nbterm"); - $object->rate = GETPOST("rate"); + $object->label = $_POST["label"]; + $object->fk_bank = $_POST["accountid"]; + $object->capital = $_POST["capital"]; + $object->datestart = $datestart; + $object->dateend = $dateend; + $object->nbterm = $_POST["nbterm"]; + $object->rate = $_POST["rate"]; - $object->account_capital = GETPOST("accountancy_account_capital"); - $object->account_insurance = GETPOST("accountancy_account_insurance"); - $object->account_interest = GETPOST("accountancy_account_interest"); + $object->account_capital = $_POST["accountancy_account_capital"]; + $object->account_insurance = $_POST["accountancy_account_insurance"]; + $object->account_interest = $_POST["accountancy_account_interest"]; $id=$object->create($user); if ($id <= 0) @@ -173,7 +173,7 @@ if ($action == 'create') $datec = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); - print '' . "\n"; + print '' . "\n"; print ''; print ''; diff --git a/htdocs/compta/loan/index.php b/htdocs/compta/loan/index.php index a4432ba9ced..2834ce2069f 100644 --- a/htdocs/compta/loan/index.php +++ b/htdocs/compta/loan/index.php @@ -45,8 +45,16 @@ if (! $sortfield) $sortfield="l.rowid"; if (! $sortorder) $sortorder="DESC"; $limit = $conf->liste_limit; +$search_ref=GETPOST('search_ref','int'); $search_label=GETPOST('search_label','alpha'); -$filtre=$_GET["filtre"]; +$filtre=GETPOST("filtre"); + +if (GETPOST("button_removefilter")) +{ + $search_ref=""; + $search_label=""; + $search_amount=""; +} /* * View @@ -56,13 +64,14 @@ $loan = new Loan($db); llxHeader(); -$sql = "SELECT l.rowid as id, l.label, l.capital, l.datestart, l.dateend,"; +$sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend,"; $sql.= " SUM(pl.amount) as alreadypayed"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l,"; $sql.= " ".MAIN_DB_PREFIX."payment_loan as pl"; $sql.= " WHERE pl.fk_loan = l.rowid"; $sql.= " AND l.entity = ".$conf->entity; -if (GETPOST("search_label")) $sql.=" AND l.label LIKE '%".$db->escape(GETPOST("search_label"))."%'"; +if (GETPOST("search_ref")) $sql.=" AND (l.rowid = ".$db->escape($search_ref).")"; +if (GETPOST("search_label")) $sql.=" AND l.label LIKE '%".$db->escape($search_label)."%'"; if ($filtre) { $filtre=str_replace(":","=",$filtre); @@ -83,7 +92,7 @@ if ($resql) print ''."\n"; print ''; print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"id","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"l.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"l.label","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Capital"),$_SERVER["PHP_SELF"],"l.capital","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"l.datestart","",$param,'align="center"',$sortfield,$sortorder); @@ -96,9 +105,11 @@ if ($resql) print ''; print ''; print ''; - print '\n"; + print ''; + print ''; + print ''; $var=true; while ($i < min($num,$limit)) diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 3ee796c6134..c6e492cd787 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -206,7 +206,7 @@ if ($action == 'create') $datesp=dol_get_first_day($pastmonthyear,$pastmonth,false); $dateep=dol_get_last_day($pastmonthyear,$pastmonth,false); } - print "\n"; + print ''; print ''; print ''; From 3042bf4dc2a4fbaab5d759fcf94a2b809b1de2a8 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 10 Nov 2014 06:08:50 +0100 Subject: [PATCH 043/940] Correct lot of bugs --- htdocs/compta/loan/card.php | 176 +++++++++--------- htdocs/compta/loan/class/loan.class.php | 82 ++++---- .../compta/loan/class/paymentloan.class.php | 29 ++- htdocs/compta/loan/index.php | 42 ++--- htdocs/compta/loan/payment/card.php | 19 +- htdocs/compta/loan/payment/payment.php | 74 +++++--- .../install/mysql/migration/3.6.0-3.7.0.sql | 42 ----- .../install/mysql/migration/3.7.0-3.8.0.sql | 63 +++++++ .../install/mysql/tables/llx_payment_loan.sql | 4 +- htdocs/langs/en_US/loan.lang | 3 + htdocs/langs/fr_FR/loan.lang | 3 + 11 files changed, 306 insertions(+), 231 deletions(-) create mode 100644 htdocs/install/mysql/migration/3.7.0-3.8.0.sql diff --git a/htdocs/compta/loan/card.php b/htdocs/compta/loan/card.php index 49e3884562c..88a4429e7c5 100644 --- a/htdocs/compta/loan/card.php +++ b/htdocs/compta/loan/card.php @@ -33,13 +33,15 @@ $langs->load("loan"); $id=GETPOST('id','int'); $action=GETPOST('action'); $confirm=GETPOST('confirm'); -$cancel=GETPOST('cancel'); +$cancel=GETPOST('cancel','alpha'); // Security check $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'loan', $id, '',''); +$object = new Loan($db); + /* * Actions */ @@ -47,7 +49,6 @@ $result = restrictedArea($user, 'loan', $id, '',''); // Classify paid if ($action == 'confirm_paid' && $confirm == 'yes') { - $object = new Loan($db); $object->fetch($id); $result = $object->set_paid($user); } @@ -55,7 +56,6 @@ if ($action == 'confirm_paid' && $confirm == 'yes') // Delete loan if ($action == 'confirm_delete' && $confirm == 'yes') { - $object = new Loan($db); $object->fetch($id); $result=$object->delete($user); if ($result > 0) @@ -72,86 +72,88 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // Add loan if ($action == 'add' && $user->rights->loan->write) { - $datestart=@dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); - $dateend=@dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - - if (! $datestart) + if (! $cancel) { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors'); - $action = 'create'; - } - elseif (! $dateend) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateEnd")), 'errors'); - $action = 'create'; - } - elseif (! $_POST["capital"]) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Capital")), 'errors'); - $action = 'create'; - } - else - { - $object = new Loan($db); - - $object->label = $_POST["label"]; - $object->fk_bank = $_POST["accountid"]; - $object->capital = $_POST["capital"]; - $object->datestart = $datestart; - $object->dateend = $dateend; - $object->nbterm = $_POST["nbterm"]; - $object->rate = $_POST["rate"]; + $datestart=@dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); + $dateend=@dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - $object->account_capital = $_POST["accountancy_account_capital"]; - $object->account_insurance = $_POST["accountancy_account_insurance"]; - $object->account_interest = $_POST["accountancy_account_interest"]; - - $id=$object->create($user); - if ($id <= 0) + if (! $datestart) { - setEventMessage($object->error, 'errors'); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors'); + $action = 'create'; } - } -} - - -if ($action == 'update' && ! $cancel && $user->rights->loan->write) -{ - $datestart=dol_mktime(12,0,0, $GETPOST("startmonth"), $GETPOST("startday"), $GETPOST("startyear")); - $dateend=dol_mktime(12,0,0, $GETPOST("endmonth"), $GETPOST("endday"), $GETPOST("endyear")); - if (! $datestart) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateStart")), 'errors'); - $action = 'edit'; - } - elseif (! $dateend) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateEnd")), 'errors'); - $action = 'edit'; - } - else - { - $object = new Loan($db); - if ($object->fetch($id)) + elseif (! $dateend) { - $object->label = $GETPOST("label"); - $object->datestart = $datestart; - $object->dateend = $dateend; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("DateEnd")), 'errors'); + $action = 'create'; } - - if ($object->update($id, $user) > 0) + elseif (! $_POST["capital"]) { - $action = ''; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Capital")), 'errors'); + $action = 'create'; } else { - $action = 'edit'; - setEventMessage($object->error, 'errors'); + $object->label = $_POST["label"]; + $object->fk_bank = $_POST["accountid"]; + $object->capital = $_POST["capital"]; + $object->datestart = $datestart; + $object->dateend = $dateend; + $object->nbterm = $_POST["nbterm"]; + $object->rate = $_POST["rate"]; + + $object->account_capital = $_POST["accountancy_account_capital"]; + $object->account_insurance = $_POST["accountancy_account_insurance"]; + $object->account_interest = $_POST["accountancy_account_interest"]; + + $id=$object->create($user); + if ($id <= 0) + { + setEventMessage($object->error, 'errors'); + } } } + else + { + header("Location: index.php"); + exit(); + } } +// Update record +else if ($action == 'update' && $user->rights->loan->write) +{ + if (! $cancel) + { + $result = $object->fetch($id); + + if ($object->fetch($id)) + { + $object->label = GETPOST("label"); + $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); + $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); + $object->nbterm = GETPOST("nbterm"); + $object->rate = GETPOST("rate"); + } + + $result = $object->update($user); + if ($result > 0) + { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit; + } + else + { + setEventMessage($object->error, 'errors'); + } + } + else + { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit; + } +} /* * View @@ -212,10 +214,10 @@ if ($action == 'create') print ''; // Number of terms - print ''; + print ''; // Rate - print ''; + print ''; // Note print ''; @@ -273,7 +275,6 @@ if ($action == 'create') // View if ($id > 0) { - $object = new Loan($db); $result = $object->fetch($id); if ($result > 0) @@ -297,8 +298,10 @@ if ($id > 0) if ($action == 'edit') { - print 'id&action=update" method="POST">'; - print ''; + print '' . "\n"; + print ''; + print ''; + print ''; } print '
  '; + print ''; print ''; - print "
'.$langs->trans("Nbterms").'
'.$langs->trans("Nbterms").'
'.$langs->trans("Rate").'
'.$langs->trans("Rate").' %
'; @@ -353,7 +356,7 @@ if ($id > 0) print ''; // Rate - print ''; + print ''; // Status print ''; @@ -378,8 +381,9 @@ if ($id > 0) /* * Payments */ - $sql = "SELECT p.rowid, p.num_payment, datep as dp, p.amount,"; - $sql.= "c.libelle as paiement_type"; + $sql = "SELECT p.rowid, p.num_payment, datep as dp,"; + $sql.= " p.amount_capital, p.amount_insurance, p.amount_interest,"; + $sql.= " c.libelle as paiement_type"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; $sql.= ", ".MAIN_DB_PREFIX."loan as l"; @@ -400,7 +404,9 @@ if ($id > 0) print ''; print ''; print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; @@ -413,21 +419,23 @@ if ($id > 0) print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print '\n"; print "\n"; - print '\n"; + print '\n"; + print '\n"; + print '\n"; print ""; - $totalpaid += $objp->amount; + $totalpaid += $objp->amount_capital; $i++; } if ($object->paid == 0) { - print "\n"; - print "\n"; + print ''; + print ''; $staytopay = $object->capital - $totalpaid; - print ""; - print "\n"; + print ''; + print ''; } print "
'.$langs->trans("Nbterms").''.$object->nbterm.'
'.$langs->trans("Rate").''.$object->rate.'
'.$langs->trans("Rate").''.$object->rate.' %
'.$langs->trans("Status").''.$object->getLibStatut(4, $totalpaye).'
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Amount").''.$langs->trans("Insurance").''.$langs->trans("Interest").''.$langs->trans("Capital").' 
'.dol_print_date($db->jdate($objp->dp),'day')."".$objp->paiement_type.' '.$objp->num_payment."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."'.price($objp->amount_insurance)." ".$langs->trans("Currency".$conf->currency)."'.price($objp->amount_interest)." ".$langs->trans("Currency".$conf->currency)."'.price($objp->amount_capital)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaid)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->capital)." ".$langs->trans("Currency".$conf->currency)."
'.$langs->trans("AlreadyPaid").' :'.price($totalpaid).' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("AmountExpected").' :'.price($object->capital).' '.$langs->trans("Currency".$conf->currency).'
".$langs->trans("RemainderToPay")." :".price($staytopay)." ".$langs->trans("Currency".$conf->currency)."
'.$langs->trans("RemainderToPay").' :'.price($staytopay).' '.$langs->trans("Currency".$conf->currency).'
"; $db->free($resql); @@ -444,7 +452,7 @@ if ($id > 0) */ if ($action != 'edit') { - print "
\n"; + print '
'; // Edit if ($user->rights->loan->write) diff --git a/htdocs/compta/loan/class/loan.class.php b/htdocs/compta/loan/class/loan.class.php index 07b842b708e..b8fcf04728f 100644 --- a/htdocs/compta/loan/class/loan.class.php +++ b/htdocs/compta/loan/class/loan.class.php @@ -263,8 +263,8 @@ class Loan extends CommonObject /** * Update loan * - * @param User $user Utilisateur qui modifie - * @return int <0 si erreur, >0 si ok + * @param User $user User who modified + * @return int <0 if error, >0 if ok */ function update($user) { @@ -273,7 +273,8 @@ class Loan extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."loan"; $sql.= " SET label='".$this->db->escape($this->label)."',"; $sql.= " datestart='".$this->db->idate($this->datestart)."',"; - $sql.= " dateend='".$this->db->idate($this->dateend)."'"; + $sql.= " dateend='".$this->db->idate($this->dateend)."',"; + $sql.= " fk_user_modif = ".$user->id; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -379,7 +380,7 @@ class Loan extends CommonObject * @param int $maxlen Label max length * @return string Chaine with URL */ - function getNameUrl($withpicto=0,$maxlen=0) + function getLinkUrl($withpicto=0,$maxlen=0) { global $langs; @@ -432,40 +433,43 @@ class Loan extends CommonObject * @param int $id Id of record * @return void */ - function info($id) - { - $sql = "SELECT l.rowid, l.tms as datem, l.fk_user_author as user_author, l.datec as datec"; - $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; - $sql.= " WHERE l.rowid = ".$id; + function info($id) + { + $sql = 'SELECT l.rowid, l.datec, l.fk_user_author, l.fk_user_modif,'; + $sql.= ' l.tms'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'loan as l'; + $sql.= ' WHERE l.rowid = '.$id; - dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - - if ($obj->user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->user_author); - $this->user_creation = $cuser; - } - - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - - } - - $this->db->free($result); - - } - else - { - dol_print_error($this->db); - } - } -} + dol_syslog(get_class($this).'::info', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + if ($obj->fk_user_modif) + { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_modif); + $this->user_modification = $muser; + } + $this->date_creation = $this->db->jdate($obj->datec); + if (empty($obj->fk_user_modif)) $obj->tms = ""; + $this->date_modification = $this->db->jdate($obj->tms); + } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } +} \ No newline at end of file diff --git a/htdocs/compta/loan/class/paymentloan.class.php b/htdocs/compta/loan/class/paymentloan.class.php index 0a558fc9bf4..944cfe4ce2f 100644 --- a/htdocs/compta/loan/class/paymentloan.class.php +++ b/htdocs/compta/loan/class/paymentloan.class.php @@ -39,8 +39,10 @@ class PaymentLoan extends CommonObject var $datec=''; var $tms=''; var $datep=''; - var $amount; // Total amount of payment var $amounts=array(); // Array of amounts + var $amount_capital; // Total amount of payment + var $amount_insurance; + var $amount_interest; var $fk_typepayment; var $num_payment; var $note; @@ -82,7 +84,9 @@ class PaymentLoan extends CommonObject // Clean parameters if (isset($this->fk_loan)) $this->fk_loan = trim($this->fk_loan); - if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital); + if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance); + if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest); if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); if (isset($this->note)) $this->note = trim($this->note); @@ -107,7 +111,7 @@ class PaymentLoan extends CommonObject if ($totalamount != 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_loan (fk_loan, datec, datep, amount,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_loan (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,"; $sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->datepaid)."',"; @@ -130,7 +134,7 @@ class PaymentLoan extends CommonObject if ($totalamount != 0 && ! $error) { - $this->amount=$totalamount; + $this->amount_capital=$totalamount; $this->total=$totalamount; // deprecated $this->db->commit(); return $this->id; @@ -158,7 +162,9 @@ class PaymentLoan extends CommonObject $sql.= " t.datec,"; $sql.= " t.tms,"; $sql.= " t.datep,"; - $sql.= " t.amount,"; + $sql.= " t.amount_capital,"; + $sql.= " t.amount_insurance,"; + $sql.= " t.amount_interest,"; $sql.= " t.fk_typepayment,"; $sql.= " t.num_payment,"; $sql.= " t.note,"; @@ -186,7 +192,9 @@ class PaymentLoan extends CommonObject $this->datec = $this->db->jdate($obj->datec); $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); - $this->amount = $obj->amount; + $this->amount_capital = $obj->amount_capital; + $this->amount_insurance = $obj->amount_insurance; + $this->amount_interest = $obj->amount_interest; $this->fk_typepayment = $obj->fk_typepayment; $this->num_payment = $obj->num_payment; $this->note = $obj->note; @@ -225,9 +233,10 @@ class PaymentLoan extends CommonObject $error=0; // Clean parameters - if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan); - if (isset($this->amount)) $this->amount=trim($this->amount); + if (isset($this->amount_capital)) $this->amount_capital=trim($this->amount_capital); + if (isset($this->amount_insurance)) $this->amount_insurance=trim($this->amount_insurance); + if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest); if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note)) $this->note=trim($this->note); @@ -245,7 +254,9 @@ class PaymentLoan extends CommonObject $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; + $sql.= " amount_capital=".(isset($this->amount_capital)?$this->amount_capital:"null").","; + $sql.= " amount_insurance=".(isset($this->amount_insurance)?$this->amount_insurance:"null").","; + $sql.= " amount_interest=".(isset($this->amount_interest)?$this->amount_interest:"null").","; $sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").","; $sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").","; $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; diff --git a/htdocs/compta/loan/index.php b/htdocs/compta/loan/index.php index 2834ce2069f..720b52de0a1 100644 --- a/htdocs/compta/loan/index.php +++ b/htdocs/compta/loan/index.php @@ -47,6 +47,7 @@ $limit = $conf->liste_limit; $search_ref=GETPOST('search_ref','int'); $search_label=GETPOST('search_label','alpha'); +$search_amount=GETPOST('search_amount','alpha'); $filtre=GETPOST("filtre"); if (GETPOST("button_removefilter")) @@ -60,36 +61,37 @@ if (GETPOST("button_removefilter")) * View */ -$loan = new Loan($db); +$loan_static = new Loan($db); llxHeader(); $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend,"; -$sql.= " SUM(pl.amount) as alreadypayed"; -$sql.= " FROM ".MAIN_DB_PREFIX."loan as l,"; -$sql.= " ".MAIN_DB_PREFIX."payment_loan as pl"; -$sql.= " WHERE pl.fk_loan = l.rowid"; -$sql.= " AND l.entity = ".$conf->entity; -if (GETPOST("search_ref")) $sql.=" AND (l.rowid = ".$db->escape($search_ref).")"; -if (GETPOST("search_label")) $sql.=" AND l.label LIKE '%".$db->escape($search_label)."%'"; - +$sql.= " SUM(pl.amount_capital) as alreadypayed"; +$sql.= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl"; +$sql.= " ON l.rowid = pl.fk_loan"; +$sql.= " WHERE l.entity = ".$conf->entity; +if ($search_amount) $sql.=" AND l.capital='".$db->escape(price2num(trim($search_amount)))."'"; +if ($search_ref) $sql.=" AND l.rowid = ".$db->escape($search_ref); +if ($search_label) $sql.=" AND l.label LIKE '%".$db->escape($search_label)."%'"; if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; } +$sql.= " GROUP BY l.rowid, l.label, l.capital, l.datestart, l.dateend"; $sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($limit + 1, $offset); +$sql.= $db->plimit($limit+1, $offset); //print $sql; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); + $i = 0; + $var=true; print_fiche_titre($langs->trans("Loans")); - $i = 0; - print ''."\n"; + print ''."\n"; print ''; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"l.rowid","",$param,"",$sortfield,$sortorder); @@ -101,9 +103,9 @@ if ($resql) // Filters lines print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; - $var=true; while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - + $var = !$var; print ""; // Ref - print ''; + print ''; // Label print ''; @@ -134,7 +132,7 @@ if ($resql) // Date start print ''; - print ''; + print ''; print "\n"; diff --git a/htdocs/compta/loan/payment/card.php b/htdocs/compta/loan/payment/card.php index d08c5f8ce0f..4dc1407e8ad 100644 --- a/htdocs/compta/loan/payment/card.php +++ b/htdocs/compta/loan/payment/card.php @@ -118,7 +118,6 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->loan->wri llxHeader(); $loan = new Loan($db); - $form = new Form($db); $h=0; @@ -168,7 +167,9 @@ print ''; // Amount -print ''; +print ''; +print ''; +print ''; // Note print ''; @@ -198,7 +199,7 @@ print '
   '; print ''; @@ -111,19 +113,15 @@ if ($resql) print '
'; - $loan->id = $obj->id; - print $loan->getNameUrl(1,'20'); - print ''.img_object($langs->trans("ShowLoan"),"label").' '.$obj->rowid.''.dol_trunc($obj->label,42).''.dol_print_date($db->jdate($obj->datestart), 'day').''.$loan->LibStatut($obj->paid,5,$obj->alreadypayed).''.$loan_static->LibStatut($obj->paid,5,$obj->alreadypayed).'
'.$langs->trans('Mode').''.$lan print '
'.$langs->trans('Number').''.$payment->num_payment.'
'.$langs->trans('Amount').''.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Capital').''.price($payment->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Insurance').''.price($payment->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Interest').''.price($payment->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($payment->note).'
'; */ $disable_delete = 0; -$sql = 'SELECT l.rowid as id, l.label, l.paid, l.capital as capital, pl.amount'; +$sql = 'SELECT l.rowid as id, l.label, l.paid, l.capital as capital, pl.amount_capital, pl.amount_insurance, pl.amount_interest'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl,'.MAIN_DB_PREFIX.'loan as l'; $sql.= ' WHERE pl.fk_loan = l.rowid'; $sql.= ' AND l.entity = '.$conf->entity; @@ -234,22 +235,22 @@ if ($resql) // Ref print ''; $loan->fetch($objp->id); - print $loan->getNameUrl(1); + print $loan->getLinkUrl(1); print "\n"; // Label print ''.$objp->label.''; // Expected to pay print ''.price($objp->capital).''; // Status - print ''.$loan->getLibStatut(4,$objp->amount).''; + print ''.$loan->getLibStatut(4,$objp->amount_capital).''; // Amount payed - print ''.price($objp->amount).''; + print ''.price($objp->amount_capital).''; print "\n"; - if ($objp->paye == 1) // If at least one invoice is paid, disable delete + if ($objp->paid == 1) // If at least one invoice is paid, disable delete { $disable_delete = 1; } - $total = $total + $objp->amount; + $total = $total + $objp->amount_capital; $i++; } } @@ -267,7 +268,7 @@ print '
'; /* - * Boutons Actions + * Actions buttons */ print '
'; diff --git a/htdocs/compta/loan/payment/payment.php b/htdocs/compta/loan/payment/payment.php index ed249d8f246..678ca1b8429 100644 --- a/htdocs/compta/loan/payment/payment.php +++ b/htdocs/compta/loan/payment/payment.php @@ -29,9 +29,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("bills"); $langs->load("loan"); -$chid=GETPOST("id"); +$chid=GETPOST('id','int'); $action=GETPOST('action'); $amounts = array(); +$cancel=GETPOST('cancel','alpha'); // Security check $socid=0; @@ -47,7 +48,7 @@ if ($action == 'add_payment') { $error=0; - if ($_POST["cancel"]) + if ($cancel) { $loc = DOL_URL_ROOT.'/compta/loan/card.php?id='.$chid; header("Location: ".$loc); @@ -98,12 +99,15 @@ if ($action == 'add_payment') // Create a line of payments $payment = new PaymentLoan($db); - $payment->chid = $chid; - $payment->datepaid = $datepaid; - $payment->amounts = $amounts; // Tableau de montant - $payment->paymenttype = $_POST["paymenttype"]; - $payment->num_payment = $_POST["num_payment"]; - $payment->note = $_POST["note"]; + $payment->chid = $chid; + $payment->datepaid = $datepaid; + $payment->amounts = $amounts; // Tableau de montant + $payment->amount_capital = $_POST["amount_capital"]; + $payment->amount_insurance = $_POST["amount_insurance"]; + $payment->amount_interest = $_POST["amount_interest"]; + $payment->paymenttype = $_POST["paymenttype"]; + $payment->num_payment = $_POST["num_payment"]; + $payment->note = $_POST["note"]; if (! $error) { @@ -177,12 +181,12 @@ if ($_GET["action"] == 'create') print ''; - print ""; + print ''; print ''; - print '\n"; + print '\n"; print '\n"; - print ''; + print ''; $sql = "SELECT sum(p.amount) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; @@ -204,7 +208,7 @@ if ($_GET["action"] == 'create') print '
".$langs->trans("Loan")."
'.$langs->trans("Loan").'
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("DateStart")."".dol_print_date($loan->datestart,'day')."
'.$langs->trans("DateStart").''.dol_print_date($loan->datestart,'day')."
'.$langs->trans("Label").''.$loan->label."
'.$langs->trans("Amount")."".price($loan->capital,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("Amount").''.price($loan->capital,0,$outputlangs,1,-1,-1,$conf->currency).'
'; print ''; - print "'; + print ''; print ''; 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 '
".$langs->trans("Payment").''.$langs->trans("Payment").'
'.$langs->trans("Date").''; @@ -249,10 +253,10 @@ if ($_GET["action"] == 'create') print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print "\n"; $var=True; @@ -269,24 +273,44 @@ if ($_GET["action"] == 'create') if ($objp->datestart > 0) { - print "\n"; + print ''; } else { - print "\n"; + print ''; } - print '"; + print '"; - print '"; + print '"; - print '"; + print '"; - print '"; print ''; - print ""; - print ""; - print ""; + print ''; + print ''; + print ''; print ''; print "\n"; } 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 95158c60a4f..0cbede46864 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 @@ -1099,48 +1099,6 @@ CREATE TABLE llx_usergroup_extrafields ( ALTER TABLE llx_usergroup_extrafields ADD INDEX idx_usergroup_extrafields (fk_object); --- Loan -create table llx_loan -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, - datec datetime, - tms timestamp, - label varchar(80) NOT NULL, - fk_bank integer, - capital real default 0 NOT NULL, - datestart date, - dateend date, - nbterm real, - rate double NOT NULL, - note text, - capital_position real default 0, - date_position date, - paid smallint default 0 NOT NULL, - accountancy_account_capital varchar(32), - accountancy_account_insurance varchar(32), - accountancy_account_interest varchar(32), - fk_user_author integer DEFAULT NULL, - fk_user_modif integer DEFAULT NULL, - active tinyint DEFAULT 1 NOT NULL -)ENGINE=innodb; - -create table llx_payment_loan -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_loan integer, - datec datetime, - tms timestamp, - datep datetime, - amount real DEFAULT 0, - fk_typepayment integer NOT NULL, - num_payment varchar(50), - note text, - fk_bank integer NOT NULL, - fk_user_creat integer, - fk_user_modif integer -)ENGINE=innodb; - ALTER TABLE llx_contrat ADD COLUMN model_pdf varchar(255) DEFAULT NULL AFTER note_public; ALTER TABLE llx_c_country ADD COLUMN favorite tinyint DEFAULT 0 AFTER active; 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 new file mode 100644 index 00000000000..93f2197de12 --- /dev/null +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -0,0 +1,63 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 3.8.0 or higher. +-- +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To restrict request to Mysql version x.y use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y use -- VPGSQLx.y +-- To make pk to be auto increment (mysql): VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE +-- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); +-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); + +-- Loan +create table llx_loan +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, + datec datetime, + tms timestamp, + label varchar(80) NOT NULL, + fk_bank integer, + capital real default 0 NOT NULL, + datestart date, + dateend date, + nbterm real, + rate double NOT NULL, + note text, + capital_position real default 0, + date_position date, + paid smallint default 0 NOT NULL, + accountancy_account_capital varchar(32), + accountancy_account_insurance varchar(32), + accountancy_account_interest varchar(32), + fk_user_author integer DEFAULT NULL, + fk_user_modif integer DEFAULT NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; + +create table llx_payment_loan +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_loan integer, + datec datetime, + tms timestamp, + datep datetime, + amount_capital real DEFAULT 0, + amount_insurance real DEFAULT 0, + amount_interest real DEFAULT 0, + fk_typepayment integer NOT NULL, + num_payment varchar(50), + note text, + fk_bank integer NOT NULL, + fk_user_creat integer, + fk_user_modif integer +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_payment_loan.sql b/htdocs/install/mysql/tables/llx_payment_loan.sql index 83bb3ac2548..0fb6b566ca5 100644 --- a/htdocs/install/mysql/tables/llx_payment_loan.sql +++ b/htdocs/install/mysql/tables/llx_payment_loan.sql @@ -23,7 +23,9 @@ create table llx_payment_loan datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount_capital real DEFAULT 0, + amount_insurance real DEFAULT 0, + amount_interest real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index 10fb0249f6d..9ccff4eecf4 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -5,10 +5,13 @@ NewLoan=New Loan ShowLoan=Show Loan PaymentLoan=Loan payment Capital=Capital +Insurance=Insurance +Interest=Interest Nbterms=Number of terms LoanAccountancyCapitalCode=Accountancy code capital LoanAccountancyInsuranceCode=Accountancy code insurance LoanAccountancyInterestCode=Accountancy code interest +LoanPayment=Loan payment ConfirmDeleteLoan=Confirm deleting this loan ConfirmPayLoan=Confirm classify paid this loan ErrorLoanCapital=Loan amount has to be numeric and greater than zero. diff --git a/htdocs/langs/fr_FR/loan.lang b/htdocs/langs/fr_FR/loan.lang index 1e54f90e2be..0a5c6320d5b 100644 --- a/htdocs/langs/fr_FR/loan.lang +++ b/htdocs/langs/fr_FR/loan.lang @@ -5,10 +5,13 @@ NewLoan=Nouvel emprunt ShowLoan=Voir emprunt PaymentLoan=Règlement d'emprunt Capital=Capital +Insurance=Assurance +Interest=Intérêt Nbterms=Nombre d'échéances LoanAccountancyCapitalCode=Compte comptable capital LoanAccountancyInsuranceCode=Compte comptable assurance LoanAccountancyInterestCode=Compte comptable intérêts +LoanPayment=Règlement emprunt ConfirmDeleteLoan=Confirmation de supression de cet emprunt ConfirmPayLoan=Confirmation que cet emprunt est classé comme payé ErrorLoanCapital=Le capital de l'emprunt doit être au format numérique et supérieur à zéro. From 15e44b6e28bc873e20a45133df22679167e02346 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 10 Nov 2014 06:39:37 +0100 Subject: [PATCH 044/940] Correct Auguria menu --- htdocs/core/menus/init_menu_auguria.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index a4833551f5b..bf35ac2806e 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -179,8 +179,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2211__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/salaries/card.php?leftmenu=tax_salary&action=create', 'NewPayment', 2, 'companies', '$user->rights->salaries->write', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->read', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled', __HANDLER__, 'left', 2220__+MAX_llx_menu__, 'accountancy', 'tax_loan', 2200__+MAX_llx_menu__, '/compta/loan/index.php?leftmenu=tax_loan&mainmenu=accountancy', 'Loans', 1, 'loan', '$user->rights->loan->read', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/loan/card.php?leftmenu=tax_loan&action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 0, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/loan/index.php?leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'accountancy', '', 2220__+MAX_llx_menu__, '/compta/loan/card.php?leftmenu=tax_loan&action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'accountancy', '', 2220__+MAX_llx_menu__, '/compta/loan/index.php?leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2250__+MAX_llx_menu__, 'accountancy', 'tax_social', 2200__+MAX_llx_menu__, '/compta/sociales/index.php?leftmenu=tax_social', 'SocialContributions', 1, '', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2251__+MAX_llx_menu__, 'accountancy', '', 2250__+MAX_llx_menu__, '/compta/sociales/charges.php?leftmenu=tax_social&action=create', 'MenuNewSocialContribution', 2, '', '$user->rights->tax->charges->creer', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2252__+MAX_llx_menu__, 'accountancy', '', 2250__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly', 'Payments', 2, '', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); From e9f754395d280e614bd8f59f9a16e9055124c137 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 10 Nov 2014 13:09:58 +0100 Subject: [PATCH 045/940] 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 046/940] 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 '
'.$langs->trans("DateDue").''.$langs->trans("Amount").''.$langs->trans("Capital").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").''.$langs->trans("Amount").'
".dol_print_date($objp->datestart,'day')."'.dol_print_date($objp->datestart,'day').'!!!!!!'.price($objp->capital)."'.price($objp->capital)."'.price($sumpaid)."'.price($sumpaid)."'.price($objp->capital - $sumpaid)."'.price($objp->capital - $sumpaid)."'; + print ''; if ($sumpaid < $objp->capital) { - $namef = "amount_".$objp->id; - print ''; + $namec = "amount_capital_".$objp->id; + print $langs->trans("Capital") .': '; + } + else + { + print '-'; + } + print '
'; + if ($sumpaid < $objp->capital) + { + $namea = "amount_insurance_".$objp->id; + print $langs->trans("Insurance") .': '; + } + else + { + print '-'; + } + print '
'; + if ($sumpaid < $objp->capital) + { + $namei = "amount_interest_".$objp->id; + print $langs->trans("Interest") .': '; } else { @@ -305,9 +329,9 @@ if ($_GET["action"] == 'create') // Print total print "
'.$langs->trans("Total").':".price($total_ttc)."".price($totalrecu)."".price($total_ttc - $totalrecu).""'.price($total_ttc).'""'.price($totalrecu).'""'.price($total_ttc - $totalrecu).'" 
'; 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 '
'; @@ -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 7c617b3515261a95c80f43855de2e8a91abaa561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 11 Nov 2014 11:21:31 +0100 Subject: [PATCH 047/940] Update card.php --- htdocs/expedition/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 8984e4c5424..1b1dbedfe59 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -664,7 +664,8 @@ if ($action == 'create') print ''.$langs->trans("DateDeliveryPlanned").''; print ''; //print dol_print_date($object->date_livraison,"day"); // date_livraison come from order and will be stored into date_delivery planed. - print $form->select_date($object->date_livraison?$object->date_livraison:-1,'date_delivery',1,1); + $date_delivery = ($date_delivery?$date_delivery:$object->date_livraison); // $date_delivery comes from GETPOST + print $form->select_date($date_delivery?$date_delivery:-1,'date_delivery',1,1); print "\n"; print ''; From c70539b3b220755594ffd4432f433fbdd7cd3c15 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 12 Nov 2014 07:33:03 +0100 Subject: [PATCH 048/940] Bug & merge --- htdocs/compta/bank/account.php | 2 +- htdocs/fichinter/card.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 858df658158..875fb4a7ab2 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -727,7 +727,7 @@ if ($id > 0 || ! empty($ref)) $loanstatic->label=$links[$key]['label']; } $loanstatic->ref=$loanstatic->label; - print $loanstatic->getNameUrl(1,16); + print $loanstatic->getLinkUrl(1,16); } else if ($links[$key]['type']=='member') { diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 77c7e17ffb5..4ffc31c9cab 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -748,10 +748,10 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg = dol_concatdesc($actionmsg, $message); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref); } From d15ef855da78952f3258c788ead2ba82aff75744 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 12 Nov 2014 07:37:59 +0100 Subject: [PATCH 049/940] Correct travis --- htdocs/langs/tr_TR/main.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/tr_TR/main.lang b/htdocs/langs/tr_TR/main.lang index 87b19cf7d91..63a4c3904c9 100644 --- a/htdocs/langs/tr_TR/main.lang +++ b/htdocs/langs/tr_TR/main.lang @@ -7,7 +7,7 @@ DIRECTION=ltr FONTFORPDF=DejaVuSans FONTSIZEFORPDF=8 SeparatorDecimal=, -SeparatorThousand=, +SeparatorThousand=Space FormatDateShort=%d/%m/%Y FormatDateShortInput=%d/%m/%Y FormatDateShortJava=dd/MM/yyyy From dfc5a98dc134ef76284d62044bdfa1306f78a919 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Nov 2014 01:05:30 +0100 Subject: [PATCH 050/940] =?UTF-8?q?Fix:=20[=20bug=20#1631=20]=20technical?= =?UTF-8?q?=20error=20in=20the=20display=20of=20associated=20objects=20/?= =?UTF-8?q?=20erreur=20technique=20=C3=A0=20l'affichage=20des=20objets=20a?= =?UTF-8?q?ssoci=C3=A9s=20=C3=A0=20un=20projet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/projet/class/project.class.php | 4 ++-- htdocs/projet/element.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index f294fa560ac..738eec46ec0 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -411,13 +411,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->jdate($dates)."'"; + $sql.=" AND ".$datefieldname." >= '".$this->db->idate($dates)."'"; } 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->jdate($datee)."'"; + $sql.=" AND ".$datefieldname." <= '".$this->db->idate($datee)."'"; } if (! $sql) return -1; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index c7f772ef93d..1d4218d1cb9 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2012 Juanjo Menent * @@ -155,7 +155,7 @@ print ''; print ''; -print '
'; +dol_fiche_end(); /* From 31b90cf3834b48f4fda5ab2f5b41a56326935943 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 17 Nov 2014 06:38:06 +0100 Subject: [PATCH 051/940] Add 1st version of calculator but need work --- htdocs/compta/loan/calc.php | 385 ++++++++++++++++++++++++ htdocs/core/menus/init_menu_auguria.sql | 1 + htdocs/core/menus/standard/eldy.lib.php | 1 + htdocs/core/modules/modLoan.class.php | 8 + htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/loan.lang | 2 + 6 files changed, 398 insertions(+) create mode 100644 htdocs/compta/loan/calc.php diff --git a/htdocs/compta/loan/calc.php b/htdocs/compta/loan/calc.php new file mode 100644 index 00000000000..5cc2c830094 --- /dev/null +++ b/htdocs/compta/loan/calc.php @@ -0,0 +1,385 @@ + + * Copyright (C) 2014 Alexandre Spangaro + * + * 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 . + */ + +require '../../main.inc.php'; + +$langs->load("loan"); + +/* --------------------------------------------------- * + * Set Form DEFAULT values + * --------------------------------------------------- */ +$default_sale_price = "150000"; +$default_annual_interest_percent = 7.0; +$default_year_term = 30; +$default_down_percent = 10; +$default_show_progress = TRUE; + +/* --------------------------------------------------- * + * Initialize Variables + * --------------------------------------------------- */ +$sale_price = 0; +$annual_interest_percent = 0; +$year_term = 0; +$down_percent = 0; +$this_year_interest_paid = 0; +$this_year_principal_paid = 0; +$form_complete = false; +$show_progress = false; +$monthly_payment = false; +$show_progress = false; +$error = false; + +/* --------------------------------------------------- * + * Set the USER INPUT values + * --------------------------------------------------- */ +if (isset($_REQUEST['form_complete'])) { + $sale_price = $_REQUEST['sale_price']; + $annual_interest_percent = $_REQUEST['annual_interest_percent']; + $year_term = $_REQUEST['year_term']; + $down_percent = $_REQUEST['down_percent']; + $show_progress = (isset($_REQUEST['show_progress'])) ? $_REQUEST['show_progress'] : false; + $form_complete = $_REQUEST['form_complete']; +} + +// This function does the actual mortgage calculations +// by plotting a PVIFA (Present Value Interest Factor of Annuity) +// table... +function get_interest_factor($year_term, $monthly_interest_rate) { + global $base_rate; + + $factor = 0; + $base_rate = 1 + $monthly_interest_rate; + $denominator = $base_rate; + for ($i=0; $i < ($year_term * 12); $i++) { + $factor += (1 / $denominator); + $denominator *= $base_rate; + } + return $factor; +} + +// If the form is complete, we'll start the math +if ($form_complete) { + // We'll set all the numeric values to JUST + // numbers - this will delete any dollars signs, + // commas, spaces, and letters, without invalidating + // the value of the number + $sale_price = preg_replace( "[^0-9.]", "", $sale_price); + $annual_interest_percent = preg_replace( "[^0-9.]", "", $annual_interest_percent); + $year_term = preg_replace( "[^0-9.]", "", $year_term); + $down_percent = preg_replace( "[^0-9.]", "", $down_percent); + + if (((float) $year_term <= 0) || ((float) $sale_price <= 0) || ((float) $annual_interest_percent <= 0)) { + $error = "You must enter a Sale Price of Home, Length of Motgage and Annual Interest Rate"; + } + + if (!$error) { + $month_term = $year_term * 12; + $down_payment = $sale_price * ($down_percent / 100); + $annual_interest_rate = $annual_interest_percent / 100; + $monthly_interest_rate = $annual_interest_rate / 12; + $financing_price = $sale_price - $down_payment; + $monthly_factor = get_interest_factor($year_term, $monthly_interest_rate); + $monthly_payment = $financing_price / $monthly_factor; + } +} else { + if (!$sale_price) { $sale_price = $default_sale_price; } + if (!$annual_interest_percent) { $annual_interest_percent = $default_annual_interest_percent; } + if (!$year_term) { $year_term = $default_year_term; } + if (!$down_percent) { $down_percent = $default_down_percent; } + if (!$show_progress) { $show_progress = $default_show_progress; } +} + +if ($error) { + print("" . $error . "

\n"); + $form_complete = false; +} + +/* + * View + */ + +llxHeader(); + +echo "This mortgage calculator can be used to figure out monthly payments of a home mortgage loan, + based on the home's sale price, the term of the loan desired, buyer's down payment percentage, and the loan's interest rate. + This calculator factors in PMI (Private Mortgage Insurance) for loans where less than 20% is put as a down payment. Also taken + into consideration are the town property taxes, and their effect on the total monthly mortgage payment.
"; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +if (! empty($show_progress)) +{ + print ''; +} +else +{ + print ''; +} + +print ''; +print '
Purchase & Financing Information
Sale Price of Home: '.$langs->trans("Currency".$conf->currency).'
Percentage Down:%
Length of Mortgage:years
Annual Interest Rate:%
Explain Calculations:Show me the calculations and amortizationShow me the calculations and amortization
'; + +print '
    '; +print '
'; + +// If the form has already been calculated, the $down_payment +// and $monthly_payment variables will be figured out, so we can show them in this table +if ($form_complete && $monthly_payment) +{ + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($down_percent < 20) + { + $pmi_per_month = 55 * ($financing_price / 100000); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; +} + +print '
Mortgage Payment Information
Down Payment:' . number_format($down_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
Amount Financed:' . number_format($financing_price, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
Monthly Payment:' . number_format($monthly_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
(Principal & Interest ONLY)
 '; + print '
'; + echo 'Since you are putting LESS than 20% down, you will need to pay PMI + (Private Mortgage Insurance), which tends + to be about $55 per month for every $100,000 financed (until you have paid off 20% of your loan). This could add + '."\$" . number_format($pmi_per_month, "2", ".", ",").' to your monthly payment.'; + print '
Monthly Payment:' . number_format(($monthly_payment + $pmi_per_month), "2", ".", ",") . $langs->trans("Currency".$conf->currency) . '
'; + print '(Principal & Interest, and PMI)
 '; + print '
'; + + $assessed_price = ($sale_price * .85); + $residential_yearly_tax = ($assessed_price / 1000) * 14; + $residential_monthly_tax = $residential_yearly_tax / 12; + + if ($pmi_per_month) + { + $pmi_text = "PMI and "; + } + + echo "Residential (or Property) Taxes are a little harder to figure out... In Massachusetts, the average resedential tax rate seems + to be around $14 per year for every $1,000 of your property's assessed value."; + + print '

'; + print "Let's say that your property's assessed value is 85% of what you actually paid for it - "; + print number_format($assessed_price, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . 'This would mean that your yearly residential taxes will be around'; + print number_format($residential_yearly_tax, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency); + print 'This could add ' . number_format($residential_monthly_tax, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . 'to your monthly payment'; + print '
TOTAL Monthly Payment:' . number_format(($monthly_payment + $pmi_per_month + $residential_monthly_tax), "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
'; + print '(including '.$pmi_text.' residential tax)
'; +print ''; + +// This prints the calculation progress and +// the instructions of HOW everything is figured +// out +if ($form_complete && $show_progress) { + $step = 1; + + print '

'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'. $step++ .''; + echo 'The down payment + = The price of the home multiplied by the percentage down divided by 100 (for 5% down becomes 5/100 or 0.05)

+ ' . number_format($down_payment,"2",".",",") . ' ' . $langs->trans("Currency".$conf->currency) . ' = '.number_format($sale_price,"2",".",",") . ' ' . $langs->trans("Currency".$conf->currency) . ' X + ('.$down_percent.' / 100)'; + print '
' . $step++ . ''; + print 'The interest rate = The annual interest percentage divided by 100

'; + print $annual_interest_rate . ' = ' . $annual_interest_percent . '% / 100'; + print '
'; + print 'The monthly factor = The result of the following formula:'; + print '
' . $step++ . ''; + print 'The monthly interest rate = The annual interest rate divided by 12 (for the 12 months in a year)

'; + print $monthly_interest_rate . ' = ' . $annual_interest_rate . ' / 12'; + print '
' . $step++ . ''; + print 'The month term of the loan in months = The number of years you\'ve taken the loan out for times 12

'; + print $month_term . ' Months = ' . $year_term . ' Years X 12'; + print '
' . $step++ . ''; + print 'The montly payment is figured out using the following formula:
'; + print 'Monthly Payment = ' . number_format($financing_price, "2", "", "") . ' * '; + print number_format($monthly_interest_rate, "4", "", "") . ' / '; + print '(1 - ((1 + ' . number_format($monthly_interest_rate, "4", "", "") . ')'; + print '-(' . $month_term . '))))'; + print '

'; + print 'The amortization breaks down how much of your monthly payment goes towards the bank\'s interest,'; + print 'and how much goes into paying off the principal of your loan.'; + print '
'; + print '
'; + + + // Set some base variables + $principal = $financing_price; + $current_month = 1; + $current_year = 1; + + // This basically, re-figures out the monthly payment, again. + $power = -($month_term); + $denom = pow((1 + $monthly_interest_rate), $power); + $monthly_payment = $principal * ($monthly_interest_rate / (1 - $denom)); + + print("

Amortization For Monthly Payment: \$" . number_format($monthly_payment, "2", ".", ",") . " over " . $year_term . " years
\n"); + + print ''; + + // This LEGEND will get reprinted every 12 months + $legend = ''; + $legend.= ''; + $legend.= ''; + $legend.= ''; + $legend.= ''; + $legend.= ''; + + echo $legend; + + // Loop through and get the current month's payments for + // the length of the loan + while ($current_month <= $month_term) + { + $interest_paid = $principal * $monthly_interest_rate; + $principal_paid = $monthly_payment - $interest_paid; + $remaining_balance = $principal - $principal_paid; + + $this_year_interest_paid = $this_year_interest_paid + $interest_paid; + $this_year_principal_paid = $this_year_principal_paid + $principal_paid; + + $var = !$var; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + + ($current_month % 12) ? $show_legend = FALSE : $show_legend = TRUE; + + if ($show_legend) { + print ''; + print ''; + print ''; + + $total_spent_this_year = $this_year_interest_paid + $this_year_principal_paid; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + $current_year++; + $this_year_interest_paid = 0; + $this_year_principal_paid = 0; + + if (($current_month + 6) < $month_term) + { + echo $legend; + } + } + $principal = $remaining_balance; + $current_month++; + } + print("
' . $langs->trans("Month") . '' . $langs->trans("Interest") . '' . $langs->trans("Capital") . '' . $langs->trans("Position") . '
' . $current_month . '' . number_format($interest_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '' . number_format($principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '' . number_format($remaining_balance, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '
' . $langs->trans("Totalsforyear") . ' ' . $current_year . '
 '; + print 'You will spend ' . number_format($total_spent_this_year, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . ' on your house in year ' . $current_year . '
'; + print number_format($this_year_interest_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . ' will go towards INTEREST
'; + print number_format($this_year_principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . ' will go towards PRINCIPAL
'; + print '
 
\n"); +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index bf35ac2806e..a0a91cab781 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -181,6 +181,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled', __HANDLER__, 'left', 2220__+MAX_llx_menu__, 'accountancy', 'tax_loan', 2200__+MAX_llx_menu__, '/compta/loan/index.php?leftmenu=tax_loan&mainmenu=accountancy', 'Loans', 1, 'loan', '$user->rights->loan->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'accountancy', '', 2220__+MAX_llx_menu__, '/compta/loan/card.php?leftmenu=tax_loan&action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'accountancy', '', 2220__+MAX_llx_menu__, '/compta/loan/index.php?leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2223__+MAX_llx_menu__, 'accountancy', '', 2220__+MAX_llx_menu__, '/compta/loan/calc.php?leftmenu=tax_loan', 'Calculator', 2, 'companies', '$user->rights->loan->calc', '', 0, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled', __HANDLER__, 'left', 2250__+MAX_llx_menu__, 'accountancy', 'tax_social', 2200__+MAX_llx_menu__, '/compta/sociales/index.php?leftmenu=tax_social', 'SocialContributions', 1, '', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2251__+MAX_llx_menu__, 'accountancy', '', 2250__+MAX_llx_menu__, '/compta/sociales/charges.php?leftmenu=tax_social&action=create', 'MenuNewSocialContribution', 2, '', '$user->rights->tax->charges->creer', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2252__+MAX_llx_menu__, 'accountancy', '', 2250__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly', 'Payments', 2, '', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 87c88ac028c..61ad1a4163f 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -817,6 +817,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/loan/index.php?leftmenu=tax_loan&mainmenu=accountancy",$langs->trans("Loans"),1,$user->rights->loan->read, '', $mainmenu, 'tax_loan'); if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/card.php?leftmenu=tax_loan&action=create",$langs->trans("NewLoan"),2,$user->rights->loan->write); if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/index.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read); + if (empty($leftmenu) || preg_match('/^tax_loan/i',$leftmenu)) $newmenu->add("/compta/loan/calc.php?leftmenu=tax_loan",$langs->trans("Calculator"),2,$user->rights->loan->calc); } // Social contributions diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index fb2de1e3a02..21ae96eba26 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -118,6 +118,14 @@ class modLoan extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'delete'; $this->rights[$r][5] = ''; + + $r++; + $this->rights[$r][0] = 525; + $this->rights[$r][1] = 'Access loan calculator'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'calc'; + $this->rights[$r][5] = ''; $r++; $this->rights[$r][0] = 527; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a56a68f3b66..b1d69ae015d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -698,6 +698,7 @@ Permission517=Export salaries Permission520=Read Loans Permission522=Create/modify loans Permission524=Delete loans +Permission525=Access loan calculator Permission527=Export loans Permission531=Read services Permission532=Create/modify services diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index 9ccff4eecf4..e59fc7898b8 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -17,6 +17,8 @@ ConfirmPayLoan=Confirm classify paid this loan ErrorLoanCapital=Loan amount has to be numeric and greater than zero. ErrorLoanLength=Loan length has to be numeric and greater than zero. ErrorLoanInterest=Annual interest has to be numeric and greater than zero. +# Calc +Totalsforyear=Totals for year # Admin ConfigLoan=Configuration of the module loan LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default From a9a8e9a73ce981e44aeac7b75ad834256e7f3265 Mon Sep 17 00:00:00 2001 From: Andrelec1 Date: Mon, 17 Nov 2014 14:55:22 +0100 Subject: [PATCH 052/940] Fix : more than 1000 holidays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Si il y a plus de 1000 jours de congés, le délimiteur des millier fais bugger les calcule ... --- htdocs/fichinter/card.php | 8 ++++---- htdocs/holiday/card.php | 1 - htdocs/holiday/class/holiday.class.php | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 77c7e17ffb5..4ffc31c9cab 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -748,10 +748,10 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg = dol_concatdesc($actionmsg, $message); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref); } diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 31a4e40599f..bbffe26cf9c 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -761,7 +761,6 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; } else print $form->select_users(GETPOST('userid')?GETPOST('userid'):$user->id,'userid',0,'',0); - //var_dump($cp->getConfCP('nbHolidayDeducted')); $nb_holiday = $cp->getCPforUser($user->id) / $cp->getConfCP('nbHolidayDeducted'); print '   '.$langs->trans('SoldeCPUser', round($nb_holiday,2)).''; print ''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 5381c99df07..2ecf8edfce3 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1045,7 +1045,8 @@ class Holiday extends CommonObject $result = $this->db->query($sql); if($result) { $obj = $this->db->fetch_object($result); - return number_format($obj->nb_holiday,2); + //return number_format($obj->nb_holiday,2); + return $obj->nb_holiday; } else { return '0'; } From f4a63b498bb76edda10634b62306408d30743f10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Nov 2014 15:09:52 +0100 Subject: [PATCH 053/940] Fix: bugs reported by scrutinizer --- htdocs/accountancy/class/bookkeeping.class.php | 1 + htdocs/core/class/extrafields.class.php | 7 +++---- htdocs/install/mysql/migration/repair.sql | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 861de271dab..6291790d008 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -31,6 +31,7 @@ class BookKeeping { var $db; var $error; + var $errors; var $id; var $doc_date; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5448df14010..a4396624f86 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -535,8 +535,7 @@ class ExtraFields $array_name_label=array(); // For avoid conflicts with external modules - if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) - return $array_name_label; + if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; @@ -569,13 +568,13 @@ class ExtraFields $this->attribute_alwayseditable[$tab->name]=$tab->alwayseditable; } } - - return $array_name_label; } else { print dol_print_error($this->db); } + + return $array_name_label; } diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 4083ba2f7b9..9b81f0ca78d 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -204,3 +204,13 @@ UPDATE llx_projet_task_time set task_datehour = task_date where task_datehour IS -- GRANT ALL ON *.* TO 'myuser'@'%'; -- flush privileges; +-- Fix type of product 2 does not exists +update llx_propaldet set product_type = 1 where product_type = 2; +update llx_commandedet set product_type = 1 where product_type = 2; +update llx_facturedet set product_type = 1 where product_type = 2; +--update llx_propaldet as d set d.product_type = 1 where d.fk_product = 22 and d.product_type = 0; +--update llx_commandedet as d set d.product_type = 1 where d.fk_product = 22 and d.product_type = 0; +--update llx_facturedet as d set d.product_type = 1 where d.fk_product = 22 and d.product_type = 0; + + + From da08e05e11af20d36f17fbee3e06fccc29d6170c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Nov 2014 14:26:06 +0100 Subject: [PATCH 054/940] Fix: Line not visible when there is a lot of lines. --- htdocs/comm/action/peruser.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index b6c3054f3a8..ddda7333947 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -659,10 +659,12 @@ while ($obj = $db->fetch_object($resql)) $todayarray=dol_getdate($now,'fast'); $sav = $tmpday; $showheader = true; +$var = false; foreach ($usernames as $username) { + $var = ! $var; echo ""; - echo '' . $username->getNomUrl(1). ''; + echo '' . $username->getNomUrl(1). ''; $tmpday = $sav; // Lopp on each day of week @@ -688,7 +690,7 @@ foreach ($usernames as $username) if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; if ($today) $style='cal_today_peruser'; - show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype); + show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); $i++; } @@ -785,9 +787,10 @@ $db->close(); * @param int $minheight Minimum height for each event. 60px by default. * @param boolean $showheader Show header * @param array $colorsbytype Array with colors by type + * @param string $var true or false for alternat style on tr/td * @return void */ -function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array()) +function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array(), $var=false) { global $db; global $user, $conf, $langs, $hookmanager, $action; @@ -989,8 +992,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & } - if ($h == $begin_h) echo ''; - else echo ''; + if ($h == $begin_h) echo ''; + else echo ''; if (count($cases1[$h]) == 1) // 1 seul evenement { $ids=array_keys($cases1[$h]); From 8b21cd402c4bed5a8996f3ef1f41554db75d471b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Nov 2014 14:36:16 +0100 Subject: [PATCH 055/940] Fix: Filter were lost --- htdocs/comm/action/peruser.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index ddda7333947..dcebefbcbb7 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -201,6 +201,7 @@ 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"; if ($pid) $param.="&projectid=".$pid; @@ -242,6 +243,20 @@ $nav.="   ('; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; +$nav.=''; + $nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1); $nav.=' '; $nav.=''; From 1d21141de212777bf900c4cca1ec145600c9f13a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Nov 2014 22:59:48 +0100 Subject: [PATCH 056/940] Fix: Bad vars --- htdocs/admin/security_other.php | 7 +++---- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 8c65d1f3359..6cbbe9185a0 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -107,7 +107,7 @@ else if ($action == 'MAIN_ANTIVIRUS_PARAM') } else if ($action == 'MAIN_APPLICATION_TITLE') { - if (! dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", $_POST["MAIN_SESSION_TIMEOUT"],'chaine',0,'',$conf->entity)) dol_print_error($db); + if (! dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", $_POST["MAIN_APPLICATION_TITLE"],'chaine',0,'',$conf->entity)) dol_print_error($db); else setEventMessage($langs->trans("RecordModifiedSuccessfully")); } @@ -176,11 +176,10 @@ if (empty($conf->global->MAIN_APPLICATION_TITLE)) $conf->global->MAIN_APPLICATIO print '
'; print ''; print ''; -print ''.$langs->trans("HiddeNumVersion").''; -print $form->textwithpicto('',$langs->trans("HiddeNumVersionExample",ini_get("session.gc_probability"),ini_get("session.gc_divisor"))); +print ''.$langs->trans("MAIN_APPLICATION_TITLE").''; print ''; print ''; -print ' '; +print ' '; print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 00f7ae43737..a075f99cd06 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1539,6 +1539,7 @@ ConfirmDeleteFiscalYear=Are you sure to delete this fiscal year ? Opened=Opened Closed=Closed AlwaysEditable=Can always be edited +MAIN_APPLICATION_TITLE=Force visible name of application Format=Format TypePaymentDesc=0:Customer payment type, 1:Supplier payment type, 2:Both customers and suppliers payment type From 44f3e64df207f87edc704b9aae267ea31b141ca6 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Wed, 19 Nov 2014 09:28:11 +0100 Subject: [PATCH 057/940] Update html.formcontract.class.php bad filtering on contract list (same sql rule as project) --- htdocs/core/class/html.formcontract.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index e0d550b4205..0eb2d4d4b26 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -65,7 +65,7 @@ class FormContract $sql.= " WHERE c.entity = ".$conf->entity; //if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")"; if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; - else $sql.= " AND c.fk_soc = ".$socid; + if ($socid > 0) $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; dol_syslog(get_class($this)."::select_contract", LOG_DEBUG); $resql=$db->query($sql); From 247da992c1e5526afbfdbfca06a4183f801520a8 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 19 Nov 2014 10:02:01 +0100 Subject: [PATCH 058/940] Fix: remove duplicate code --- htdocs/core/class/commonobject.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 12fee9deb8b..98bee3e052c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2011-2014 Philippe Grand * Copyright (C) 2012 Marcos García @@ -611,8 +611,6 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdparty = new Societe($this->db); $result=$thirdparty->fetch(isset($this->socid)?$this->socid:(isset($this->fk_soc)?$this->fk_soc:$this->fk_thirdparty)); $this->client = $thirdparty; // deprecated From dae9315374b084419b8897f9c0f208f0a34ff464 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Nov 2014 11:06:46 +0100 Subject: [PATCH 059/940] Fix: duplicate line --- htdocs/admin/security_other.php | 46 --------------------------------- 1 file changed, 46 deletions(-) diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index c72ff392b28..064f7ad0cd9 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -128,52 +128,6 @@ $head=security_prepare_head(); dol_fiche_head($head, 'misc', $langs->trans("Security")); -// Timeout -$var=true; - -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; - -$var=!$var; -$sessiontimeout=ini_get("session.gc_maxlifetime"); -if (empty($conf->global->MAIN_SESSION_TIMEOUT)) $conf->global->MAIN_SESSION_TIMEOUT=$sessiontimeout; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -$var=!$var; -$sessiontimeout=ini_get("session.gc_maxlifetime"); -if (empty($conf->global->MAIN_APPLICATION_TITLE)) $conf->global->MAIN_APPLICATION_TITLE=""; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -print '
'.$langs->trans("Parameters").''.$langs->trans("Value").' 
'.$langs->trans("SessionTimeOut").''; -print $form->textwithpicto('',$langs->trans("SessionExplanation",ini_get("session.gc_probability"),ini_get("session.gc_divisor"))); -print ''; -print ' '.strtolower($langs->trans("Seconds")); -print ''; -print ''; -print '
'.$langs->trans("MAIN_APPLICATION_TITLE").''; -print ''; -print ' '; -print ''; -print ''; -print '
'; -print '
'; - // Other Options $var=true; From 1246c20355e9e3471e0a90290dfb32b7442edb94 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Nov 2014 00:12:09 +0100 Subject: [PATCH 060/940] More complete translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 720da83ccfd..1834843c7be 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1539,7 +1539,7 @@ ConfirmDeleteFiscalYear=Are you sure to delete this fiscal year ? Opened=Opened Closed=Closed AlwaysEditable=Can always be edited -MAIN_APPLICATION_TITLE=Force visible name of application +MAIN_APPLICATION_TITLE=Force visible name of application (warning: setting your own name here may break autofill login feature when using DoliDroid mobile application) NbMajMin=Minimum number of uppercase characters NbNumMin=Minimum number of numeric characters NbSpeMin=Minimum number of special characters From d9fdf8239112891666f65b59e94959c44d1ce502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 01:21:51 +0100 Subject: [PATCH 061/940] (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers --- htdocs/commande/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index b152a38db02..2c30f4128c6 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -70,7 +70,7 @@ $limit = $conf->liste_limit; $viewstatut=GETPOST('viewstatut'); // Purge search criteria -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_categ=''; $search_user=''; From 54541f9f14cb27e7e06333bb4c9dbf45013104c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:29:04 +0100 Subject: [PATCH 062/940] Update /cron/list.php --- htdocs/cron/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 79e5ae5b1a4..3c2844f3fe4 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -64,7 +64,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_label=''; $status=-1; From a10209ae9ffa7c1ba51888c967c019558bc0a1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:30:32 +0100 Subject: [PATCH 063/940] Update /holiday/index.php --- htdocs/holiday/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php index e988e640711..86c4eca49eb 100644 --- a/htdocs/holiday/index.php +++ b/htdocs/holiday/index.php @@ -64,7 +64,7 @@ $search_employe = GETPOST('search_employe'); $search_valideur = GETPOST('search_valideur'); $search_statut = GETPOST('select_statut'); -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $month_create=""; From 46aea31e6c3401c4c90c26cacc6836f5bd547e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:31:20 +0100 Subject: [PATCH 064/940] Update /comm/list.php --- htdocs/comm/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php index ce7eb82f9a1..b35e4fab7cc 100644 --- a/htdocs/comm/list.php +++ b/htdocs/comm/list.php @@ -75,7 +75,7 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $a if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_sale=""; $search_categ=""; From b43f8eede36fcdc4eb7c422970b3634b2c423d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:32:46 +0100 Subject: [PATCH 065/940] Update /fichinter/list.php --- htdocs/fichinter/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index a6d3f9720ec..9030cd9c4ac 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -62,7 +62,7 @@ $search_desc=GETPOST('search_desc','alpha'); $search_status=GETPOST('search_status'); $sall=GETPOST('sall'); -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_company=""; From 91aca474ddd4d536f11ee31fe4080cfe9c1abcf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:33:32 +0100 Subject: [PATCH 066/940] Update /expedition/list.php --- htdocs/expedition/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index af1d244e0d0..0722dedddf4 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -52,7 +52,7 @@ if (! $sortorder) $sortorder="DESC"; $limit = $conf->liste_limit; // Purge search criteria -if (GETPOST("button_removefilter_x")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref_exp=''; $search_ref_liv=''; From 6f3ce0a63b3ae6ce115d1e61a8d3b8d82eb2a387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:34:20 +0100 Subject: [PATCH 067/940] Update /contrat/services.php --- htdocs/contrat/services.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index b0fb4ed5edb..22ae64ef9cd 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -69,7 +69,7 @@ $staticcontrat=new Contrat($db); $staticcontratligne=new ContratLigne($db); $companystatic=new Societe($db); -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_name=""; $search_contract=""; From 7442b1a6b123190555cd75a3713e328247018d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:34:56 +0100 Subject: [PATCH 068/940] Update /contrat/list.php --- htdocs/contrat/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index b1b28192395..debe18e995e 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -58,7 +58,7 @@ $result = restrictedArea($user, 'contrat', $id); $staticcontrat=new Contrat($db); $staticcontratligne=new ContratLigne($db); -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_name=""; $search_contract=""; From 89deffa3a7e2856369a980767f40de0443935f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:36:07 +0100 Subject: [PATCH 069/940] Update /fourn/list.php --- htdocs/fourn/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/list.php b/htdocs/fourn/list.php index 296415c1aee..b0d7caf8695 100644 --- a/htdocs/fourn/list.php +++ b/htdocs/fourn/list.php @@ -60,7 +60,7 @@ if (! $sortfield) $sortfield="nom"; // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('supplierlist')); -if (GETPOST("button_removefilter_x")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $socname=""; $search_name=""; From 09f1f79f4eaca8423dc1c2cd49a7202f9ee10bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:46:24 +0100 Subject: [PATCH 070/940] Update /adherents/list.php --- htdocs/adherents/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 887bac4e1e7..b70e212d2d2 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -59,7 +59,7 @@ $pagenext = $page + 1; if (! $sortorder) { $sortorder=($filter=='outofdate'?"ASC":"DESC"); } if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search=""; $search_ref=""; From fbee671db1d3dcbea2681e73995eb3934d812de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:47:19 +0100 Subject: [PATCH 071/940] Update /societe/consumption.php --- 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 f89212e5fbc..d5ef1af6dbb 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -58,7 +58,7 @@ $month = GETPOST('month','int'); $year = GETPOST('year','int'); // Clean up on purge search criteria ? -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $sref=''; $sprod_fulldescr=''; From 5b0b222772bfdf038a1669363983133e3493a72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:48:13 +0100 Subject: [PATCH 072/940] Update /societe/societe.php --- htdocs/societe/societe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/societe.php b/htdocs/societe/societe.php index f0b3532018b..2d046a3ec16 100644 --- a/htdocs/societe/societe.php +++ b/htdocs/societe/societe.php @@ -153,7 +153,7 @@ llxHeader('',$langs->trans("ThirdParty"),$help_url); // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_categ=''; $search_sale=''; From 979eadf42e6d287cb3757369a5357371b4a3e4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:48:54 +0100 Subject: [PATCH 073/940] Update /compta/dons/list.php --- htdocs/compta/dons/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/dons/list.php b/htdocs/compta/dons/list.php index 174b5357bb2..95011ca0b74 100644 --- a/htdocs/compta/dons/list.php +++ b/htdocs/compta/dons/list.php @@ -50,7 +50,7 @@ $search_amount = GETPOST('search_amount','alpha'); if (!$user->rights->don->lire) accessforbidden(); -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_company=""; From d6e8211018e6b5f5516c3258a270e4c3ba029ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:49:30 +0100 Subject: [PATCH 074/940] Update /compta/deplacement/list.php --- htdocs/compta/deplacement/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 42a6713c1ce..e34e7c2b3a6 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -57,7 +57,7 @@ $limit = $conf->liste_limit; $year=GETPOST("year"); $month=GETPOST("month"); -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_name=""; From 37eef59b5083016af34a708052b55aa302d7663d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:50:19 +0100 Subject: [PATCH 075/940] Update /compta/prelevement/list.php --- htdocs/compta/prelevement/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 0a68aa686ae..921736faedf 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -53,7 +53,7 @@ $ligne=new LignePrelevement($db,$user); $offset = $conf->liste_limit * $page ; -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_line=""; $search_bon=""; From adf0e8bb54f01fe60af1e457f4bcda5155c3cb0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:51:03 +0100 Subject: [PATCH 076/940] Update /compta/tva/reglement.php --- htdocs/compta/tva/reglement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index ebba3888004..45a69076492 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -66,7 +66,7 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_label=""; From fe725f1d8ad3804434f4477e12ba562757229715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:51:49 +0100 Subject: [PATCH 077/940] Update /compta/sociales/index.php --- htdocs/compta/sociales/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index db4bef2abe6..31e98370003 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -68,7 +68,7 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_label=""; From cfe5784d494289b67425f3689067fcb6176b7db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:52:35 +0100 Subject: [PATCH 078/940] Update /compta/bank/search.php --- htdocs/compta/bank/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index 1e8196481e6..127e428162c 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -73,7 +73,7 @@ $limit = $conf->liste_limit; if (! $sortorder) $sortorder='DESC'; if (! $sortfield) $sortfield='b.dateo'; -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $description=""; $type=""; From c9a0208328ff029d8def311815ce99d4fdcc9f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:53:19 +0100 Subject: [PATCH 079/940] Update /compta/paiement/list.php --- htdocs/compta/paiement/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 65615b9bbf3..c7fd426babf 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -58,7 +58,7 @@ $limit = $conf->liste_limit; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="p.rowid"; -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_account=""; From 865ec76a51c5068313c21f5a10b98db3c31c2e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:54:17 +0100 Subject: [PATCH 080/940] Update /compta/salaries/index.php --- htdocs/compta/salaries/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 17c3efdbfaa..678b3bfaa2e 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -64,7 +64,7 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_label=""; From fef3cfbe811b692da10082b2eb501e10c0dfafd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:55:13 +0100 Subject: [PATCH 081/940] Update /compta/facture/list.php --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index ba27f5659a9..56bd57c725a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -111,7 +111,7 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_categ=''; $search_user=''; From 0ea40c155ebebbeb3460481295a9602a5da1fc34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:57:21 +0100 Subject: [PATCH 082/940] Update /compta/facture/impayees.php --- htdocs/compta/facture/impayees.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index c762aac5702..a010e7d7401 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -374,7 +374,7 @@ $search_montant_ttc = GETPOST("search_montant_ttc"); $late = GETPOST("late"); // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=''; $search_refcustomer=''; From 5f1135454754c06278b724ee24359094a5b5bb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:58:19 +0100 Subject: [PATCH 083/940] Update /accountancy/admin/account.php --- htdocs/accountancy/admin/account.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 36739254d06..0c2a825604b 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -88,7 +88,7 @@ if ($action == 'disable') { } } -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_account=""; $search_label=""; @@ -220,4 +220,4 @@ if ($result) { } llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); From e1addea6dbcdb3fe68d8cc39ee4012cdd76710e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 09:59:05 +0100 Subject: [PATCH 084/940] Update /accountancy/bookeeping/list.php --- htdocs/accountancy/bookkeeping/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 21da5bacbb9..b2acc60fb6a 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -51,7 +51,7 @@ $offset = $conf->liste_limit * $page; $formventilation = new FormVentilation($db); -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_doc_type=""; $search_doc_ref=""; @@ -231,4 +231,4 @@ else { } llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); From 8356c1b5602f05f7d81ab7b84290e84e87e62dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 10:00:09 +0100 Subject: [PATCH 085/940] Update /comm/actions/listactions.php --- htdocs/comm/action/listactions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 53243d0c165..245902013a1 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -100,7 +100,7 @@ if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permi } // Purge search criteria -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $datestart=''; $dateend=''; From c6f71344145e0abebc5c7a9b9edf2d56defb05d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 10:01:07 +0100 Subject: [PATCH 086/940] Update /comm/prospect/list.php --- htdocs/comm/prospect/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 113618ffae8..3501d94aafd 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -154,7 +154,7 @@ $sts = array(-1,0,1,2,3); $hookmanager->initHooks(array('prospectlist')); // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $socname=""; $stcomm=""; From 8bbc2d8db4998a0e9c9df1fd42ea1737daabaf0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 10:02:16 +0100 Subject: [PATCH 087/940] Update /product/stock/mouvement.php --- htdocs/product/stock/mouvement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 06e089c5209..83d856ed0cc 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -60,7 +60,7 @@ $offset = $conf->liste_limit * $page; if (! $sortfield) $sortfield="m.datem"; if (! $sortorder) $sortorder="DESC"; -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $year=''; $month=''; From 018d1488fc353ed253173cd0839eb2c35ba7afb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 10:03:03 +0100 Subject: [PATCH 088/940] Update /fourn/commande/list.php --- htdocs/fourn/commande/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index ab0fd08d3f0..6affbae3045 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -58,7 +58,7 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); // Purge search criteria -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=''; $search_refsupp=''; From edaf6aec100c72911900d09842aa7a4f02c1f37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 10:04:43 +0100 Subject: [PATCH 089/940] Update /fourn/facture/paiement.php --- htdocs/fourn/facture/paiement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 57100bd98f0..65428cd138e 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -459,7 +459,7 @@ if (empty($action)) $search_amount=GETPOST('search_amount'); $search_company=GETPOST('search_company'); - if (GETPOST("button_removefilter")) + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_account=""; From 38febad979a1e0cbc6250583b502152249db034d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 10:05:40 +0100 Subject: [PATCH 090/940] Update /fourn/facture/impayees.php --- htdocs/fourn/facture/impayees.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php index 2767c792f9e..83d4b830c5f 100644 --- a/htdocs/fourn/facture/impayees.php +++ b/htdocs/fourn/facture/impayees.php @@ -64,7 +64,7 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield="f.date_lim_reglement"; if (! $sortorder) $sortorder="ASC"; -if (GETPOST("button_removefilter")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_ref_supplier=""; From ffb4dd9e3de6abea3892ea95c2c70a4409026a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 10:06:40 +0100 Subject: [PATCH 091/940] Update /compta/paiement/cheque/list.php --- htdocs/compta/paiement/cheque/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 47a6ee8ba74..fdfe86ec178 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -61,7 +61,7 @@ $checkdepositstatic=new RemiseCheque($db); $accountstatic=new Account($db); // If click on purge search criteria ? -if (GETPOST("button_removefilter_x")) +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=''; $search_amount=''; From de48a048446f6e9dc0c7ce6e4a3b7e13c139a4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 23 Nov 2014 12:53:00 +0100 Subject: [PATCH 092/940] Fix: W3C. form into table is forbidden. --- htdocs/comm/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 4129b561ed1..fd25287c029 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -90,15 +90,15 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { $var=false; - print ''; print ''; print ''; + print '
'; print ''; print ''; print ''; print ''; - print "
'.$langs->trans("SearchACustomerOrder").'
'; print ':
:

\n"; + print "
\n"; } // Search contract From 9f73277ef2793842f1110375c6d4e10b51c82b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 13:14:54 +0100 Subject: [PATCH 093/940] Fixed [ bug #1642 ]: add a free line in contract --- htdocs/contrat/card.php | 6 ++--- .../contract/doc/pdf_strato.modules.php | 24 ++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 20fd6939f5d..dfdf0e95a87 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -536,10 +536,10 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; - if (empty($model)) { $tmp=getListOfModels($db, 'contract'); $keys=array_keys($tmp); $model=$keys[0]; } + $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST ['prod_entry_mode']); diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index bd4cc333743..4c609bc100c 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -53,6 +53,18 @@ class pdf_strato extends ModelePDFContract var $marge_haute; var $marge_basse; + /** + * Issuer + * @var Societe + */ + public $emetteur; + + /** + * Recipient + * @var Societe + */ + public $recipient; + /** * Constructor * @@ -581,17 +593,17 @@ class pdf_strato extends ModelePDFContract $result=$object->fetch_contact($arrayidcontact[0]); } + $this->recipient = $object->client; + // Recipient name - if (! empty($usecontact)) - { + if (! empty($usecontact)) { // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; else $socname = $object->client->name; - $this->recipient->name=$outputlangs->convToOutputCharset($socname); + $this->recipient->name = $outputlangs->convToOutputCharset($socname); } - else - { - $this->recipient->name=$outputlangs->convToOutputCharset($object->client->name); + else { + $this->recipient->name = $outputlangs->convToOutputCharset($object->client->name); } $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, (isset($object->contact)?$object->contact:''), $usecontact, 'target'); From 6cb3bafd9381966b4b45b3147f11d07044fe1bd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Nov 2014 15:41:13 +0100 Subject: [PATCH 094/940] Debug travis pb --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 57781d47e44..830923fa8f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,6 +83,7 @@ before_script: - sudo cat /etc/apache2/sites-available/default - sudo /etc/init.d/apache2 restart - wget http://localhost/ + - ls /var/log/apache2/* - cat index.html From 835b359179b0119fefde05ffe781547002c2ff0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 15:42:29 +0100 Subject: [PATCH 095/940] Fixed [ bug #1658 ] Linked files in supplier invoices wrongly shows amounts --- htdocs/fourn/facture/document.php | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index d47433af4f5..c7219c6e415 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -168,30 +168,6 @@ if ($object->id > 0) print $form->editfieldval("Label",'label',$object->label,$object,0); print ''; - // Status - $alreadypaid=$object->getSommePaiement(); - print ''.$langs->trans('Status').''.$object->getLibStatut(4,$alreadypaid).''; - - // Amount - print ''.$langs->trans('AmountHT').''.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).''; - print ''.$langs->trans('AmountVAT').''.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).''; - - // Amount Local Taxes - //TODO: Place into a function to control showing by country or study better option - if ($societe->localtax1_assuj=="1") //Localtax1 - { - print ''.$langs->transcountry("AmountLT1",$societe->country_code).''; - print ''.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).''; - print ' '; - } - if ($societe->localtax2_assuj=="1") //Localtax2 - { - print ''.$langs->transcountry("AmountLT2",$societe->country_code).''; - print ''.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).''; - print ''; - } - print ''.$langs->trans('AmountTTC').''.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).''; - print '
'; print ''; From 3f06274d5e09570f9699831be5376edeb3b68907 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Nov 2014 15:54:59 +0100 Subject: [PATCH 096/940] Debug travis pb --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 830923fa8f1..393db48438b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,7 +83,7 @@ before_script: - sudo cat /etc/apache2/sites-available/default - sudo /etc/init.d/apache2 restart - wget http://localhost/ - - ls /var/log/apache2/* + - cat /var/log/apache2/error.log - cat index.html From 7d719743621a3e25acc5c5894591b35f03180c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 16:14:12 +0100 Subject: [PATCH 097/940] Fixed [ bug #1712 ] Unable to add a social charge --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 72b7c8fe549..05402898ee6 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -192,7 +192,7 @@ $tabfield[3] = "code,libelle,country_id,country"; $tabfield[4] = "code,label"; $tabfield[5] = "code,label"; $tabfield[6] = "code,libelle,type,color,position"; -$tabfield[7] = "code,libelle,country_id,country,accountancy_code,deductible"; +$tabfield[7] = "code,libelle,country,accountancy_code,deductible"; $tabfield[8] = "code,libelle,country_id,country"; $tabfield[9] = "code,label,unicode"; $tabfield[10]= "country_id,country,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; From bd765ef3ae5922e35deb0a6b28d0f966de99e391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 16:17:09 +0100 Subject: [PATCH 098/940] Fixed [ bug #1705 ] Members statistics menu entry strange target --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index db8f216fd60..e637455152e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1233,7 +1233,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=uptodate",$langs->trans("MenuMembersUpToDate"),2,$user->rights->adherent->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=outofdate",$langs->trans("MenuMembersNotUpToDate"),2,$user->rights->adherent->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=0",$langs->trans("MenuMembersResiliated"),2,$user->rights->adherent->lire); - $newmenu->add("/adherents/stats/geo.php?leftmenu=members&mode=memberbycountry",$langs->trans("MenuMembersStats"),1,$user->rights->adherent->lire); + $newmenu->add("/adherents/stats/index.php?leftmenu=members",$langs->trans("MenuMembersStats"),1,$user->rights->adherent->lire); $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members",$langs->trans("Subscriptions"),0,$user->rights->adherent->cotisation->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=-1,1&mainmenu=members",$langs->trans("NewSubscription"),1,$user->rights->adherent->cotisation->creer); From 4f83eea3cf9add94885b0ea1069631b8e7da930f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 16:22:38 +0100 Subject: [PATCH 099/940] Fixed[ bug #1661 ] Bookmarks list "Target" translation missing --- htdocs/bookmarks/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 61dc0a91d7e..a22b24388b1 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -25,6 +25,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; $langs->load("bookmarks"); +$langs->load("admin"); // Security check if (! $user->rights->bookmark->lire) { From a1cc95d35271e8b4040ae5b1f3198ed7048a89a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 16:26:55 +0100 Subject: [PATCH 100/940] Fixed design of edit page of a bookmark --- htdocs/bookmarks/card.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 640e7e72c57..1d217b64154 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -153,7 +153,7 @@ if ($action == 'create') print_fiche_titre($langs->trans("NewBookmark")); - dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark'); + dol_fiche_head($head, 'card', $langs->trans("Bookmark"),0,'bookmark'); print '
'; @@ -196,8 +196,15 @@ if ($id > 0 && ! preg_match('/^add/i',$action)) $bookmark=new Bookmark($db); $bookmark->fetch($id); + $head = array( + array( + '', + $langs->trans('Card'), + 'card' + ) + ); - dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark'); + dol_fiche_head($head, 'card', $langs->trans("Bookmark"),0,'bookmark'); if ($action == 'edit') { From d2762f50779c4c9efcedf6687d9580ee107e4709 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Nov 2014 16:28:25 +0100 Subject: [PATCH 101/940] Debug travis pb --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 393db48438b..26111b8ae48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,7 +83,7 @@ before_script: - sudo cat /etc/apache2/sites-available/default - sudo /etc/init.d/apache2 restart - wget http://localhost/ - - cat /var/log/apache2/error.log + - sudo ls /var/log/apache2/* - cat index.html From be2fe19e03d1309c33cdb590696d0e18ab913dca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Nov 2014 16:31:37 +0100 Subject: [PATCH 102/940] Debug travis pb --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 26111b8ae48..94452733a5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,7 +83,7 @@ before_script: - sudo cat /etc/apache2/sites-available/default - sudo /etc/init.d/apache2 restart - wget http://localhost/ - - sudo ls /var/log/apache2/* + - sudo ls /var/log/apache/* - cat index.html From 26a652814f6ccdda527bf810dd47dcf7da4910a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Nov 2014 16:34:56 +0100 Subject: [PATCH 103/940] Debug travis pb --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 26111b8ae48..f9c1e097af0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,7 +83,7 @@ before_script: - sudo cat /etc/apache2/sites-available/default - sudo /etc/init.d/apache2 restart - wget http://localhost/ - - sudo ls /var/log/apache2/* + - sudo cat /etc/apache2/envvars - cat index.html From 89e3e3bee3192425ff218c19230f25b357582903 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Nov 2014 16:38:59 +0100 Subject: [PATCH 104/940] Debug travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index feb9f034f6e..8140caba269 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,8 +83,8 @@ before_script: - sudo cat /etc/apache2/sites-available/default - sudo /etc/init.d/apache2 restart - wget http://localhost/ - - echo ${APACHE_LOG_DIR} - sudo cat /etc/apache2/envvars + - sudo ls /var/log/apache2* - cat index.html From c40be71dcdd817e19619983acf92d6754578bfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 16:44:49 +0100 Subject: [PATCH 105/940] Fixed design of new bookmark page --- htdocs/bookmarks/card.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 1d217b64154..2c1c61c5981 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -153,8 +153,6 @@ if ($action == 'create') print_fiche_titre($langs->trans("NewBookmark")); - dol_fiche_head($head, 'card', $langs->trans("Bookmark"),0,'bookmark'); - print '
'; print ''; @@ -183,8 +181,6 @@ if ($action == 'create') print ''; print ''; - - dol_fiche_end(); } @@ -220,12 +216,12 @@ if ($id > 0 && ! preg_match('/^add/i',$action)) print ''; - print ''; - print ''; From b83e4cffb08e68e9365189bbe376728e553ded3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Nov 2014 16:45:33 +0100 Subject: [PATCH 106/940] Debug travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8140caba269..dc2c543b07e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -84,7 +84,7 @@ before_script: - sudo /etc/init.d/apache2 restart - wget http://localhost/ - sudo cat /etc/apache2/envvars - - sudo ls /var/log/apache2* + - sudo cat /var/log/apache2/error.log - cat index.html From 52eb4943e2492a0a733800e1c557f96b3bf35e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 16:46:48 +0100 Subject: [PATCH 107/940] Fixed entities problems in error messages when creating a bookmark --- htdocs/bookmarks/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 2c1c61c5981..5e8f770c91c 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -69,12 +69,12 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') if (! $title) { $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle")), 'errors'); + setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("BookmarkTitle")), 'errors'); } if (! $url) { $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink")), 'errors'); + setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("UrlOrLink")), 'errors'); } if (! $error) @@ -95,7 +95,7 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') if ($bookmark->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessage($langs->trans("WarningBookmarkAlreadyExists"), 'warnings'); + setEventMessage($langs->transnoentities("WarningBookmarkAlreadyExists"), 'warnings'); } else { From 373bdcf5d7cc1169c1c3039626aa749534c2fa4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 16:54:09 +0100 Subject: [PATCH 108/940] Fixed problem when editing a bookmark and failing --- htdocs/bookmarks/card.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 5e8f770c91c..9e115a611e6 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -50,6 +50,13 @@ $backtopage=GETPOST('backtopage','alpha'); if ($action == 'add' || $action == 'addproduct' || $action == 'update') { + + if ($action == 'update') { + $invertedaction = 'edit'; + } else { + $invertedaction = 'create'; + } + $error = 0; if (GETPOST("cancel")) @@ -101,12 +108,12 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') { setEventMessage($bookmark->error, 'errors'); } - $action='create'; + $action = $invertedaction; } } else { - $action='create'; + $action = $invertedaction; } } From 231ad04fbd5555b42a535934226141e1830359d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 16:58:46 +0100 Subject: [PATCH 109/940] Highlight of required fields should be only in edit mode --- htdocs/bookmarks/card.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 9e115a611e6..5896f63106a 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2013 Laurent Destailleur + * 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 @@ -223,12 +224,31 @@ if ($id > 0 && ! preg_match('/^add/i',$action)) print ''; - print ''; - print ''; From b76a58b898d64f7548de2d8d813298641786112a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 17:03:25 +0100 Subject: [PATCH 110/940] Fixed typo --- htdocs/bookmarks/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index a22b24388b1..748a4d9b7fa 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -59,7 +59,7 @@ if ($_GET["action"] == 'delete') } else { - $setEventMessage($bookmark->error, 'errors'); + setEventMessage($bookmark->error, 'errors'); } } From 496a3fcaaef0f6e4a36bfe8d9aff9fad8b23d24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 17:06:51 +0100 Subject: [PATCH 111/940] Removed unused action of card.php --- htdocs/bookmarks/card.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 5896f63106a..05d6a0b4843 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -118,28 +118,6 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') } } -if ($action == 'delete') -{ - $bookmark=new Bookmark($db); - $bookmark->id=$_GET["bid"]; - $bookmark->url=$user->id; - $bookmark->target=$user->id; - $bookmark->title='xxx'; - $bookmark->favicon='xxx'; - - $res=$bookmark->remove(); - if ($res > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - setEventMessage($bookmark->error, 'errors'); - } -} - - /* * View */ From 912384a9fad737c007dbe449cec47bd85cd64884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 17:24:37 +0100 Subject: [PATCH 112/940] Fixed [ bug #1679 ] Can't sort groups by user count in user groups list --- htdocs/user/group/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index 00af5b0e6d2..1f06fa3a3c2 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -91,7 +91,7 @@ if ($resql) { print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],"g.entity",$param,"",'align="center"',$sortfield,$sortorder); } - print_liste_field_titre($langs->trans("NbOfUsers"),$_SERVER["PHP_SELF"],"g.nb",$param,"",'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("NbOfUsers"),$_SERVER["PHP_SELF"],"nb",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"g.datec",$param,"",'align="right"',$sortfield,$sortorder); print "\n"; $var=True; From bbdd25f97cde68b4ad46a2f2f268ddd3eee08f6c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 23 Nov 2014 21:37:45 +0100 Subject: [PATCH 113/940] Add function purge criteria in project module --- htdocs/projet/list.php | 14 ++++++++++++-- htdocs/projet/tasks/index.php | 13 ++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b4260e8ea91..614f91468cc 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -63,6 +63,14 @@ $search_label=GETPOST("search_label"); $search_societe=GETPOST("search_societe"); $search_all=GETPOST("search_all"); +// Purge criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=""; + $search_label=""; + $search_societe=""; + $search_all=0; +} /* * View @@ -147,8 +155,10 @@ if ($resql) print ''; print ''; print ''; - print ''; - print "\n"; + print ''; while ($i < $num) { diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index cdf90a918a3..4354fc23b2c 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -51,7 +51,13 @@ $page = $page == -1 ? 0 : $page; $mine = $_REQUEST['mode']=='mine' ? 1 : 0; - +// Purge criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_project=""; + $search_status=""; +} +if (empty($search_status)) $search_status=1; /* * View @@ -122,9 +128,10 @@ print $form->selectarray('search_status', $listofstatus, $search_status); print ''; print ''; -print ''; -print "\n"; if (count($tasksarray) > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)) { From ef991e6c5dff769ca1eb5e776df956971d2ea1b7 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 24 Nov 2014 06:43:15 +0100 Subject: [PATCH 114/940] HTML5 -
is deprecated - Need CSS - continue working --- htdocs/product/price.php | 21 +++++++++++++++------ htdocs/product/stock/card.php | 11 ++++++++--- htdocs/product/stock/mouvement.php | 17 ++++++++++++----- htdocs/product/stock/product.php | 14 ++++++++++---- htdocs/product/traduction.php | 16 ++++++++++------ htdocs/projet/card.php | 4 ++-- htdocs/projet/tasks/task.php | 7 ++++--- htdocs/public/demo/index.php | 2 +- htdocs/public/members/new.php | 12 ++++++------ htdocs/public/paybox/newpayment.php | 4 ++-- htdocs/public/paypal/newpayment.php | 4 ++-- htdocs/societe/checkvat/checkVatPopup.php | 2 +- htdocs/societe/price.php | 14 ++++++++++---- htdocs/societe/rib.php | 16 ++++++++++------ htdocs/societe/soc.php | 10 +++++----- htdocs/user/agenda_extsites.php | 4 ++-- htdocs/user/card.php | 8 ++++---- htdocs/user/clicktodial.php | 6 +++--- htdocs/user/group/card.php | 4 ++-- htdocs/user/note.php | 6 +++--- htdocs/user/param_ihm.php | 6 +++--- htdocs/webservices/admin/webservices.php | 4 ++-- 22 files changed, 117 insertions(+), 75 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 3ff496356a8..bfd0b91fc5f 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -669,8 +669,11 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print '
'.$langs->trans("BookmarkTitle").''.$langs->trans("SetHereATitleForLink").'
'.$langs->trans("Ref").''.$bookmark->ref.'
'.$langs->trans("BookmarkTitle").''; + print '
'.$langs->trans("BookmarkTitle").''; if ($action == 'edit') print 'title).'">'; else print $bookmark->title; print '
'.$langs->trans("UrlOrLink").''; + print '
'.$langs->trans("UrlOrLink").''; if ($action == 'edit') print 'url).'">'; else print 'target?' target="_blank"':'').'>'.$bookmark->url.''; print '
'.$langs->trans("Ref").''.$bookmark->ref.'
'.$langs->trans("BookmarkTitle").''; + print '
'; + if ($action == 'edit') { + print ''; + } + + print $langs->trans("BookmarkTitle"); + + if ($action == 'edit') { + print ''; + } + + print ''; if ($action == 'edit') print 'title).'">'; else print $bookmark->title; print '
'.$langs->trans("UrlOrLink").''; + print '
'; + if ($action == 'edit') { + print ''; + } + print $langs->trans("UrlOrLink"); + if ($action == 'edit') { + print ''; + } + print ''; if ($action == 'edit') print 'url).'">'; else print 'target?' target="_blank"':'').'>'.$bookmark->url.''; print '
 
'; + print ''; + print ''; + print ''; print ' '; +print ''; +print ''; +print ''; print '
'; - print '

 '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print '
'; } else { @@ -930,8 +933,11 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; - print '

 '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print '
'; } elseif ($action == 'edit_customer_price') { @@ -1012,8 +1018,11 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; - print '

 '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print '
'; } elseif ($action == 'showlog_customer_price') { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 051a0575aaa..74cb33e02e7 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -206,7 +206,9 @@ if ($action == 'create') print ''; - print '

'; + print '
'; + print ''; + print '
'; print ''; } @@ -538,8 +540,11 @@ else print ''; - print '

 '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 83d856ed0cc..1bac6b9fef5 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -332,9 +332,13 @@ if ($resql) print ''; - print '
 '; - print '
'; - print ''; + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print ''; } /* @@ -370,8 +374,11 @@ if ($resql) print ''; - print '
 '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 96ecdb1d95d..a1a2b2be669 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -483,8 +483,11 @@ if ($id > 0 || $ref) } print ''; - print '
 '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } @@ -519,8 +522,11 @@ if ($id > 0 || $ref) print ''; - print '
 '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index cd7e4cdcb3c..34b38fe8919 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -217,9 +217,11 @@ if ($action == 'edit') } } - print '
'; - print '     '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; @@ -300,9 +302,11 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''; print ''; - print '
'; - print '     '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index f60d56cb633..e4e85345ec8 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -471,14 +471,14 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; - print '
'; + print '
'; print ''; if (! empty($backtopage)) { print '     '; print ''; } - print '
'; + print '
'; print ''; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 73400bbcc6e..5d5c4f08e40 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -372,10 +372,11 @@ if ($id > 0 || ! empty($ref)) print ''; - print '

'; - print '   '; + print '
'; + print ''; + print '     '; print ''; - print '
'; + print '
'; print ''; } diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 8ee00d83515..dba28538780 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -305,7 +305,7 @@ print "\n"; print ''; print '
'; -print '
Dolibarr logo

'; +print '
Dolibarr logo

'; print '
'; print $langs->trans("DemoDesc").'
'; diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index c8628bd26a0..bb218e4c0cf 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -110,9 +110,9 @@ function llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayo { $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; } - print '
'; + print '
'; print 'Logo'; - print '

'; + print '
'; print '
'; } @@ -343,9 +343,9 @@ if ($action == 'added') // Si on a pas ete redirige print '
'; - print '
'; + print '
'; print $langs->trans("NewMemberbyWeb"); - print '
'; + print '
'; llxFooterVierge(); exit; @@ -591,13 +591,13 @@ if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT) print "
\n"; // Save -print '
'; +print '
'; print ''; if (! empty($backtopage)) { print '     '; } -print '
'; +print '
'; print "
\n"; print ''; diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 47a93e39c32..0213ee7f6fa 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -166,7 +166,7 @@ if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcredi else if (! empty($conf->global->PAYBOX_CREDITOR)) $creditor=$conf->global->PAYBOX_CREDITOR; print ''."\n"; -print '
'; +print '
'; print '
'; print ''; print ''; @@ -778,7 +778,7 @@ print ''."\n"; print ''."\n"; print '
'."\n"; -print '
'."\n"; +print ''."\n"; print '
'; diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index afe685fb6ac..2cd56778f83 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -268,7 +268,7 @@ if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcredi else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR; print ''."\n"; -print '
'."\n"; +print '
'."\n"; print '
'."\n"; print ''."\n"; print ''."\n"; @@ -959,7 +959,7 @@ print ''."\n"; print ''."\n"; print '
'."\n"; -print '
'."\n"; +print ''."\n"; print '
'; diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index 20c9068d4f6..748ba690ea0 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -158,7 +158,7 @@ else print '
'; print $langs->trans("VATIntraManualCheck",$langs->trans("VATIntraCheckURL"),$langs->trans("VATIntraCheckURL")).'
'; print '
'; -print '
'; +print '
'; if ($messagetoshow) { diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 7ab39a10ddc..0932144a860 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -292,8 +292,11 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; - print '

 '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print '
'; } elseif ($action == 'edit_customer_price') { @@ -368,8 +371,11 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; - print '

 '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print '
'; } elseif ($action == 'showlog_customer_price') { diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 01d82ac0867..68ade0431aa 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -497,9 +497,11 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print '
'; - print '
'; - print '   '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } @@ -577,9 +579,11 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print '
'; - print '
'; - print '   '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 62869daf366..d9fb4c0159f 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1095,9 +1095,9 @@ else print ''."\n"; - print '
'; + print '
'; print ''; - print '
'."\n"; + print ''."\n"; print ''."\n"; } @@ -1608,11 +1608,11 @@ else print ''; print '
'; - print '
'; + print '
'; print ''; - print '     '; + print '     '; print ''; - print '
'; + print ''; print ''; diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 1993f12bd5c..2077c7e73e1 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -174,9 +174,9 @@ while ($i <= $MAXAGENDA) print ''; print '
'; -print '
'; +print '
'; print "trans("Save")."\">"; -print "
"; +print ""; print "\n"; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 429bcc91130..fe86717a4c9 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1009,7 +1009,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print "\n"; - print '

'; + print '
'; print ""; } @@ -2126,11 +2126,11 @@ else print ''; - print '
'; + print '
'; print ''; - print '   '; + print '     '; print ''; - print '
'; + print ''; print ''; diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 3dc3c14cc12..f72a8eb0f15 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -155,10 +155,10 @@ if ($id > 0) print ''; - print '
'; - print '     '; + print '
'; + print '     '; print ''; - print '
'; + print ''; print ''; } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index a1930f7c027..5f79c939432 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -264,7 +264,7 @@ if ($action == 'create') print "\n"; - print '

'; + print '
'; print ""; } @@ -536,7 +536,7 @@ else print "\n"; - print '

'; + print '
'; print ''; diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 448dd76d147..2a992aa3212 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -133,11 +133,11 @@ if ($id) if ($action == 'edit') { - print '

'; + print '
'; print ''; - print '   '; + print '     '; print ''; - print '
'; + print ''; } print "\n"; diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 65e9e4ca7a6..3bca4cbee47 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -202,11 +202,11 @@ if ($action == 'edit') dol_fiche_end(); - print '
'; + print '
'; print ''; - print '     '; + print '     '; print ''; - print '
'; + print ''; print ''; diff --git a/htdocs/webservices/admin/webservices.php b/htdocs/webservices/admin/webservices.php index a12f638a174..431150bd9e9 100644 --- a/htdocs/webservices/admin/webservices.php +++ b/htdocs/webservices/admin/webservices.php @@ -90,9 +90,9 @@ print ''; print ''; -print '
'; +print '
'; print ''; -print '
'; +print ''; print ''; From d9958efcd77ee55ea991d73d1fe7ae6974278a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 24 Nov 2014 12:45:46 +0100 Subject: [PATCH 115/940] Fixed [ bug #1691 ] Don't think the ID should be displayed in holiday module --- htdocs/holiday/define_holiday.php | 11 ++--------- htdocs/langs/en_US/holiday.lang | 1 - 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 217cb16bad1..fa3f745de81 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -144,17 +144,14 @@ if($cp_events == 1) print '
'; } -dol_fiche_head(); - print '
'."\n"; print ''; print ''; print ""; -print ''; -print ''; +print ''; print ''; print ''; -print ''; +print ''; print ''; foreach($listUsers as $users) @@ -163,7 +160,6 @@ foreach($listUsers as $users) $var=!$var; print ''; - print ''; print '
'.$langs->trans('ID').''.$langs->trans('Employee').''.$langs->trans('Employee').''.$langs->trans('Available').''.$langs->trans('Note').''.$langs->trans('UpdateButtonCP').'
'.$users['rowid'].''; $userstatic->id=$users['rowid']; $userstatic->lastname=$users['name']; @@ -183,9 +179,6 @@ foreach($listUsers as $users) print '
'; print '
'; -dol_fiche_end(); - - llxFooter(); $db->close(); diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 698d34eb539..f5b87fefb08 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -48,7 +48,6 @@ ConfirmDeleteCP=Confirm the deletion of this leave request? ErrorCantDeleteCP=Error you don't have the right to delete this leave request. CantCreateCP=You don't have the right to make leave requests. InvalidValidatorCP=You must choose an approbator to your leave request. -UpdateButtonCP=Update CantUpdate=You cannot update this leave request. NoDateDebut=You must select a start date. NoDateFin=You must select an end date. From 082f67a6e4edd761f7db07c2dded7de24355f307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 24 Nov 2014 12:49:33 +0100 Subject: [PATCH 116/940] Fixed [ bug #1718 ] Mistakenly searching for text in amount field breaks --- htdocs/fourn/commande/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 6affbae3045..4f0974abd10 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -123,7 +123,7 @@ if ($search_user) } if ($search_ttc) { - $sql .= " AND total_ttc = ".price2num($search_ttc); + $sql .= " AND total_ttc = '".$db->escape(price2num($search_ttc))."'"; } if ($sall) { From c4c69e191bdc616e25fd7f04448ba5189594a130 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 25 Nov 2014 20:13:43 +0100 Subject: [PATCH 117/940] Replace
tags --- build/doxygen/doxygen_footer.html | 4 ++-- build/doxygen/doxygen_header.html | 4 ++-- dev/skeletons/skeleton_page.php | 4 ++-- dev/test/testdiv.php | 8 ++++---- htdocs/accountancy/admin/card.php | 13 +++++++++---- htdocs/accountancy/admin/fiscalyear_card.php | 13 +++++++++---- htdocs/accountancy/customer/card.php | 7 +++++-- htdocs/adherents/admin/public.php | 6 +++--- htdocs/adherents/card.php | 8 ++++---- htdocs/adherents/card_subscriptions.php | 6 +++--- htdocs/adherents/type.php | 15 ++++++++++----- htdocs/admin/agenda.php | 4 ++-- htdocs/admin/agenda_extsites.php | 6 +++--- htdocs/admin/agenda_other.php | 2 +- htdocs/admin/agenda_xcal.php | 4 ++-- htdocs/admin/clicktodial.php | 2 +- htdocs/admin/company.php | 6 +++--- htdocs/admin/delais.php | 2 +- htdocs/admin/external_rss.php | 4 ++-- htdocs/admin/fckeditor.php | 2 +- htdocs/admin/ihm.php | 4 ++-- htdocs/admin/index.php | 2 +- htdocs/admin/ldap.php | 2 +- htdocs/admin/limits.php | 4 ++-- htdocs/admin/mails.php | 6 +++--- htdocs/admin/menus.php | 6 +++--- htdocs/admin/menus/edit.php | 16 ++++++++++------ htdocs/admin/notification.php | 2 +- htdocs/admin/pdf.php | 4 ++-- htdocs/admin/prelevement.php | 2 +- htdocs/admin/sms.php | 6 +++--- htdocs/admin/tools/index.php | 2 +- htdocs/admin/tools/purge.php | 2 +- htdocs/bookmarks/admin/bookmark.php | 2 +- htdocs/cashdesk/admin/cashdesk.php | 2 +- htdocs/cashdesk/tpl/liste_articles.tpl.php | 2 +- htdocs/categories/card.php | 6 +++--- htdocs/categories/edit.php | 3 +-- htdocs/categories/traduction.php | 16 ++++++++++------ htdocs/comm/action/card.php | 14 ++++++++------ htdocs/comm/address.php | 12 ++++++------ htdocs/comm/mailing/card.php | 8 ++++---- htdocs/comm/propal.php | 7 ++++--- htdocs/comm/remise.php | 6 +++--- htdocs/comm/remx.php | 6 +++--- htdocs/commande/card.php | 2 +- htdocs/commande/orderstoinvoice.php | 5 +++-- htdocs/compta/bank/annuel.php | 6 +++--- htdocs/compta/bank/card.php | 9 ++++++--- htdocs/compta/bank/virement.php | 2 +- htdocs/compta/deplacement/card.php | 13 +++++++++---- htdocs/compta/dons/card.php | 4 ++-- htdocs/compta/facture.php | 9 +++++---- htdocs/compta/localtax/card.php | 7 +++++-- htdocs/compta/paiement.php | 4 ++-- htdocs/compta/paiement/cheque/card.php | 4 ++-- htdocs/compta/paiement_charge.php | 8 +++----- htdocs/compta/prelevement/card.php | 4 ++-- htdocs/compta/prelevement/ligne.php | 2 +- htdocs/compta/salaries/card.php | 7 +++++-- htdocs/compta/tva/card.php | 7 +++++-- htdocs/contact/card.php | 10 +++++----- htdocs/contact/perso.php | 6 +++--- htdocs/contrat/card.php | 2 +- htdocs/core/class/html.formmail.class.php | 4 ++-- htdocs/core/class/html.formsms.class.php | 11 +++++------ htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/core/modules/dons/html_cerfafr.html | 4 ++-- htdocs/core/photos_resize.php | 4 ++-- htdocs/core/tpl/login.tpl.php | 10 +++++----- htdocs/core/tpl/passwordforgotten.tpl.php | 12 +++++------- htdocs/cron/admin/cron.php | 4 ++-- htdocs/ecm/docdir.php | 6 +++--- htdocs/expedition/card.php | 2 +- htdocs/exports/index.php | 4 ++-- htdocs/externalsite/admin/externalsite.php | 6 +++--- htdocs/externalsite/frames.php | 4 ++-- htdocs/fichinter/card.php | 8 ++++---- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/commande/dispatch.php | 4 ++-- htdocs/fourn/commande/orderstoinvoice.php | 9 +++++---- htdocs/fourn/facture/card.php | 4 ++-- htdocs/fourn/facture/paiement.php | 4 ++-- htdocs/ftp/admin/ftpclient.php | 2 +- htdocs/holiday/card.php | 4 ++-- htdocs/imports/import.php | 16 ++++++++-------- htdocs/imports/index.php | 4 ++-- htdocs/install/check.php | 6 +++--- htdocs/install/etape5.php | 16 ++++++++-------- htdocs/install/index.php | 4 ++-- htdocs/install/repair.php | 4 ++-- htdocs/opensurvey/card.php | 2 +- htdocs/opensurvey/wizard/choix_date.php | 8 ++++---- htdocs/opensurvey/wizard/index.php | 18 +++++++++--------- htdocs/paybox/admin/paybox.php | 2 +- htdocs/paybox/lib/paybox.lib.php | 6 +++--- htdocs/paypal/admin/paypal.php | 2 +- htdocs/paypal/lib/paypal.lib.php | 4 ++-- htdocs/product/card.php | 9 ++++++--- htdocs/product/composition/card.php | 8 +++++--- htdocs/product/fournisseurs.php | 8 +++++--- 102 files changed, 326 insertions(+), 276 deletions(-) diff --git a/build/doxygen/doxygen_footer.html b/build/doxygen/doxygen_footer.html index 1f4cbd00215..e11df270ddc 100755 --- a/build/doxygen/doxygen_footer.html +++ b/build/doxygen/doxygen_footer.html @@ -26,7 +26,7 @@ for $projectname by Doxygen $doxygenversio -
+
-
+
diff --git a/build/doxygen/doxygen_header.html b/build/doxygen/doxygen_header.html index 363d408d43c..0c2e189136b 100755 --- a/build/doxygen/doxygen_header.html +++ b/build/doxygen/doxygen_header.html @@ -24,7 +24,7 @@ File added into doxygen generated documentation
-
+
@@ -54,7 +54,7 @@ File added into doxygen generated documentation
$projectname
- $projectnumber
-
+
diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php index deaecd95526..ac329318ae5 100644 --- a/dev/skeletons/skeleton_page.php +++ b/dev/skeletons/skeleton_page.php @@ -282,7 +282,7 @@ if ($action == 'create') print '
'; - print '
 
'; + print '
 
'; print ''; @@ -304,7 +304,7 @@ if (($id || $ref) && $action == 'edit') print '
'; - print '
'; + print '
'; print ''; diff --git a/dev/test/testdiv.php b/dev/test/testdiv.php index 8700be5b2ab..2f1bd9182ae 100644 --- a/dev/test/testdiv.php +++ b/dev/test/testdiv.php @@ -19,14 +19,14 @@ -
+
'."\n"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 781de5f2913..aaf24d5b07e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -436,7 +436,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu print ''; print ''; print ''; print ''; print '
'."\n"; diff --git a/htdocs/core/modules/dons/html_cerfafr.html b/htdocs/core/modules/dons/html_cerfafr.html index 2dc9c72968c..ca3f3510eee 100644 --- a/htdocs/core/modules/dons/html_cerfafr.html +++ b/htdocs/core/modules/dons/html_cerfafr.html @@ -157,8 +157,8 @@
-
__Date__ & __Signature__
-
__NOW__
+
__Date__ & __Signature__
+
__NOW__
diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 2d18c6154f8..3a51a5f7567 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -173,11 +173,11 @@ if (! empty($conf->use_javascript_ajax)) print '
'; print ''.$langs->trans("Recenter").''; print $langs->trans("DefineNewAreaToPick").'...
'; - print '
'; + print '
'; print '
'; print ''; print '
'; - print '

'; + print '
'; print '
'.$langs->trans("NewSizeAfterCropping").': diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 23d8dd4f326..b314104f734 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -46,7 +46,7 @@ $(document).ready(function () { -
+