\n";
+print "
\n";
+print '| '.$langs->trans("Name").' | ';
+print ''.$langs->trans("Description").' | ';
+print ''.$langs->trans("Status")." | \n";
+print ''.$langs->trans("Default")." | \n";
+print ''.$langs->trans("ShortInfo").' | ';
+print ''.$langs->trans("Preview").' | ';
+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 '
| ';
+ print (empty($module->name)?$name:$module->name);
+ print " | \n";
+ if (method_exists($module,'info')) print $module->info($langs);
+ else print $module->description;
+ print ' | ';
+
+ // Active
+ if (in_array($name, $def))
+ {
+ print ''."\n";
+ print '';
+ print img_picto($langs->trans("Enabled"),'switch_on');
+ print '';
+ print ' | ';
+ }
+ else
+ {
+ print ''."\n";
+ print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'';
+ print " | ";
+ }
+
+ // Default
+ 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 ' | ';
+
+ // 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 '';
+ print $form->textwithpicto('',$htmltooltip,1,0);
+ print ' | ';
+
+ // Preview
+ print '';
+ if ($module->type == 'pdf')
+ {
+ print ''.img_object($langs->trans("Preview"),'bill').'';
+ }
+ else
+ {
+ print img_object($langs->trans("PreviewNotAvailable"),'generic');
+ }
+ print ' | ';
+
+ print "
\n";
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+*/
+
+
dol_fiche_end();
print '
';
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/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;
}
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index d7d142c7420..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
@@ -490,7 +492,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';
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/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/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php
new file mode 100644
index 00000000000..699b186a9d2
--- /dev/null
+++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php
@@ -0,0 +1,391 @@
+
+ *
+ * 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');
+
+
+
+ // 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 fac7ef1a9d5..820d9bec2f3 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.'/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';
@@ -37,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,11 +48,12 @@ class pdf_sepamandate extends ModeleBankAccountDoc
global $conf,$langs,$mysoc;
$langs->load("main");
- $langs->load("projects");
+ $langs->load("bank");
+ $langs->load("withdrawals");
$langs->load("companies");
$this->db = $db;
- $this->name = "baleine";
+ $this->name = "sepamandate";
$this->description = $langs->trans("DocumentModelSepaMandate");
// Dimension page pour format A4
@@ -93,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
@@ -104,15 +105,23 @@ 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;
- 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)
@@ -149,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
@@ -211,87 +208,140 @@ class pdf_sepamandate extends ModeleBankAccountDoc
$curY = $tab_top + 7;
$nexY = $tab_top + 7;
- // Boucle sur les lignes
- for ($i = 0 ; $i < $nblignes ; $i++)
+ $posY = $curY;
+
+ $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)
{
@@ -304,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
*/
@@ -360,36 +419,84 @@ 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');
-
}
+
+ /**
+ * 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.
*
@@ -437,16 +544,22 @@ 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;
+ $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');
+ */
$pdf->SetTextColor(0,0,60);
@@ -489,7 +602,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',null,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
}
}
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/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/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/admin.lang b/htdocs/langs/en_US/admin.lang
index 54cda62d35b..626af0340a2 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).
@@ -437,8 +438,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 +616,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
@@ -1354,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 b0b7af4076f..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
@@ -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
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 8af385091aa..ce839d04eed 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/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 54b3de3915b..5030ebffaac 100644
--- a/htdocs/langs/en_US/withdrawals.lang
+++ b/htdocs/langs/en_US/withdrawals.lang
@@ -1,27 +1,28 @@
# 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 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
+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.
@@ -46,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
@@ -61,28 +62,42 @@ 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
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"
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
+PleaseReturnMandate=Please return this mandate form to
+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 *
+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 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/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php
index 774976c3a4a..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;
@@ -129,6 +131,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 +306,39 @@ 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->date_rum =dol_now() - 10000;
+ $this->frstrecur = 'FRST';
+
+ $this->socid = 0;
+ }
+
}
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 e4eb0ef7053..5c989720f1c 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
@@ -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,207 +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');
-
- $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)
- {
- $result = $account->update($user); // 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');
- }
-}
/*
@@ -246,11 +298,11 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes')
*/
$form = new Form($db);
-$prelevement = new BonPrelevement($db);
+$formfile = new FormFile($db);
llxHeader();
-$head=societe_prepare_head2($object);
+$head=societe_prepare_head($object);
if (! $id)
$account->fetch(0,$object->id);
@@ -258,7 +310,6 @@ else
$account->fetch($id);
if (empty($account->socid)) $account->socid=$object->id;
-
if ($socid && $action == 'edit' && $user->rights->societe->creer)
{
print '