From c9792ff04707881d1e72d1137e053cf23a57d584 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 1 Oct 2016 20:12:00 +0200 Subject: [PATCH 1/8] Fix translation --- htdocs/admin/prelevement.php | 45 ++++++++++++++++++++ htdocs/core/modules/modPrelevement.class.php | 8 ++-- htdocs/langs/en_US/admin.lang | 12 +++--- htdocs/langs/en_US/withdrawals.lang | 27 ++++++------ htdocs/societe/rib.php | 2 +- 5 files changed, 70 insertions(+), 24 deletions(-) diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 0e82681c686..bece7e72d01 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -110,6 +110,51 @@ if ($action == "deletenotif") exit; } +if ($action == 'specimen') +{ + $modele=GETPOST('module','alpha'); + + $commande = new Commande($db); + $commande->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php",0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($commande,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } + else + { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + /* * View diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index 982cb95d208..297d0085136 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -92,7 +92,7 @@ class modPrelevement extends DolibarrModules $r=0; $r++; $this->rights[$r][0] = 151; - $this->rights[$r][1] = 'Read withdrawals'; + $this->rights[$r][1] = 'Read direct debit payment orders'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'bons'; @@ -100,7 +100,7 @@ class modPrelevement extends DolibarrModules $r++; $this->rights[$r][0] = 152; - $this->rights[$r][1] = 'Create/modify a withdrawals'; + $this->rights[$r][1] = 'Create/modify a direct debit payment order'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'bons'; @@ -108,7 +108,7 @@ class modPrelevement extends DolibarrModules $r++; $this->rights[$r][0] = 153; - $this->rights[$r][1] = 'Send withdrawals to bank'; + $this->rights[$r][1] = 'Send/Transmit direct debit payment orders'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'bons'; @@ -116,7 +116,7 @@ class modPrelevement extends DolibarrModules $r++; $this->rights[$r][0] = 154; - $this->rights[$r][1] = 'credit/refuse withdrawals'; + $this->rights[$r][1] = 'Record Credits/Rejects of direct debit payment orders'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'bons'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 54cda62d35b..aa1b98ccf58 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -437,8 +437,8 @@ Module55Name=Barcodes Module55Desc=Barcode management Module56Name=Telephony Module56Desc=Telephony integration -Module57Name=Standing orders -Module57Desc=Standing orders and withdrawal management. Also includes generation of SEPA file for european countries. +Module57Name=Direct bank payment orders +Module57Desc=Management of Direct Debit payment orders. It includes generation of SEPA file for european countries. Module58Name=ClickToDial Module58Desc=Integration of a ClickToDial system (Asterisk, ...) Module59Name=Bookmark4u @@ -615,10 +615,10 @@ Permission142=Create/modify all projects and tasks (also private projects i am n Permission144=Delete all projects and tasks (also private projects i am not contact for) Permission146=Read providers Permission147=Read stats -Permission151=Read standing orders -Permission152=Create/modify a standing orders request -Permission153=Transmission standing orders receipts -Permission154=Credit/refuse standing orders receipts +Permission151=Read direct debit payment orders +Permission152=Create/modify a direct debit payment orders +Permission153=Send/Transmit direct debit payment orders +Permission154=Record Credits/Rejects of direct debit payment orders Permission161=Read contracts/subscriptions Permission162=Create/modify contracts/subscriptions Permission163=Activate a service/subscription of a contract diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 54b3de3915b..3ecc090f2fe 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -1,15 +1,16 @@ # Dolibarr language file - Source file is en_US - withdrawals -CustomersStandingOrdersArea=Customers standing orders area -StandingOrders=Standing orders -StandingOrder=Standing orders -NewStandingOrder=New standing order +CustomersStandingOrdersArea=Direct debit payment orders area +SuppliersStandingOrdersArea=Direct credit payment orders area +StandingOrders=Direct debit payment orders +StandingOrder=Direct debit payment order +NewStandingOrder=New direct debit payment order StandingOrderToProcess=To process WithdrawalsReceipts=Withdrawal receipts WithdrawalReceipt=Withdrawal receipt LastWithdrawalReceipts=Latest %s withdrawal receipts WithdrawalsLines=Withdrawal lines -RequestStandingOrderToTreat=Request for standing orders to process -RequestStandingOrderTreated=Request for standing orders processed +RequestStandingOrderToTreat=Request for direct debit payment order to process +RequestStandingOrderTreated=Request for direct debit payment order processed NotPossibleForThisStatusOfWithdrawReceiptORLine=Not yet possible. Withdraw status must be set to 'credited' before declaring reject on specific lines. NbOfInvoiceToWithdraw=Nb. of invoice with withdraw request NbOfInvoiceToWithdrawWithInfo=Nb. of invoice with withdraw request for customers having defined bank account information @@ -66,7 +67,7 @@ CreditDate=Credit on WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country %s (Your country is not supported) ShowWithdraw=Show Withdraw IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one withdrawal payment not yet processed, it won't be set as paid to allow prior withdrawal management. -DoStandingOrdersBeforePayments=This tab allows you to request a standing order. Once done, go into menu Bank->Withdrawal to manage the standing order. When standing order is closed, payment on invoice will be automatically recorded, and invoice closed if remainder to pay is null. +DoStandingOrdersBeforePayments=This tab allows you to request a direct debit payment order. Once done, go into menu Bank->Withdrawal to manage the direct debit payment order. When payment order is closed, payment on invoice will be automatically recorded, and invoice closed if remainder to pay is null. WithdrawalFile=Withdrawal file SetToStatusSent=Set to status "File Sent" ThisWillAlsoAddPaymentOnInvoice=This will also apply payments to invoices and will classify them as "Paid" @@ -78,11 +79,11 @@ WithdrawRequestAmount=Withdraw request amount: WithdrawRequestErrorNilAmount=Unable to create withdraw request for nil amount. ### Notifications -InfoCreditSubject=Payment of standing order %s by the bank -InfoCreditMessage=The standing order %s has been paid by the bank
Data of payment: %s -InfoTransSubject=Transmission of standing order %s to bank -InfoTransMessage=The standing order %s has been sent to bank by %s %s.

+InfoCreditSubject=Payment of direct debit payment order %s by the bank +InfoCreditMessage=The direct debit payment order %s has been paid by the bank
Data of payment: %s +InfoTransSubject=Transmission of direct debit payment order %s to bank +InfoTransMessage=The direct debit payment order %s has been sent to bank by %s %s.

InfoTransData=Amount: %s
Method: %s
Date: %s -InfoRejectSubject=Standing order refused -InfoRejectMessage=Hello,

the standing order of invoice %s related to the company %s, with an amount of %s has been refused by the bank.

--
%s +InfoRejectSubject=Direct debit payment order refused +InfoRejectMessage=Hello,

the direct debit payment order of invoice %s related to the company %s, with an amount of %s has been refused by the bank.

--
%s ModeWarning=Option for real mode was not set, we stop after this simulation diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index e4eb0ef7053..f1ba5217b8e 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Peter Fontaine * Copyright (C) 2015-2016 Marcos García From 2668cb20cc9d556751560de82af3ab254538de79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 1 Oct 2016 20:45:50 +0200 Subject: [PATCH 2/8] Work on SEPA mandate --- htdocs/admin/bank.php | 220 +++++++++++++++++- htdocs/admin/commande.php | 4 +- htdocs/admin/prelevement.php | 196 +++++++++++++++- .../bank/doc/pdf_sepamandate.modules.php | 15 +- htdocs/langs/en_US/banks.lang | 2 + 5 files changed, 421 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 8a5c60c8483..bccae5bbfaf 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -40,6 +40,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action','alpha'); +$type = 'bankaccount'; /* @@ -60,14 +61,82 @@ if ($action == 'setbankorder') } } + +if ($action == 'specimen') +{ + $modele=GETPOST('module','alpha'); + + $commande = new Commande($db); + $commande->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/paymentorders/doc/pdf_".$modele.".modules.php",0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($commande,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=paymentorders&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } + else + { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +// Set default model +else if ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "PAYMENTORDER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->PAYMENTORDER_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + + + /* * view */ -llxHeader("",$langs->trans("BankSetupModule")); - $form=new Form($db); +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + +llxHeader("",$langs->trans("BankSetupModule")); + $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BankSetupModule"),$linkback,'title_setup'); @@ -79,7 +148,7 @@ $var=true; $var=! $var; //Show bank account order -print load_fiche_titre($langs->trans("BankOrderShow")); +print load_fiche_titre($langs->trans("BankOrderShow"), '', ''); print ''; print ''; @@ -137,6 +206,151 @@ while ($i < $nbofbank) print '
'."\n"; + +print '

'; + + +/* + * Document templates generators + */ +print load_fiche_titre($langs->trans("BankAccountModelModule"), '', ''); + +// Load array def with activated templates +$def = array(); +$sql = "SELECT nom"; +$sql .= " FROM " . MAIN_DB_PREFIX . "document_model"; +$sql .= " WHERE type = '" . $type . "'"; +$sql .= " AND entity = " . $conf->entity; +$resql = $db->query($sql); +if ($resql) { + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i ++; + } +} else { + dol_print_error($db); +} + +print "\n"; +print "\n"; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +$var = true; +foreach ($dirmodels as $reldir) +{ + foreach (array('', '/doc') as $valdir) { + $dir = dol_buildpath($reldir . "core/modules/bank" . $valdir); + + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); + + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + + if (file_exists($dir . '/' . $file)) { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); + + require_once $dir . '/' . $file; + $module = new $classname($db); + + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) + $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) + $modulequalified = 0; + + if ($modulequalified) { + $var = ! $var; + print ''; + + // Active + if (in_array($name, $def)) { + print ''; + } else { + print '"; + } + + // Default + print ''; + + // Info + $htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name; + $htmltooltip .= '
' . $langs->trans("Type") . ': ' . ($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') { + $htmltooltip .= '
' . $langs->trans("Width") . '/' . $langs->trans("Height") . ': ' . $module->page_largeur . '/' . $module->page_hauteur; + } + $htmltooltip .= '

' . $langs->trans("FeaturesSupported") . ':'; + $htmltooltip .= '
' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1); + $htmltooltip .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); + $htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); + $htmltooltip .= '
' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1); + // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + $htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } +} + + + + dol_fiche_end(); llxFooter(); diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 2a1c4a1561d..c2f8cf2d4d6 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -273,12 +273,12 @@ else if ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') * View */ +$form=new Form($db); + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); llxHeader("",$langs->trans("OrdersSetup")); -$form=new Form($db); - $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("OrdersSetup"),$linkback,'title_setup'); diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index bece7e72d01..6d5c915dae2 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -36,6 +36,7 @@ $langs->load("withdrawals"); if (!$user->admin) accessforbidden(); $action = GETPOST('action','alpha'); +$type = 'paymentorder'; /* @@ -110,6 +111,7 @@ if ($action == "deletenotif") exit; } +/* if ($action == 'specimen') { $modele=GETPOST('module','alpha'); @@ -122,7 +124,7 @@ if ($action == 'specimen') $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); foreach($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php",0); + $file=dol_buildpath($reldir."core/modules/paymentorders/doc/pdf_".$modele.".modules.php",0); if (file_exists($file)) { $filefound=1; @@ -139,7 +141,7 @@ if ($action == 'specimen') if ($module->write_file($commande,$langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf"); + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=paymentorders&file=SPECIMEN.pdf"); return; } else @@ -154,7 +156,26 @@ if ($action == 'specimen') dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } - + +// Set default model +else if ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "PAYMENTORDER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->PAYMENTORDER_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} +*/ + /* * View @@ -162,6 +183,8 @@ if ($action == 'specimen') $form=new Form($db); +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + llxHeader('',$langs->trans("WithdrawalsSetup")); $linkback=''.$langs->trans("BackToModuleList").''; @@ -173,6 +196,7 @@ print ''; print ''; print '
' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Status") . "' . $langs->trans("Default") . "' . $langs->trans("ShortInfo") . '' . $langs->trans("Preview") . '
'; + print(empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) + print $module->info($langs); + else + print $module->description; + print '' . "\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print '' . "\n"; + print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print "'; + if ($conf->global->PAYMENTORDER_ADDON_PDF == $name) { + print img_picto($langs->trans("Default"), 'on'); + } else { + print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + if ($module->type == 'pdf') { + print '' . img_object($langs->trans("Preview"), 'bill') . ''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; + print ''; print ''; print ''; @@ -204,6 +228,172 @@ print '
entity; +$resql=$db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} +else +{ + dol_print_error($db); +} + + +print "
'.$langs->trans("Parameter").''.$langs->trans("Value").'
\n"; +print "\n"; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +$var=true; +foreach ($dirmodels as $reldir) +{ + foreach (array('','/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/paymentorders".$valdir); + + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + { + + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + + if ($modulequalified) + { + $var = !$var; + print ''; + + // Active + if (in_array($name, $def)) + { + print ''; + } + else + { + print '"; + } + + // Default + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); + //$htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + //$htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1); + + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } +} + +*/ + + dol_fiche_end(); print '
'; diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index fac7ef1a9d5..111b426267b 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -22,9 +22,8 @@ * \brief File of class to generate document with template sepamandate */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; -require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -48,11 +47,11 @@ class pdf_sepamandate extends ModeleBankAccountDoc global $conf,$langs,$mysoc; $langs->load("main"); - $langs->load("projects"); + $langs->load("bank"); $langs->load("companies"); $this->db = $db; - $this->name = "baleine"; + $this->name = "sepamandate"; $this->description = $langs->trans("DocumentModelSepaMandate"); // Dimension page pour format A4 @@ -104,12 +103,12 @@ class pdf_sepamandate extends ModeleBankAccountDoc $outputlangs->load("companies"); $outputlangs->load("projects"); - if ($conf->projet->dir_output) + if ($conf->bank->dir_output) { //$nblignes = count($object->lines); // This is set later with array of tasks $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->projet->dir_output; + $dir = $conf->bank->dir_output; if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; @@ -489,7 +488,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf,$outputlangs,'BANK_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index b0b7af4076f..8a6a6aaeeac 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -144,3 +144,5 @@ ConfirmRejectCheck=Are you sure you want to mark this check as rejected ? RejectCheckDate=Date the check was returned CheckRejected=Check returned CheckRejectedAndInvoicesReopened=Check returned and invoices reopened +BankAccountModelModule=Document templates for bank accounts +DocumentModelSepaMandate=Template of SEPA mandate. Usefull for european countries in EEC only. \ No newline at end of file From e3aa84ff5a198fcec6c08315bc24243686b13835 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Oct 2016 10:41:22 +0200 Subject: [PATCH 3/8] NEW Add last activation date as info in module list. --- htdocs/admin/modules.php | 28 +++++++++++-------- htdocs/core/modules/DolibarrModules.class.php | 28 ++++++++++++++++++- htdocs/langs/en_US/admin.lang | 1 + 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 85e46b32333..9de1dae60b5 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -520,6 +520,11 @@ if ($mode != 'marketplace') { $text.='
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; } + $text.='
'.$langs->trans("LastActivationDate").': '; + if (! empty($conf->global->$const_name)) $text.=dol_print_date($objMod->getLastActivationDate(), 'dayhour'); + else $text.=$langs->trans("Disabled"); + $text.='
'; + $text.='
'.$langs->trans("AddRemoveTabs").': '; if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) { @@ -650,22 +655,23 @@ if ($mode != 'marketplace') print $form->textwithpicto('', $text, 1, 'help', 'minheight20'); - // Picto warning - $version=$objMod->getVersion(0); - $versiontrans=$objMod->getVersion(1); - if (preg_match('/development/i', $version)) print img_warning($langs->trans("Development"), 'style="float: right"'); - if (preg_match('/experimental/i', $version)) print img_warning($langs->trans("Experimental"), 'style="float: right"'); - if (preg_match('/deprecated/i', $version)) print img_warning($langs->trans("Deprecated"), 'style="float: right"'); - - // Picto external - if ($textexternal) print img_picto($langs->trans("ExternalModule",$dirofmodule), 'external', 'style="float: right"'); - - print ''; // Version print '
\n"; // Activate/Disable and Setup (2 columns) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index b8b194e5be6..dbb8f9b3f01 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -709,7 +709,33 @@ class DolibarrModules // Can not be abstract, because we need to insta } } - + + /** + * Gives the last date of activation + * + * @return timestamp Date of last activation + */ + function getLastActivationDate() + { + global $conf; + + $sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const"; + $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->const_name."'"; + $sql.= " AND entity IN (0, ".$conf->entity.")"; + + dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) $err++; + else + { + $obj=$this->db->fetch_object($resql); + if ($obj) return $this->db->jdate($obj->tms); + } + + return ''; + } + + /** * Insert constants for module activation * diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index aa1b98ccf58..0d5e6e464e9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -278,6 +278,7 @@ YouCanSubmitFile=For this step, you can send package using this tool: Select mod CurrentVersion=Dolibarr current version CallUpdatePage=Go to the page that updates the database structure and data: %s. LastStableVersion=Latest stable version +LastActivationDate=Last activation date UpdateServerOffline=Update server offline GenericMaskCodes=You may enter any numbering mask. In this mask, the following tags could be used:
{000000} corresponds to a number which will be incremented on each %s. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros from the left in order to have as many zeros as the mask.
{000000+000} same as previous but an offset corresponding to the number to the right of the + sign is applied starting on first %s.
{000000@x} same as previous but the counter is reset to zero when month x is reached (x between 1 and 12, or 0 to use the early months of fiscal year defined in your configuration, or 99 to reset to zero every month). If this option is used and x is 2 or higher, then sequence {yy}{mm} or {yyyy}{mm} is also required.
{dd} day (01 to 31).
{mm} month (01 to 12).
{yy}, {yyyy} or {y} year over 2, 4 or 1 numbers.
GenericMaskCodes2={cccc} the client code on n characters
{cccc000} the client code on n characters is followed by a counter dedicated for customer. This counter dedicated to customer is reset at same time than global counter.
{tttt} The code of thirdparty type on n characters (see dictionary-thirdparty types).
From 2579cb35ddeb8822285c924e9425cc92e49871e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Oct 2016 11:03:36 +0200 Subject: [PATCH 4/8] Minor fix --- htdocs/admin/modules.php | 2 +- htdocs/core/class/conf.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 9de1dae60b5..5c1255a1c20 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -363,7 +363,7 @@ if ($mode != 'marketplace') //print ''; } - print '


'; + print '



'; // Show list of modules diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index d7d142c7420..1085d289dd2 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -490,7 +490,7 @@ class Conf if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=1; // Define list of limited modules - if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,supplier_proposal,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. + if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplier_proposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. // Enable select2 if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT='select2'; From a52ad545eb283c849a816faebd5bcc11ea26d29e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Oct 2016 13:03:45 +0200 Subject: [PATCH 5/8] Enhancement on module Direct Debit SEPA. --- htdocs/admin/agenda_other.php | 2 +- htdocs/admin/bank.php | 54 +- htdocs/compta/bank/class/account.class.php | 5 +- .../class/bonprelevement.class.php | 3 +- .../core/modules/bank/doc/pdf_ban.modules.php | 472 ++++++++++++++++++ .../bank/doc/pdf_sepamandate.modules.php | 83 ++- htdocs/core/modules/modBanque.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/en_US/banks.lang | 4 +- htdocs/langs/en_US/bills.lang | 8 +- htdocs/langs/en_US/errors.lang | 1 + htdocs/langs/en_US/withdrawals.lang | 38 +- .../class/companybankaccount.class.php | 33 ++ htdocs/societe/rib.php | 23 +- 14 files changed, 628 insertions(+), 102 deletions(-) create mode 100644 htdocs/core/modules/bank/doc/pdf_ban.modules.php diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 76b3b060925..2fe4f0a6037 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -147,7 +147,7 @@ else if ($action == 'specimen') // For orders // Activate a model else if ($action == 'setmodel') { - print "sssd".$value; + //print "sssd".$value; $ret = addDocumentModel($value, $type, $label, $scandir); } diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index bccae5bbfaf..58d97842017 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -28,7 +28,8 @@ 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'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $langs->load("admin"); $langs->load("companies"); @@ -40,6 +41,9 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$label = GETPOST('label','alpha'); +$scandir = GETPOST('scandir','alpha'); $type = 'bankaccount'; @@ -66,15 +70,22 @@ if ($action == 'specimen') { $modele=GETPOST('module','alpha'); - $commande = new Commande($db); - $commande->initAsSpecimen(); + if ($modele == 'sepamandate') + { + $object = new CompanyBankAccount($db); + } + else + { + $object = new Account($db); + } + $object->initAsSpecimen(); // Search template files $file=''; $classname=''; $filefound=0; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); foreach($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/paymentorders/doc/pdf_".$modele.".modules.php",0); + $file=dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php",0); if (file_exists($file)) { $filefound=1; @@ -89,9 +100,9 @@ if ($action == 'specimen') $module = new $classname($db); - if ($module->write_file($commande,$langs) > 0) + if ($module->write_file($object,$langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=paymentorders&file=SPECIMEN.pdf"); + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); return; } else @@ -107,14 +118,28 @@ if ($action == 'specimen') } } +// Activate a model +if ($action == 'set') +{ + $ret = addDocumentModel($value, $type, $label, $scandir); +} + +else if ($action == 'del') +{ + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->BANKADDON_PDF == "$value") dolibarr_del_const($db, 'BANKADDON_PDF',$conf->entity); + } +} // Set default model else if ($action == 'setdoc') { - if (dolibarr_set_const($db, "PAYMENTORDER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + if (dolibarr_set_const($db, "BANKADDON_PDF",$value,'chaine',0,'',$conf->entity)) { // The constant that was read before the new set // We therefore requires a variable to have a coherent view - $conf->global->PAYMENTORDER_ADDON_PDF = $value; + $conf->global->BANKADDON_PDF = $value; } // On active le modele @@ -213,6 +238,8 @@ print '

'; /* * Document templates generators */ +//if (! empty($conf->global->MAIN_FEATURES_LEVEL)) +//{ print load_fiche_titre($langs->trans("BankAccountModelModule"), '', ''); // Load array def with activated templates @@ -303,7 +330,7 @@ foreach ($dirmodels as $reldir) // Default print '
'; + print ''; print ''; } print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"'); @@ -412,7 +424,8 @@ if ($socid && $action != 'edit' && $action != "create") if (! empty($conf->prelevement->enabled)) { // RUM - print ''; + //print ''; + print ''; // FRSTRECUR print ''; From 3efa0e411d9a1a6ecb56130cc9630cedcd61ab60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Oct 2016 15:29:43 +0200 Subject: [PATCH 6/8] NEW Add a direct debit mandate PDF template. --- .../core/modules/bank/doc/pdf_ban.modules.php | 83 +---- .../bank/doc/pdf_sepamandate.modules.php | 309 +++++++++++++----- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/withdrawals.lang | 12 + .../class/companybankaccount.class.php | 7 +- 5 files changed, 243 insertions(+), 169 deletions(-) diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index a496e303fa6..699b186a9d2 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -211,88 +211,7 @@ class pdf_ban extends ModeleBankAccountDoc $pdf->SetXY($this->marge_gauche, $curY); $pdf->MultiCell(200, 3, $outputlangs->trans("BAN").' : '.$object->account_number, 0, 'L'); - // Boucle sur les lignes - /* - for ($i = 0 ; $i < $nblignes ; $i++) - { - $curY = $nexY; - - // Description of ligne - $ref=$object->lines[$i]->ref; - $libelleline=$object->lines[$i]->label; - $progress=$object->lines[$i]->progress.'%'; - $datestart=dol_print_date($object->lines[$i]->date_start,'day'); - $dateend=dol_print_date($object->lines[$i]->date_end,'day'); - $planned_workload=convertSecondToTime($object->lines[$i]->planned_workload,'allhourmin'); - - $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page - - $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); - $pdf->SetXY($this->posxlabel, $curY); - $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); - $pdf->SetXY($this->posxworkload, $curY); - $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload, 0, 'R'); - $pdf->SetXY($this->posxprogress, $curY); - $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R'); - - $pdf->SetXY($this->posxdatestart, $curY); - $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C'); - $pdf->SetXY($this->posxdateend, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C'); - - $pageposafter=$pdf->getPage(); - - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut - $nexY = $pdf->GetY(); - - // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) - { - $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); - //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); - $pdf->SetLineStyle(array('dash'=>0)); - } - - $nexY+=2; // Passe espace entre les lignes - - // Detect if some page were added automatically and output _tableau for past pages - while ($pagenb < $pageposafter) - { - $pdf->setPage($pagenb); - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); - } - $this->_pagefoot($pdf,$object,$outputlangs,1); - $pagenb++; - $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) - { - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); - } - $this->_pagefoot($pdf,$object,$outputlangs,1); - // New page - $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - $pagenb++; - } - } - */ + // Show square if ($pagenb == 1) diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 932fdd2d9f0..820d9bec2f3 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -94,7 +94,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc */ function write_file($object,$outputlangs) { - global $conf, $hookmanager, $langs, $user; + global $conf, $hookmanager, $langs, $user, $mysoc; 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 @@ -208,92 +208,139 @@ class pdf_sepamandate extends ModeleBankAccountDoc $curY = $tab_top + 7; $nexY = $tab_top + 7; - //var_dump($object);exit; - $pdf->SetXY($this->marge_gauche, $curY); - $pdf->MultiCell(200, 3, $outputlangs->trans("RUMLong").' ('.$outputlangs->trans("RUM").')'.' : '.$object->rum, 0, 'L'); + $posY = $curY; - // Boucle sur les lignes - /* - for ($i = 0 ; $i < $nblignes ; $i++) + $pdf->SetFont('','', $default_font_size); + + $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); + $posY+=2; + + $pdf->SetXY($this->marge_gauche, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->trans("RUM").')'.' : '.$object->rum, 0, 'L'); + + $posY=$pdf->GetY(); + $posY+=2; + $pdf->SetXY($this->marge_gauche, $posY); + $ics=''; + if (! empty($conf->global->PRELEVEMENT_ICS)) $ics=$conf->global->PRELEVEMENT_ICS; + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->trans("ICS").')'.' : '.$ics, 0, 'L'); + + $posY=$pdf->GetY(); + $posY+=1; + $pdf->SetXY($this->marge_gauche, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L'); + + $posY=$pdf->GetY(); + $posY+=1; + $pdf->SetXY($this->marge_gauche, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(), 0, 'L'); + + $posY=$pdf->GetY(); + $posY+=3; + + $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); + + $pdf->SetFont('','', $default_font_size - 1); + + $posY+=8; + $pdf->SetXY($this->marge_gauche, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->trans("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L'); + + // Your data form + $posY=$pdf->GetY(); + $posY+=8; + $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); + $posY+=2; + + $pdf->SetFont('','', $default_font_size); + + $pdf->SetXY($this->marge_gauche, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C'); + + $thirdparty=new Societe($this->db); + if ($object->socid > 0) $thirdparty->fetch($object->socid); + + $sepaname = '______________________________________________'; + if ($thirdparty->id > 0) { - $curY = $nexY; - - // Description of ligne - $ref=$object->lines[$i]->ref; - $libelleline=$object->lines[$i]->label; - $progress=$object->lines[$i]->progress.'%'; - $datestart=dol_print_date($object->lines[$i]->date_start,'day'); - $dateend=dol_print_date($object->lines[$i]->date_end,'day'); - $planned_workload=convertSecondToTime($object->lines[$i]->planned_workload,'allhourmin'); - - $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page - - $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); - $pdf->SetXY($this->posxlabel, $curY); - $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); - $pdf->SetXY($this->posxworkload, $curY); - $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload, 0, 'R'); - $pdf->SetXY($this->posxprogress, $curY); - $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R'); - - $pdf->SetXY($this->posxdatestart, $curY); - $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C'); - $pdf->SetXY($this->posxdateend, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C'); - - $pageposafter=$pdf->getPage(); - - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut - $nexY = $pdf->GetY(); - - // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) - { - $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); - //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); - $pdf->SetLineStyle(array('dash'=>0)); - } - - $nexY+=2; // Passe espace entre les lignes - - // Detect if some page were added automatically and output _tableau for past pages - while ($pagenb < $pageposafter) - { - $pdf->setPage($pagenb); - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); - } - $this->_pagefoot($pdf,$object,$outputlangs,1); - $pagenb++; - $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) - { - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); - } - $this->_pagefoot($pdf,$object,$outputlangs,1); - // New page - $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - $pagenb++; - } + $sepaname = $thirdparty->name.' ('.$object->account_owner.')'; } - */ + $posY=$pdf->GetY(); + $posY+=3; + $pdf->SetXY($this->marge_gauche, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L'); + $pdf->SetXY(80, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0, 'L'); + + $address = '______________________________________________'; + if ($thirdparty->id > 0) + { + $address = $thirdparty->getFullAddress(); + } + $posY=$pdf->GetY(); + $posY+=1; + $pdf->SetXY($this->marge_gauche, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L'); + $pdf->SetXY(80, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); + if (preg_match('/_____/', $address)) + { + $posY+=6; + $pdf->SetXY(80, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L'); + } + + $ban = '__________________________________________________'; + if (! empty($object->iban)) $ban = $object->iban; + $posY=$pdf->GetY(); + $posY+=1; + $pdf->SetXY($this->marge_gauche, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L'); + $pdf->SetXY(80, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L'); + + $bic = '__________________________________________________'; + if (! empty($object->bic)) $bic = $object->bic; + $posY=$pdf->GetY(); + $posY+=1; + $pdf->SetXY($this->marge_gauche, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L'); + $pdf->SetXY(80, $posY); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L'); + + + $posY=$pdf->GetY(); + $posY+=1; + $pdf->SetXY($this->marge_gauche, $posY); + $txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : '; + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); + $pdf->Rect(80, $posY, 5, 5); + $pdf->SetXY(80, $posY); + if ($object->frstrecur == 'FRST') $pdf->MultiCell(5, 3, 'X', 0, 'L'); + $pdf->SetXY(86, $posY); + $txt = $langs->trans("ModeRECUR").' '.$langs->trans("or"); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); + $posY+=6; + $pdf->Rect(80, $posY, 5, 5); + $pdf->SetXY(80, $posY); + if ($object->frstrecur == 'RECUR') $pdf->MultiCell(5, 3, 'X', 0, 'L'); + $pdf->SetXY(86, $posY); + $txt = $langs->trans("ModeFRST"); + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); + if (empty($object->frstrecur)) + { + $posY+=6; + $pdf->SetXY(80, $posY); + $txt = '('.$langs->trans("PleaseCheckOne").')'; + $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L'); + } + + $posY=$pdf->GetY(); + $posY+=3; + $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY); + $posY+=3; + // Show square if ($pagenb == 1) @@ -307,6 +354,15 @@ class pdf_sepamandate extends ModeleBankAccountDoc $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } + var_dump($tab_top); + var_dump($heightforinfotot); + var_dump($heightforfreetext); + var_dump($heightforfooter); + var_dump($bottomlasttab); + + // Affiche zone infos + $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + /* * Pied de page */ @@ -365,6 +421,82 @@ class pdf_sepamandate extends ModeleBankAccountDoc } + + /** + * Show miscellaneous information (payment mode, payment term, ...) + * + * @param PDF $pdf Object PDF + * @param Object $object Object to show + * @param int $posy Y + * @param Translate $outputlangs Langs object + * @return void + */ + function _tableau_info(&$pdf, $object, $posy, $outputlangs) + { + global $conf, $mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?1:$conf->global->PDF_DIFFSIZE_TITLE); + + $posy+=$this->_signature_area($pdf, $object, $posy, $outputlangs); + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('','', $default_font_size); + $pdf->MultiCell(100, 3, $outputlangs->trans("PleaseReturnMandate").':', 0, 'L', 0); + $posy=$pdf->GetY()+2; + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('','', $default_font_size - $diffsizetitle); + $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0); + $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0); + $posy=$pdf->GetY()+2; + + return $posy; + } + + + + /** + * Show area for the customer to sign + * + * @param PDF $pdf Object PDF + * @param Facture $object Object invoice + * @param int $posy Position depart + * @param Translate $outputlangs Objet langs + * @return int Position pour suite + */ + function _signature_area(&$pdf, $object, $posy, $outputlangs) + { + $default_font_size = pdf_getPDFFontSize($outputlangs); + $tab_top = $posy + 4; + $tab_hl = 4; + + $posx = $this->marge_gauche; + $pdf->SetXY($posx, $tab_top + 0); + + $pdf->SetFont('','', $default_font_size - 2); + + $pdf->MultiCell(100, 3, $outputlangs->trans("DateOfSignature"), 0, 'L', 0); + $pdf->MultiCell(100, 3, ' '); + $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0); + + $posx = 120; + $largcol = ($this->page_largeur - $this->marge_droite - $posx); + $useborder=0; + $index = 0; + // Total HT + $pdf->SetFillColor(255,255,255); + $pdf->SetXY($posx, $tab_top + 0); + $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("Signature"), 0, 'L', 1); + + $pdf->SetXY($posx, $tab_top + $tab_hl); + $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); + + return ($tab_hl*7); + } + + /** * Show top header of page. * @@ -418,7 +550,12 @@ class pdf_sepamandate extends ModeleBankAccountDoc $posy+=6; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date(dol_now(),'day',false,$outputlangs,true), '', 'R'); + $daterum = '__________________'; + if (! empty($object->date_rum)) + { + $daterum = dol_print_date($object->date_rum,'day',false,$outputlangs,true); + } + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . $daterum, '', 'R'); /*$posy+=6; $pdf->SetXY($posx,$posy); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); @@ -465,7 +602,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + return pdf_pagefoot($pdf,$outputlangs,'PAYMENTORDER_FREE_TEXT',null,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index ad5539d502f..d9ac8ea0539 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -607,6 +607,7 @@ DisabledModules=Disabled modules For=For ForCustomer=For customer Signature=Signature +DateOfSignature=Date of signature HidePassword=Show command with password hidden UnHidePassword=Show real command with clear password Root=Root diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 443524f9a30..70d3dc6f49a 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -79,6 +79,18 @@ WithdrawMode=Direct debit mode (FRST or RECUR) WithdrawRequestAmount=Withdraw request amount: WithdrawRequestErrorNilAmount=Unable to create withdraw request for nil amount. SepaMandate=SEPA Direct Debit Mandate +PleaseReturnMandate=Please return this mandate form to +SEPALegalText=By signing this mandate form, you authorise (A) %s to send instructions to your bank to debit your account and (B) your bank to debit your account in accordance with the instructions from %s. As part of your rights, you are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited. Your rights regarding the above mandate are explained in a statement that you can obtain from your bank. +CreditorIdentifier=Creditor Identifier +CreditorName=Creditor’s Name +SEPAFillForm=(B) Please complete all the fields marked * +SEPAFormYourName=Your name +SEPAFormYourBAN=Your Bank Account Name (IBAN) +SEPAFormYourBIC=Your Bank Identifier Code (BIC) +SEPAFrstOrRecur=Type of payment +ModeRECUR=Reccurent payment +ModeFRST=One-off payment +PleaseCheckOne=Please check one only ### Notifications InfoCreditSubject=Payment of direct debit payment order %s by the bank diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 63d2a48d901..f7bad843709 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -37,6 +37,8 @@ class CompanyBankAccount extends Account var $default_rib; var $frstrecur; + var $rum; + var $date_rum; var $datec; var $datem; @@ -332,7 +334,10 @@ class CompanyBankAccount extends Account $this->country_id = 1; $this->rum = 'UMR-CU1212-0007-5-1475405262'; - $this->frstrecur = 'FRST'; + $this->date_rum =dol_now() - 10000; + $this->frstrecur = 'FRST'; + + $this->socid = 0; } } From f92ca518f79dcbecbf9ec27f6986a0bb819f4acd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Oct 2016 16:12:40 +0200 Subject: [PATCH 7/8] Uniformize look and feel --- htdocs/core/class/conf.class.php | 2 + htdocs/core/lib/company.lib.php | 56 +- .../societe/doc/doc_generic_odt.modules.php | 2 + htdocs/langs/en_US/withdrawals.lang | 2 +- htdocs/societe/consumption.php | 4 +- htdocs/societe/rib.php | 605 ++++++++++-------- htdocs/societe/soc.php | 16 - htdocs/theme/eldy/style.css.php | 3 + htdocs/theme/md/style.css.php | 3 + 9 files changed, 402 insertions(+), 291 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 1085d289dd2..b388298cf08 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -386,6 +386,8 @@ class Conf if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard"; if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum"; + if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint'; + // Security if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED='standard'; // Default password generator if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664'; // Default mask diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e6a109d5352..51d43ad214e 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -123,7 +123,45 @@ function societe_prepare_head(Societe $object) $h++; } - // Show more tabs from modules + // Related items + if (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fichinter->enabled) || ! empty($conf->fournisseur->enabled)) + { + $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Referers"); + $head[$h][2] = 'consumption'; + $h++; + } + + // Bank accounrs + if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) + { + $nbBankAccount=0; + $head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$object->id; + $head[$h][1] = $langs->trans("BankAccounts"); + $sql = "SELECT COUNT(n.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; + $sql.= " WHERE fk_soc = ".$object->id; + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $nbBankAccount=$obj->nb; + $i++; + } + } + else { + dol_print_error($db); + } + if ($nbBankAccount > 0) $head[$h][1].= ' '.$nbBankAccount.''; + $head[$h][2] = 'rib'; + $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:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab @@ -131,14 +169,6 @@ function societe_prepare_head(Societe $object) if ($user->societe_id == 0) { - if (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fichinter->enabled) || ! empty($conf->fournisseur->enabled)) - { - $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Referers"); - $head[$h][2] = 'consumption'; - $h++; - } - // Notifications if (! empty($conf->notification->enabled)) { @@ -232,14 +262,6 @@ function societe_prepare_head2($object) $head[$h][2] = 'company'; $h++; - if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) - { - $head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$object->id; - $head[$h][1] = $langs->trans("BankAccount"); - $head[$h][2] = 'rib'; - $h++; - } - $head[$h][0] = 'commerciaux.php?socid='.$object->id; $head[$h][1] = $langs->trans("SalesRepresentative"); $head[$h][2] = 'salesrepresentative'; diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 08f6372c11b..edee43b274c 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -332,6 +332,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc $var=true; if ($num) { + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + $i=0; $contactstatic = new Contact($this->db); diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 70d3dc6f49a..5030ebffaac 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -80,7 +80,7 @@ WithdrawRequestAmount=Withdraw request amount: WithdrawRequestErrorNilAmount=Unable to create withdraw request for nil amount. SepaMandate=SEPA Direct Debit Mandate PleaseReturnMandate=Please return this mandate form to -SEPALegalText=By signing this mandate form, you authorise (A) %s to send instructions to your bank to debit your account and (B) your bank to debit your account in accordance with the instructions from %s. As part of your rights, you are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited. Your rights regarding the above mandate are explained in a statement that you can obtain from your bank. +SEPALegalText=By signing this mandate form, you authorize (A) %s to send instructions to your bank to debit your account and (B) your bank to debit your account in accordance with the instructions from %s. As part of your rights, you are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited. Your rights regarding the above mandate are explained in a statement that you can obtain from your bank. CreditorIdentifier=Creditor Identifier CreditorName=Creditor’s Name SEPAFillForm=(B) Please complete all the fields marked * diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index da3792d0897..85695efff40 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2013-2015 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Ferran Marcet @@ -57,7 +57,7 @@ $month = GETPOST('month','int'); $year = GETPOST('year','int'); // Clean up on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $sref=''; $sprod_fulldescr=''; diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index dd12548400f..5c989720f1c 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -29,6 +29,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; @@ -38,220 +39,258 @@ $langs->load("banks"); $langs->load("bills"); // Security check -$socid = GETPOST("socid"); +$socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); -$object = new Societe($db); -$object->fetch($socid); - $id=GETPOST("id","int"); $ribid=GETPOST("ribid","int"); $action=GETPOST("action"); +$object = new Societe($db); +$object->fetch($socid); + $account = new CompanyBankAccount($db); $prelevement = new BonPrelevement($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('thirdpartybancard','globalcard')); + + /* * Actions */ -if ($action == 'update' && ! $_POST["cancel"]) -{ - // Modification - if (! GETPOST('label')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $action='update'; - $error++; - } - if (! GETPOST('bank')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='update'; - $error++; - } - if ($account->needIBAN() == 1) - { - if (! GETPOST('iban')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='update'; - $error++; - } - if (! GETPOST('bic')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='update'; - $error++; - } - } +$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - $account->fetch($id); - if (! $error) +if (empty($reshook)) +{ + if ($cancel) { - $account->socid = $object->id; - - $account->bank = GETPOST('bank','alpha'); - $account->label = GETPOST('label','alpha'); - $account->courant = GETPOST('courant','alpha'); - $account->clos = GETPOST('clos','alpha'); - $account->code_banque = GETPOST('code_banque','alpha'); - $account->code_guichet = GETPOST('code_guichet','alpha'); - $account->number = GETPOST('number','alpha'); - $account->cle_rib = GETPOST('cle_rib','alpha'); - $account->bic = GETPOST('bic','alpha'); - $account->iban = GETPOST('iban','alpha'); - $account->domiciliation = GETPOST('domiciliation','alpha'); - $account->proprio = GETPOST('proprio','alpha'); - $account->owner_address = GETPOST('owner_address','alpha'); - $account->frstrecur = GETPOST('frstrecur','alpha'); - if (empty($account->rum)) - { - $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); - $account->date_rum = dol_now(); - } - - $result = $account->update($user); - if (! $result) - { - setEventMessages($account->error, $account->errors, 'errors'); - } - else - { - // If this account is the default bank account, we disable others - if ($account->default_rib) - { - $account->setAsDefault($id); // This will make sure there is only one default rib - } - - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; - } + $action=''; + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } } -} -if ($action == 'add' && ! $_POST["cancel"]) -{ - $error=0; - - if (! GETPOST('label')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $action='create'; - $error++; - } - if (! GETPOST('bank')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='create'; - $error++; - } - - if (! $error) - { - // Ajout - $account = new CompanyBankAccount($db); - - $account->socid = $object->id; - - $account->bank = GETPOST('bank','alpha'); - $account->label = GETPOST('label','alpha'); - $account->courant = GETPOST('courant','alpha'); - $account->clos = GETPOST('clos','alpha'); - $account->code_banque = GETPOST('code_banque','alpha'); - $account->code_guichet = GETPOST('code_guichet','alpha'); - $account->number = GETPOST('number','alpha'); - $account->cle_rib = GETPOST('cle_rib','alpha'); - $account->bic = GETPOST('bic','alpha'); - $account->iban = GETPOST('iban','alpha'); - $account->domiciliation = GETPOST('domiciliation','alpha'); - $account->proprio = GETPOST('proprio','alpha'); - $account->owner_address = GETPOST('owner_address','alpha'); - $account->frstrecur = GETPOST('frstrecur'); - - // This test can be done only once properties were set - if ($account->needIBAN() == 1) - { - if (! GETPOST('iban')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='create'; - $error++; - } - if (! GETPOST('bic')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='create'; - $error++; - } - } - - if (! $error) - { - if (empty($account->rum)) - { - $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); - $account->date_rum = dol_now(); - } - - $result = $account->update($user); // This will set the UMR number. - // TODO Use create and include update into create method - if (! $result) - { - setEventMessages($account->error, $account->errors, 'errors'); - $_GET["action"]='create'; // Force chargement page création - } - else - { - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + + if ($action == 'update' && ! $_POST["cancel"]) + { + // Modification + if (! GETPOST('label')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + $action='update'; + $error++; + } + if (! GETPOST('bank')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action='update'; + $error++; + } + if ($account->needIBAN() == 1) + { + if (! GETPOST('iban')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); + $action='update'; + $error++; + } + if (! GETPOST('bic')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); + $action='update'; + $error++; + } + } + + $account->fetch($id); + if (! $error) + { + $account->socid = $object->id; + + $account->bank = GETPOST('bank','alpha'); + $account->label = GETPOST('label','alpha'); + $account->courant = GETPOST('courant','alpha'); + $account->clos = GETPOST('clos','alpha'); + $account->code_banque = GETPOST('code_banque','alpha'); + $account->code_guichet = GETPOST('code_guichet','alpha'); + $account->number = GETPOST('number','alpha'); + $account->cle_rib = GETPOST('cle_rib','alpha'); + $account->bic = GETPOST('bic','alpha'); + $account->iban = GETPOST('iban','alpha'); + $account->domiciliation = GETPOST('domiciliation','alpha'); + $account->proprio = GETPOST('proprio','alpha'); + $account->owner_address = GETPOST('owner_address','alpha'); + $account->frstrecur = GETPOST('frstrecur','alpha'); + if (empty($account->rum)) + { + $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } + + $result = $account->update($user); + if (! $result) + { + setEventMessages($account->error, $account->errors, 'errors'); + } + else + { + // If this account is the default bank account, we disable others + if ($account->default_rib) + { + $account->setAsDefault($id); // This will make sure there is only one default rib + } + + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; header('Location: '.$url); exit; - } - } - } + } + } + } + + if ($action == 'add' && ! $_POST["cancel"]) + { + $error=0; + + if (! GETPOST('label')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + $action='create'; + $error++; + } + if (! GETPOST('bank')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action='create'; + $error++; + } + + if (! $error) + { + // Ajout + $account = new CompanyBankAccount($db); + + $account->socid = $object->id; + + $account->bank = GETPOST('bank','alpha'); + $account->label = GETPOST('label','alpha'); + $account->courant = GETPOST('courant','alpha'); + $account->clos = GETPOST('clos','alpha'); + $account->code_banque = GETPOST('code_banque','alpha'); + $account->code_guichet = GETPOST('code_guichet','alpha'); + $account->number = GETPOST('number','alpha'); + $account->cle_rib = GETPOST('cle_rib','alpha'); + $account->bic = GETPOST('bic','alpha'); + $account->iban = GETPOST('iban','alpha'); + $account->domiciliation = GETPOST('domiciliation','alpha'); + $account->proprio = GETPOST('proprio','alpha'); + $account->owner_address = GETPOST('owner_address','alpha'); + $account->frstrecur = GETPOST('frstrecur'); + + // This test can be done only once properties were set + if ($account->needIBAN() == 1) + { + if (! GETPOST('iban')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); + $action='create'; + $error++; + } + if (! GETPOST('bic')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); + $action='create'; + $error++; + } + } + + if (! $error) + { + if (empty($account->rum)) + { + $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } + + $result = $account->update($user); // This will set the UMR number. + // TODO Use create and include update into create method + if (! $result) + { + setEventMessages($account->error, $account->errors, 'errors'); + $_GET["action"]='create'; // Force chargement page création + } + else + { + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + } + } + } + + if ($action == 'setasdefault') + { + $account = new CompanyBankAccount($db); + $res = $account->setAsDefault(GETPOST('ribid','int')); + if ($res) + { + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + else + { + setEventMessages($db->lasterror, null, 'errors'); + } + } + + if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') + { + $account = new CompanyBankAccount($db); + if ($account->fetch($ribid?$ribid:$id)) + { + $result = $account->delete($user); + if ($result > 0) + { + $url = $_SERVER['PHP_SELF']."?socid=".$object->id; + header('Location: '.$url); + exit; + } + else + { + setEventMessages($account->error, $account->errors, 'errors'); + } + } + else + { + setEventMessages($account->error, $account->errors, 'errors'); + } + } + + $savid=$id; + + // Actions to build doc + $id = $socid; + $upload_dir = $conf->societe->dir_output; + $permissioncreate=$user->rights->societe->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + $id = $savid; } -if ($action == 'setasdefault') -{ - $account = new CompanyBankAccount($db); - $res = $account->setAsDefault(GETPOST('ribid','int')); - if ($res) - { - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; - } - else - { - setEventMessages($db->lasterror, null, 'errors'); - } -} - -if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') -{ - $account = new CompanyBankAccount($db); - if ($account->fetch($ribid?$ribid:$id)) - { - $result = $account->delete($user); - if ($result > 0) - { - $url = $_SERVER['PHP_SELF']."?socid=".$object->id; - header('Location: '.$url); - exit; - } - else - { - setEventMessages($account->error, $account->errors, 'errors'); - } - } - else - { - setEventMessages($account->error, $account->errors, 'errors'); - } -} /* @@ -259,10 +298,11 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') */ $form = new Form($db); +$formfile = new FormFile($db); llxHeader(); -$head=societe_prepare_head2($object); +$head=societe_prepare_head($object); if (! $id) $account->fetch(0,$object->id); @@ -270,7 +310,6 @@ else $account->fetch($id); if (empty($account->socid)) $account->socid=$object->id; - if ($socid && $action == 'edit' && $user->rights->societe->creer) { print ''; @@ -315,7 +354,6 @@ if ($socid && $action != 'edit' && $action != "create") print ''; // Show fields of bank account - foreach($account->getFieldsToShow() as $val) { if ($val == 'BankCode') { @@ -324,24 +362,31 @@ if ($socid && $action != 'edit' && $action != "create") $content = $account->code_guichet; } elseif ($val == 'BankAccountNumber') { $content = $account->number; + if (! empty($account->label)) { + if (! checkBanForAccount($account)) { + $content.= ' '.img_picto($langs->trans("NotValid"),'warning'); + } else { + $content.= ' '.img_picto($langs->trans("Valid"),'info'); + } + } } elseif ($val == 'BankAccountNumberKey') { $content = $account->cle_rib; }elseif ($val == 'IBAN') { $content = $account->iban; if (! empty($account->iban)) { if (! checkIbanForAccount($account)) { - $content.= img_picto($langs->trans("IbanNotValid"),'warning'); + $content.= ' '.img_picto($langs->trans("IbanNotValid"),'warning'); } else { - $content.= img_picto($langs->trans("IbanValid"),'info'); + $content.= ' '.img_picto($langs->trans("IbanValid"),'info'); } } }elseif ($val == 'BIC') { $content = $account->bic; if (! empty($account->bic)) { if (! checkSwiftForAccount($account)) { - $content.= img_picto($langs->trans("SwiftNotValid"),'warning'); + $content.= ' '.img_picto($langs->trans("SwiftNotValid"),'warning'); } else { - $content.= img_picto($langs->trans("SwiftValid"),'info'); + $content.= ' '.img_picto($langs->trans("SwiftValid"),'info'); } } } @@ -351,26 +396,20 @@ if ($socid && $action != 'edit' && $action != "create") print ''; } - print '\n"; - print '\n"; - print '\n"; print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print "'; + if ($conf->global->PAYMENTORDER_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'bill').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print '
'; + + // Picto warning + $version=$objMod->getVersion(0); + $versiontrans=$objMod->getVersion(1); + if (preg_match('/development/i', $version)) print img_warning($langs->trans("Development"), 'style="float: left"'); + if (preg_match('/experimental/i', $version)) print img_warning($langs->trans("Experimental"), 'style="float: left"'); + if (preg_match('/deprecated/i', $version)) print img_warning($langs->trans("Deprecated"), 'style="float: left"'); + + // Picto external + if ($textexternal) print img_picto($langs->trans("ExternalModule",$dirofmodule), 'external', 'style="float: left"'); + print $versiontrans; + print "'; - if ($conf->global->PAYMENTORDER_ADDON_PDF == $name) { + if ($conf->global->BANKADDON_PDF == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print '' . img_picto($langs->trans("Disabled"), 'off') . ''; @@ -318,12 +345,12 @@ foreach ($dirmodels as $reldir) } $htmltooltip .= '

' . $langs->trans("FeaturesSupported") . ':'; $htmltooltip .= '
' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1); - $htmltooltip .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); - $htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); + //$htmltooltip .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); + //$htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); $htmltooltip .= '
' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1); // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); - $htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); + //$htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); print '
'; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -347,8 +374,7 @@ foreach ($dirmodels as $reldir) } } } - - +//} dol_fiche_end(); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 9cb9e130bab..a26062e2bac 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1450,8 +1450,9 @@ class Account extends CommonObject */ function initAsSpecimen() { + $this->specimen = 1; $this->ref = 'MBA'; - $this->label = 'My Bank account'; + $this->label = 'My Big Company Bank account'; $this->bank = 'MyBank'; $this->courant = Account::TYPE_CURRENT; $this->clos = Account::STATUS_OPEN; @@ -1461,7 +1462,7 @@ class Account extends CommonObject $this->cle_rib = 50; $this->bic = 'AA12'; $this->iban = 'FR999999999'; - $this->domiciliation = 'The bank addresse'; + $this->domiciliation = 'My bank address'; $this->proprio = 'Owner'; $this->owner_address = 'Owner address'; $this->country_id = 1; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index cd14736632d..5bc09419666 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1525,7 +1525,8 @@ class BonPrelevement extends CommonObject */ static function buildRumNumber($row_code_client, $row_datec, $row_drum) { - $pre = ($row_datec > 1359673200) ? 'RUM-' : '++R'; + global $langs; + $pre = ($row_datec > 1359673200) ? $langs->trans('RUM').'-' : '++R'; return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php new file mode 100644 index 00000000000..a496e303fa6 --- /dev/null +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -0,0 +1,472 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bank/doc/pdf_ban.modules.php + * \ingroup bank + * \brief File of class to generate document with template ban + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + +/** + * Classe permettant de generer les projets au modele Ban + */ + +class pdf_ban extends ModeleBankAccountDoc +{ + var $emetteur; // Objet societe qui emet + var $version = 'development'; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("bank"); + $langs->load("withdrawals"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "ban"; + $this->description = $langs->trans("DocumentModelBan").' (Volunteer wanted to finish)'; + + // Dimension page pour format A4 + $this->type = 'pdf'; + $formatarray=pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_codeproduitservice = 1; // Affiche code produit-service + + // Recupere emmetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + + // Defini position des colonnes + $this->posxref=$this->marge_gauche+1; + $this->posxlabel=$this->marge_gauche+25; + $this->posxworkload=$this->marge_gauche+100; + $this->posxprogress=$this->marge_gauche+130; + $this->posxdatestart=$this->marge_gauche+150; + $this->posxdateend=$this->marge_gauche+170; + } + + + /** + * Fonction generant le projet sur le disque + * + * @param Project $object Object project a generer + * @param Translate $outputlangs Lang output object + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs) + { + 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 + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("projects"); + + if ($conf->bank->dir_output) + { + //$nblignes = count($object->lines); // This is set later with array of tasks + + // Definition of $dir and $file + if ($object->specimen) + { + $dir = $conf->bank->dir_output; + $file = $dir . "/SPECIMEN.pdf"; + } + else + { + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->bank->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; + } + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return 0; + } + } + + if (file_exists($dir)) + { + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + $pdf->SetAutoPageBreak(1,0); + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + + $pdf->Open(); + $pagenb=0; + $pdf->SetDrawColor(128,128,128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("BAN")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("BAN")); + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + // New page + $pdf->AddPage(); + $pagenb++; + $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); + + $tab_top = 50; + $tab_height = 200; + $tab_top_newpage = 40; + $tab_height_newpage = 210; + + // Affiche notes + if (! empty($object->note_public)) + { + $pdf->SetFont('','', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($object->note_public), 0, 1); + $nexY = $pdf->GetY(); + $height_note=$nexY-($tab_top-2); + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-3, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; + + $pdf->SetXY($this->marge_gauche, $curY); + $pdf->MultiCell(200, 3, $outputlangs->trans("BAN").' : '.$object->account_number, 0, 'L'); + + // Boucle sur les lignes + /* + for ($i = 0 ; $i < $nblignes ; $i++) + { + $curY = $nexY; + + // Description of ligne + $ref=$object->lines[$i]->ref; + $libelleline=$object->lines[$i]->label; + $progress=$object->lines[$i]->progress.'%'; + $datestart=dol_print_date($object->lines[$i]->date_start,'day'); + $dateend=dol_print_date($object->lines[$i]->date_end,'day'); + $planned_workload=convertSecondToTime($object->lines[$i]->planned_workload,'allhourmin'); + + $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page + + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); + $pdf->SetXY($this->posxlabel, $curY); + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); + $pdf->SetXY($this->posxworkload, $curY); + $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload, 0, 'R'); + $pdf->SetXY($this->posxprogress, $curY); + $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R'); + + $pdf->SetXY($this->posxdatestart, $curY); + $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C'); + $pdf->SetXY($this->posxdateend, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C'); + + $pageposafter=$pdf->getPage(); + + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + $nexY = $pdf->GetY(); + + // Add line + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->SetLineStyle(array('dash'=>0)); + } + + $nexY+=2; // Passe espace entre les lignes + + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) + { + $pdf->setPage($pagenb); + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + } + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + } + } + */ + + // Show square + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + + /* + * Pied de page + */ + $this->_pagefoot($pdf,$object,$outputlangs); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + + $pdf->Close(); + + $pdf->Output($file,'F'); + + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return 0; + } + } + + $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); + return 0; + } + + + /** + * Show table for lines + * + * @param PDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y + * @param Translate $outputlangs Langs object + * @param int $hidetop Hide top bar of array + * @param int $hidebottom Hide bottom bar of array + * @return void + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) + { + global $conf,$mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + + } + + /** + * Show top header of page. + * + * @param PDF $pdf Object PDF + * @param Project $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void + */ + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + { + global $langs,$conf,$mysoc; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B', $default_font_size + 3); + + $posx=$this->page_largeur-$this->marge_droite-100; + $posy=$this->marge_haute; + + $pdf->SetXY($this->marge_gauche,$posy); + + // Logo + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; + if ($mysoc->logo) + { + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); + } + } + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); + + $pdf->SetFont('','B', $default_font_size + 3); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("BAN")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); + $pdf->SetFont('','', $default_font_size + 2); + + $posy+=6; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date(dol_now(),'day',false,$outputlangs,true), '', 'R'); + /*$posy+=6; + $pdf->SetXY($posx,$posy); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); + */ + + $pdf->SetTextColor(0,0,60); + + // Add list of linked objects + /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... + $object->fetchObjectLinked(); + + foreach($object->linkedObjects as $objecttype => $objects) + { + var_dump($objects);exit; + if ($objecttype == 'commande') + { + $outputlangs->load('orders'); + $num=count($objects); + for ($i=0;$i<$num;$i++) + { + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $text=$objects[$i]->ref; + if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')'; + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); + } + } + } + */ + + } + + /** + * Show footer of page. Need this->emetteur object + * + * @param PDF $pdf PDF + * @param Project $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return integer + */ + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + //return pdf_pagefoot($pdf,$outputlangs,'BANK_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + } + +} + diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 111b426267b..932fdd2d9f0 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -23,7 +23,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -36,7 +36,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; class pdf_sepamandate extends ModeleBankAccountDoc { var $emetteur; // Objet societe qui emet - + var $version = 'dolibarr'; + /** * Constructor * @@ -48,6 +49,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $langs->load("main"); $langs->load("bank"); + $langs->load("withdrawals"); $langs->load("companies"); $this->db = $db; @@ -107,11 +109,19 @@ class pdf_sepamandate extends ModeleBankAccountDoc { //$nblignes = count($object->lines); // This is set later with array of tasks - $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->bank->dir_output; - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; - + // Definition of $dir and $file + if ($object->specimen) + { + $dir = $conf->bank->dir_output; + $file = $dir . "/SPECIMEN.pdf"; + } + else + { + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->bank->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; + } + if (! file_exists($dir)) { if (dol_mkdir($dir) < 0) @@ -148,27 +158,15 @@ class pdf_sepamandate extends ModeleBankAccountDoc } $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Complete object by loading several other informations - $task = new Task($this->db); - $tasksarray = $task->getTasksArray(0,0,$object->id); - - if (! $object->id > 0) // Special case when used with object = specimen, we may return all lines - { - $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray))); - } - - $object->lines=$tasksarray; - $nblignes=count($object->lines); - $pdf->Open(); $pagenb=0; $pdf->SetDrawColor(128,128,128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("Project")); + $pdf->SetSubject($outputlangs->transnoentities("SepaMandate")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project")); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate")); if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right @@ -210,7 +208,12 @@ class pdf_sepamandate extends ModeleBankAccountDoc $curY = $tab_top + 7; $nexY = $tab_top + 7; + //var_dump($object);exit; + $pdf->SetXY($this->marge_gauche, $curY); + $pdf->MultiCell(200, 3, $outputlangs->trans("RUMLong").' ('.$outputlangs->trans("RUM").')'.' : '.$object->rum, 0, 'L'); + // Boucle sur les lignes + /* for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; @@ -290,7 +293,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc $pagenb++; } } - + */ + // Show square if ($pagenb == 1) { @@ -359,34 +363,6 @@ class pdf_sepamandate extends ModeleBankAccountDoc $default_font_size = pdf_getPDFFontSize($outputlangs); - $pdf->SetDrawColor(128,128,128); - - // Rect prend une longueur en 3eme param - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); - // line prend une position y en 3eme param - $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); - - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','', $default_font_size); - - $pdf->SetXY($this->posxref, $tab_top+1); - $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L'); - - $pdf->SetXY($this->posxlabel, $tab_top+1); - $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L'); - - $pdf->SetXY($this->posxworkload, $tab_top+1); - $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R'); - - $pdf->SetXY($this->posxprogress, $tab_top+1); - $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R'); - - $pdf->SetXY($this->posxdatestart, $tab_top+1); - $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C'); - - $pdf->SetXY($this->posxdateend, $tab_top+1); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); - } /** @@ -436,16 +412,17 @@ class pdf_sepamandate extends ModeleBankAccountDoc $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R'); $pdf->SetFont('','', $default_font_size + 2); $posy+=6; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R'); - $posy+=6; + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date(dol_now(),'day',false,$outputlangs,true), '', 'R'); + /*$posy+=6; $pdf->SetXY($posx,$posy); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); + */ $pdf->SetTextColor(0,0,60); diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 33ca523d00b..d3c28b246df 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -70,7 +70,7 @@ class modBanque extends DolibarrModules // Dependancies $this->depends = array(); - $this->requiredby = array("modComptabilite","modAccounting"); + $this->requiredby = array("modComptabilite","modAccounting","modPrelevement"); $this->conflictwith = array(); $this->langfiles = array("banks","compta","bills","companies"); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0d5e6e464e9..626af0340a2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1355,7 +1355,7 @@ GenbarcodeLocation=Bar code generation command line tool (used by internal engin BarcodeInternalEngine=Internal engine BarCodeNumberManager=Manager to auto define barcode numbers ##### Prelevements ##### -WithdrawalsSetup=Withdrawal module setup +WithdrawalsSetup=Setup of module Direct debit payment orders ##### ExternalRSS ##### ExternalRSSSetup=External RSS imports setup NewRSS=New RSS Feed diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 8a6a6aaeeac..3cef6fd6c40 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -32,8 +32,8 @@ IbanNotValid=IBAN is Not Valid BIC=BIC/SWIFT number SwiftValid=BIC/SWIFT is Valid SwiftNotValid=BIC/SWIFT is Not Valid -StandingOrders=Standing orders -StandingOrder=Standing order +StandingOrders=Direct Debit orders +StandingOrder=Direct debit order AccountStatement=Account statement AccountStatementShort=Statement AccountStatements=Account statements diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index ac27ef018fd..3210c3ff838 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -209,8 +209,8 @@ EscompteOffered=Discount offered (payment before term) EscompteOfferedShort=Discount SendBillRef=Submission of invoice %s SendReminderBillRef=Submission of invoice %s (reminder) -StandingOrders=Standing orders -StandingOrder=Standing order +StandingOrders=Direct debit orders +StandingOrder=Direct debit order NoDraftBills=No draft invoices NoOtherDraftBills=No other draft invoices NoDraftInvoices=No draft invoices @@ -351,8 +351,8 @@ VarAmount=Variable amount (%% tot.) # PaymentType PaymentTypeVIR=Bank transfer PaymentTypeShortVIR=Bank transfer -PaymentTypePRE=Bank's order -PaymentTypeShortPRE=Bank's order +PaymentTypePRE=Direct debit payment order +PaymentTypeShortPRE=Debit payment order PaymentTypeLIQ=Cash PaymentTypeShortLIQ=Cash PaymentTypeCB=Credit card diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0462b4d1dc9..8c40a808074 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -175,6 +175,7 @@ ErrorStockIsNotEnoughToAddProductOnInvoice=Stock is not enougth for product %s t ErrorStockIsNotEnoughToAddProductOnShipment=Stock is not enougth for product %s to add it into a new shipment. ErrorStockIsNotEnoughToAddProductOnProposal=Stock is not enougth for product %s to add it into a new proposal. ErrorFailedToLoadLoginFileForMode=Failed to get the login file for mode '%s'. +ErrorModuleNotFound=File of module was not found. # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 3ecc090f2fe..443524f9a30 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -3,26 +3,26 @@ CustomersStandingOrdersArea=Direct debit payment orders area SuppliersStandingOrdersArea=Direct credit payment orders area StandingOrders=Direct debit payment orders StandingOrder=Direct debit payment order -NewStandingOrder=New direct debit payment order +NewStandingOrder=New direct debit order StandingOrderToProcess=To process -WithdrawalsReceipts=Withdrawal receipts -WithdrawalReceipt=Withdrawal receipt -LastWithdrawalReceipts=Latest %s withdrawal receipts -WithdrawalsLines=Withdrawal lines +WithdrawalsReceipts=Direct debit orders +WithdrawalReceipt=Direct debit order +LastWithdrawalReceipts=Latest %s direct debit files +WithdrawalsLines=Direct debit order lines RequestStandingOrderToTreat=Request for direct debit payment order to process RequestStandingOrderTreated=Request for direct debit payment order processed NotPossibleForThisStatusOfWithdrawReceiptORLine=Not yet possible. Withdraw status must be set to 'credited' before declaring reject on specific lines. -NbOfInvoiceToWithdraw=Nb. of invoice with withdraw request -NbOfInvoiceToWithdrawWithInfo=Nb. of invoice with withdraw request for customers having defined bank account information -InvoiceWaitingWithdraw=Invoice waiting for withdraw +NbOfInvoiceToWithdraw=Nb. of invoice with direct debit order +NbOfInvoiceToWithdrawWithInfo=Nb. of customer invoice with direct debit payment orders having defined bank account information +InvoiceWaitingWithdraw=Invoice waiting for direct debit AmountToWithdraw=Amount to withdraw -WithdrawsRefused=Withdraws refused +WithdrawsRefused=Direct debit refused NoInvoiceToWithdraw=No customer invoice in payment mode "withdraw" is waiting. Go on 'Withdraw' tab on invoice card to make a request. ResponsibleUser=Responsible user -WithdrawalsSetup=Withdrawal setup -WithdrawStatistics=Withdraw's statistics -WithdrawRejectStatistics=Withdraw reject's statistics -LastWithdrawalReceipt=Latest %s withdrawal receipts +WithdrawalsSetup=Direct debit payment setup +WithdrawStatistics=Direct debit payment statistics +WithdrawRejectStatistics=Direct debit payment reject statistics +LastWithdrawalReceipt=Latest %s direct debit receipts MakeWithdrawRequest=Make a withdraw request ThirdPartyBankCode=Third party bank code NoInvoiceCouldBeWithdrawed=No invoice withdrawed with success. Check that invoice are on companies with a valid BAN. @@ -47,7 +47,7 @@ StatusRefused=Refused StatusMotif0=Unspecified StatusMotif1=Insufficient funds StatusMotif2=Request contested -StatusMotif3=No Withdrawal order +StatusMotif3=No direct debit payment order StatusMotif4=Customer Order StatusMotif5=RIB unusable StatusMotif6=Account without balance @@ -62,7 +62,7 @@ NotifyCredit=Withdrawal Credit NumeroNationalEmetter=National Transmitter Number WithBankUsingRIB=For bank accounts using RIB WithBankUsingBANBIC=For bank accounts using IBAN/BIC/SWIFT -BankToReceiveWithdraw=Bank account to receive withdraws +BankToReceiveWithdraw=Bank account to receive direct debit CreditDate=Credit on WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country %s (Your country is not supported) ShowWithdraw=Show Withdraw @@ -72,11 +72,13 @@ WithdrawalFile=Withdrawal file SetToStatusSent=Set to status "File Sent" ThisWillAlsoAddPaymentOnInvoice=This will also apply payments to invoices and will classify them as "Paid" StatisticsByLineStatus=Statistics by status of lines -RUM=RUM -RUMWillBeGenerated=RUM number will be generated once bank account information are saved -WithdrawMode=Withdraw mode (FRST or RECUR) +RUM=UMR +RUMLong=Unique Mandate Reference +RUMWillBeGenerated=UMR number will be generated once bank account information are saved +WithdrawMode=Direct debit mode (FRST or RECUR) WithdrawRequestAmount=Withdraw request amount: WithdrawRequestErrorNilAmount=Unable to create withdraw request for nil amount. +SepaMandate=SEPA Direct Debit Mandate ### Notifications InfoCreditSubject=Payment of direct debit payment order %s by the bank diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 774976c3a4a..63d2a48d901 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -129,6 +129,8 @@ class CompanyBankAccount extends Account if ($conf->prelevement->enabled) { $sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'"; + $sql.= ",rum = '".$this->db->escape($this->rum)."'"; + $sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null"); } if (trim($this->label) != '') $sql.= ",label = '".$this->db->escape($this->label)."'"; @@ -302,5 +304,36 @@ class CompanyBankAccount extends Account 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->specimen = 1; + $this->ref = 'CBA'; + $this->label = 'CustomerCorp Bank account'; + $this->bank = 'CustomerCorp Bank'; + $this->courant = Account::TYPE_CURRENT; + $this->clos = Account::STATUS_OPEN; + $this->code_banque = '123'; + $this->code_guichet = '456'; + $this->number = 'CUST12345'; + $this->cle_rib = 50; + $this->bic = 'CC12'; + $this->iban = 'FR999999999'; + $this->domiciliation = 'Bank address of customer corp'; + $this->proprio = 'Owner'; + $this->owner_address = 'Owner address'; + $this->country_id = 1; + + $this->rum = 'UMR-CU1212-0007-5-1475405262'; + $this->frstrecur = 'FRST'; + } + } diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index f1ba5217b8e..dd12548400f 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -50,6 +50,7 @@ $ribid=GETPOST("ribid","int"); $action=GETPOST("action"); $account = new CompanyBankAccount($db); +$prelevement = new BonPrelevement($db); /* @@ -106,7 +107,12 @@ if ($action == 'update' && ! $_POST["cancel"]) $account->proprio = GETPOST('proprio','alpha'); $account->owner_address = GETPOST('owner_address','alpha'); $account->frstrecur = GETPOST('frstrecur','alpha'); - + if (empty($account->rum)) + { + $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } + $result = $account->update($user); if (! $result) { @@ -185,7 +191,14 @@ if ($action == 'add' && ! $_POST["cancel"]) if (! $error) { - $result = $account->update($user); // TODO Use create and include update into create method + if (empty($account->rum)) + { + $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } + + $result = $account->update($user); // This will set the UMR number. + // TODO Use create and include update into create method if (! $result) { setEventMessages($account->error, $account->errors, 'errors'); @@ -246,7 +259,6 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') */ $form = new Form($db); -$prelevement = new BonPrelevement($db); llxHeader(); @@ -384,7 +396,7 @@ if ($socid && $action != 'edit' && $action != "create") print_liste_field_titre($langs->trans("BIC")); if (! empty($conf->prelevement->enabled)) { - print 'RUM'.$langs->trans("RUM").''.$langs->trans("WithdrawMode").''.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).''.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).''.$rib->rum.''.$rib->frstrecur.''.$account->bank.'
'.$langs->trans("BankAccountDomiciliation").''; + print '
'.$langs->trans("BankAccountDomiciliation").''; print $account->domiciliation; print "
'.$langs->trans("BankAccountOwner").''; + print '
'.$langs->trans("BankAccountOwner").''; print $account->proprio; print "
'.$langs->trans("BankAccountOwnerAddress").''; + print '
'.$langs->trans("BankAccountOwnerAddress").''; print $account->owner_address; print "
'; - // Check BBAN - if ($account->label && ! checkBanForAccount($account)) - { - print '
'.$langs->trans("RIBControlError").'
'; - } - print ""; dol_fiche_end(); @@ -401,10 +440,6 @@ if ($socid && $action != 'edit' && $action != "create") } print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"'); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); - if (! empty($conf->prelevement->enabled)) - { - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); - } print "\n"; foreach ($rib_list as $rib) @@ -415,11 +450,47 @@ if ($socid && $action != 'edit' && $action != "create") // Bank name print ''.$rib->bank.''; // Account number - print ''.$rib->getRibLabel(false).''; + print ''; + $string=''; + foreach ($rib->getFieldsToShow() as $val) { + + if ($val == 'BankCode') { + $string .= $rib->code_banque.' '; + } elseif ($val == 'BankAccountNumber') { + $string .= $rib->number.' '; + } elseif ($val == 'DeskCode') { + $string .= $rib->code_guichet.' '; + } elseif ($val == 'BankAccountNumberKey') { + $string .= $rib->cle_rib.' '; + /* Already output after + }elseif ($val == 'BIC') { + $string .= $rib->bic.' '; + }elseif ($val == 'IBAN') { + $string .= $rib->iban.' ';*/ + } + } + print $string; + print ''; // IBAN - print ''.$rib->iban.''; + print ''.$rib->iban; + if (! empty($rib->iban)) { + if (! checkIbanForAccount($rib)) { + print ' '.img_picto($langs->trans("IbanNotValid"),'warning'); + } else { + print ' '.img_picto($langs->trans("IbanValid"),'info'); + } + } + print ''; // BIC - print ''.$rib->bic.''; + print ''.$rib->bic; + if (! empty($rib->bic)) { + if (! checkSwiftForAccount($rib)) { + print ' '.img_picto($langs->trans("SwiftNotValid"),'warning'); + } else { + print ' '.img_picto($langs->trans("SwiftValid"),'info'); + } + } + print ''; if (! empty($conf->prelevement->enabled)) { @@ -458,27 +529,6 @@ if ($socid && $action != 'edit' && $action != "create") } print ''; - if (! empty($conf->prelevement->enabled)) - { - include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; - $modellist=ModeleBankAccountDoc::liste_modeles($db); - print ''; - if (is_array($modellist) && count($modellist) == 1) // If there is only one element - { - $arraykeys=array_keys($modellist); - $modelselected=$arraykeys[0]; - } - $out.= $form->selectarray('model', $modellist, $modelselected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); - $out.= ajax_combobox('model'); - //print $out; - $buttonlabel=$langs->trans("Generate"); - $genbutton = ''; // TODO Add link to generate doc - } - print ''; } @@ -494,6 +544,68 @@ if ($socid && $action != 'edit' && $action != "create") dol_print_error($db); } + + if ($socid && $action != 'edit' && $action != 'create') + { + /* + * Barre d'actions + */ + print '
'; + + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Add").''; + } + + print '
'; + } + + + + + if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) + { + print '
'; + print ''; // ancre + + /* + * Documents generes + */ + $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; + $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; + $genallowed=$user->rights->societe->creer; + $delallowed=$user->rights->societe->supprimer; + + $var=true; + + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, '', 0, '', $object->default_lang); + + print '
'; + + + print '
'; + + print '
'; + } + /* + include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; + $modellist=ModeleBankAccountDoc::liste_modeles($db); + //print ''; + if (is_array($modellist) && count($modellist) == 1) // If there is only one element + { + $arraykeys=array_keys($modellist); + $modelselected=$arraykeys[0]; + } + $out.= $form->selectarray('model', $modellist, $modelselected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out.= ajax_combobox('model'); + //print $out; + $buttonlabel=$langs->trans("Generate"); + $genbutton = ''; // TODO Add link to generate doc + */ } // Edit @@ -510,7 +622,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print '
'; print ''; - print ''; + print ''; print ''; print ''; @@ -650,10 +762,10 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) } // IBAN - print ''; + print 'needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("IBAN").''; print ''; - print ''; + print 'needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("BIC").''; print ''; print ''; - print ''; - } - // Parent company if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b1b17e68309..91fa5dbb0ec 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3974,6 +3974,9 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +.select2-container .select2-choice > .select2-chosen { + margin-right: 23px; +} .select2-container .select2-choice .select2-arrow { border-radius: 0; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f5dbc02e9b3..6bfebf6fac0 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3841,6 +3841,9 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +.select2-container .select2-choice > .select2-chosen { + margin-right: 23px; +} .select2-container .select2-choice .select2-arrow { border-radius: 0; } From 0d9f28bd616bd427ac16ed77ca1bf784cb1aa54c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Oct 2016 16:50:28 +0200 Subject: [PATCH 8/8] Fix dash in incoterm label --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4be8e03a00f..1457d10726c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3080,6 +3080,7 @@ abstract class CommonObject /** * Return incoterms informations + * TODO Use a cache for label get * * @return string incoterms info */ @@ -3098,7 +3099,7 @@ abstract class CommonObject } } - $out .= ' - '.$this->location_incoterms; + $out .= (($res->code && $this->location_incoterms)?' - ':'').$this->location_incoterms; return $out; }
'.$langs->trans("LabelRIB").'
'.$langs->trans("LabelRIB").'
'.$langs->trans("BankName").'
needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("IBAN").'
needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("BIC").'
'.$langs->trans("BankAccountDomiciliation").''; @@ -710,23 +822,6 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) } - -if ($socid && $action != 'edit' && $action != 'create') -{ - /* - * Barre d'actions - */ - print '
'; - - if ($user->rights->societe->creer) - { - print ''.$langs->trans("Add").''; - } - - print '
'; -} - - llxFooter(); $db->close(); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 22af7a3dae8..3d561275c38 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -2267,22 +2267,6 @@ else print $object->showOptionals($extrafields); } - // Ban - if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) - { - print '
'; - print '
'; - print $langs->trans('RIB'); - print ''; - if ($user->rights->societe->creer) print ''.img_edit().''; - else print ' '; - print '
'; - print '
'; - print $object->display_rib(); - print '