diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 32f527af599..f1e00a7016d 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -297,13 +297,13 @@ if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $
$result = $fac->set_valid($user);
if ($result >= 0)
{
- $outputlangs = $langs;
- if (! empty($_REQUEST['lang_id']))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($_REQUEST['lang_id']);
- }
- facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
+ $outputlangs = $langs;
+ if (! empty($_REQUEST['lang_id']))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
+ }
+ facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
}
else
{
@@ -347,13 +347,13 @@ if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->glo
{
$fac->set_draft($user);
- $outputlangs = $langs;
- if (! empty($_REQUEST['lang_id']))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($_REQUEST['lang_id']);
- }
- facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
+ $outputlangs = $langs;
+ if (! empty($_REQUEST['lang_id']))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
+ }
+ facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
}
}
@@ -838,14 +838,14 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
$date_start=$_POST['date_start'.$suffixe.'year'].'-'.$_POST['date_start'.$suffixe.'month'].'-'.$_POST['date_start'.$suffixe.'day'];
// If hour/minute are specified, append them
if (($_POST['date_start'.$suffixe.'hour']) && ($_POST['date_start'.$suffixe.'min']))
- $date_start.=' '.$_POST['date_start'.$suffixe.'hour'].':'.$_POST['date_start'.$suffixe.'min'];
+ $date_start.=' '.$_POST['date_start'.$suffixe.'hour'].':'.$_POST['date_start'.$suffixe.'min'];
}
if ($_POST['date_end'.$suffixe.'year'] && $_POST['date_end'.$suffixe.'month'] && $_POST['date_end'.$suffixe.'day'])
{
$date_end=$_POST['date_end'.$suffixe.'year'].'-'.$_POST['date_end'.$suffixe.'month'].'-'.$_POST['date_end'.$suffixe.'day'];
// If hour/minute are specified, append them
if (($_POST['date_end'.$suffixe.'hour']) && ($_POST['date_end'.$suffixe.'min']))
- $date_end.=' '.$_POST['date_end'.$suffixe.'hour'].':'.$_POST['date_end'.$suffixe.'min'];
+ $date_end.=' '.$_POST['date_end'.$suffixe.'hour'].':'.$_POST['date_end'.$suffixe.'min'];
}
$price_base_type = 'HT';
@@ -905,7 +905,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
$info_bits=0;
if ($tva_npr) $info_bits |= 0x01;
-
+
if($prod->price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($prod->price_min)))
{
$fac->error = $langs->trans("CantBeLessThanMinPrice",price2num($prod->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)) ;
@@ -935,13 +935,13 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
if ($result > 0)
{
- $outputlangs = $langs;
- if (! empty($_REQUEST['lang_id']))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($_REQUEST['lang_id']);
- }
- facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
+ $outputlangs = $langs;
+ if (! empty($_REQUEST['lang_id']))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
+ }
+ facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
}
else
{
@@ -965,14 +965,14 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
$date_start=$_POST['date_startyear'].'-'.$_POST['date_startmonth'].'-'.$_POST['date_startday'];
// If hour/minute are specified, append them
if (($_POST['date_starthour']) && ($_POST['date_startmin']))
- $date_start.=' '.$_POST['date_starthour'].':'.$_POST['date_startmin'];
+ $date_start.=' '.$_POST['date_starthour'].':'.$_POST['date_startmin'];
}
if ($_POST['date_endyear'] && $_POST['date_endmonth'] && $_POST['date_endday'])
{
$date_end=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday'];
// If hour/minute are specified, append them
if (($_POST['date_endhour']) && ($_POST['date_endmin']))
- $date_end.=' '.$_POST['date_endhour'].':'.$_POST['date_endmin'];
+ $date_end.=' '.$_POST['date_endhour'].':'.$_POST['date_endmin'];
}
// Define info_bits
@@ -1006,16 +1006,16 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
'HT',
$info_bits
);
-
- $outputlangs = $langs;
- if (! empty($_REQUEST['lang_id']))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($_REQUEST['lang_id']);
- }
- facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
+
+ $outputlangs = $langs;
+ if (! empty($_REQUEST['lang_id']))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
+ }
+ facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
}
-
+
$_GET['facid']=$_POST['facid']; // Pour réaffichage de la fiche en cours d'édition
}
@@ -1036,12 +1036,12 @@ if ($_GET['action'] == 'up' && $user->rights->facture->creer)
$fac->fetch($_GET['facid']);
$fac->line_up($_GET['rowid']);
- $outputlangs = $langs;
- if (! empty($_REQUEST['lang_id']))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($_REQUEST['lang_id']);
- }
+ $outputlangs = $langs;
+ if (! empty($_REQUEST['lang_id']))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
+ }
facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
Header ('Location: '.$_SERVER["PHP_SELF"].'?facid='.$_GET["facid"].'#'.$_GET['rowid']);
exit;
@@ -1053,12 +1053,12 @@ if ($_GET['action'] == 'down' && $user->rights->facture->creer)
$fac->fetch($_GET['facid']);
$fac->line_down($_GET['rowid']);
- $outputlangs = $langs;
- if (! empty($_REQUEST['lang_id']))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($_REQUEST['lang_id']);
- }
+ $outputlangs = $langs;
+ if (! empty($_REQUEST['lang_id']))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
+ }
facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
Header ('Location: '.$_SERVER["PHP_SELF"].'?facid='.$_GET["facid"].'#'.$_GET['rowid']);
exit;
@@ -1279,12 +1279,12 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
$fac->setDocModel($user, $_REQUEST['model']);
}
- $outputlangs = $langs;
- if (! empty($_REQUEST['lang_id']))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($_REQUEST['lang_id']);
- }
+ $outputlangs = $langs;
+ if (! empty($_REQUEST['lang_id']))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
+ }
$result=facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
if ($result <= 0)
{
@@ -1406,7 +1406,7 @@ if ($_GET['action'] == 'create')
print '';
}
- // Factures prédéfinnies
+ // Factures prédéfinnies
// TODO Use instead invoice in llx_facture table with a particular status
if ($conf->global->FACTURE_ENABLE_RECUR)
{
@@ -1464,7 +1464,7 @@ if ($_GET['action'] == 'create')
$options.=' ('.$facturestatic->LibStatut(0,$facparam['status']).')';
$options.='';
}
-
+
$facids=$facturestatic->list_qualified_avoir_invoices($soc->id);
if ($facids < 0)
{
@@ -1652,7 +1652,7 @@ if ($_GET['action'] == 'create')
//print ''."\n";
//print ''."\n";
print '';
-
+
print '
| '.$langs->trans('Order').' | '.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.' |
';
print '| '.$langs->trans('TotalHT').' | '.price($commande->total_ht).' |
';
print '| '.$langs->trans('TotalVAT').' | '.price($commande->total_tva)." |
";
@@ -1897,13 +1897,13 @@ else
//$resteapayer=bcadd($fac->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
//$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
$resteapayer = price2num($fac->total_ttc - $totalpaye - $totalavoir,'MT');
-
+
if ($fac->paye) $resteapayer=0;
$resteapayeraffiche=$resteapayer;
$absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
$absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
-
+
$author = new User($db);
if ($fac->user_author)
{
@@ -2047,20 +2047,20 @@ else
print '
';
}
- // Clone confirmation
+ // Clone confirmation
if ($_GET["action"] == 'clone')
{
// Create an array for form
$formquestion=array(
- //'text' => $langs->trans("ConfirmClone"),
- //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
+ //'text' => $langs->trans("ConfirmClone"),
+ //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
);
// Paiement incomplet. On demande si motif = escompte ou autre
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$fac->ref),'confirm_clone',$formquestion,'yes');
print '
';
}
-
-
+
+
// Invoice content
print '';
@@ -2911,7 +2911,7 @@ else
print ''.$langs->trans('ReOpen').'';
}
}
-
+
// Valider
if ($fac->statut == 0 && $num_lignes > 0 && (($fac->type < 2 && $fac->total_ttc >= 0) || ($fac->type == 2 && $fac->total_ttc <= 0)))
{
@@ -3028,7 +3028,7 @@ else
{
print ''.$langs->trans("ToClone").'';
}
-
+
// Clone as predefined
if ($conf->global->FACTURE_ENABLE_RECUR && $fac->type == 0 && $fac->statut == 0 && $user->rights->facture->creer)
{
diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php
index aaf727aa42c..9f12e6697c7 100644
--- a/htdocs/compta/paiement/cheque/fiche.php
+++ b/htdocs/compta/paiement/cheque/fiche.php
@@ -104,7 +104,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user-
if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->banque)
{
$remisecheque = new RemiseCheque($db);
- $remisecheque->Fetch($_GET["id"]);
+ $result = $remisecheque->Fetch($_GET["id"]);
$result = $remisecheque->Validate($user);
if ($result >= 0)
{
@@ -121,15 +121,29 @@ if ($_POST['action'] == 'builddoc' && $user->rights->banque)
{
$remisecheque = new RemiseCheque($db);
$result = $remisecheque->Fetch($_GET["id"]);
- if ($result == 0)
+
+ /*if ($_REQUEST['model'])
{
- $result = $remisecheque->GeneratePdf($_POST["model"], $langs);
- Header("Location: fiche.php?id=".$remisecheque->id);
+ $remisecheque->setDocModel($user, $_REQUEST['model']);
+ }*/
+
+ $outputlangs = $langs;
+ if (! empty($_REQUEST['lang_id']))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
+ }
+
+ $result = $remisecheque->GeneratePdf($_POST["model"], $outputlangs);
+ if ($result <= 0)
+ {
+ dolibarr_print_error($db,$result);
exit;
}
else
{
- $mesg=''.$paiement->error.'
';
+ Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$remisecheque->id.'#builddoc');
+ exit;
}
}
@@ -331,7 +345,7 @@ else
$sql.= " WHERE b.fk_type= 'CHQ'";
$sql.= " AND b.fk_bordereau = ".$remisecheque->id;
$sql.= " ORDER BY $sortfield $sortorder";
-
+ //print $sql;
$resql = $db->query($sql);
if ($resql)
{
@@ -398,15 +412,6 @@ else
print '';
-if ($_GET['action'] != 'new')
-{
- if ($remisecheque->statut == 1)
- {
- $dir = DOL_DATA_ROOT.'/compta/bordereau/'.get_exdir($remisecheque->number);
- $gen = array('Blochet');
- $formfile->show_documents("remisecheque","",$dir,'',$gen,0);
- }
-}
/*
* Boutons Actions
@@ -432,6 +437,18 @@ if ($user->societe_id == 0 && $_GET['action'] == '')
print '';
+
+if ($_GET['action'] != 'new')
+{
+ if ($remisecheque->statut == 1)
+ {
+ $dir = DOL_DATA_ROOT.'/compta/bordereau/'.get_exdir($remisecheque->number);
+ $gen = array('Blochet');
+ $formfile->show_documents("remisecheque","",$dir,$_SERVER["PHP_SELF"].'?id='.$remisecheque->id,$gen,1);
+ }
+}
+
+
$db->close();
llxFooter('$Date$ - $Revision$');
diff --git a/htdocs/compta/paiement/cheque/remisecheque.class.php b/htdocs/compta/paiement/cheque/remisecheque.class.php
index 03229397b7d..e026d14e5ec 100644
--- a/htdocs/compta/paiement/cheque/remisecheque.class.php
+++ b/htdocs/compta/paiement/cheque/remisecheque.class.php
@@ -57,10 +57,11 @@ class RemiseCheque extends CommonObject
}
/**
- \brief Load record
- \param id Id record
- \param ref Ref record
- */
+ * \brief Load record
+ * \param id Id record
+ * \param ref Ref record
+ * \return int <0 if KO, >= 0 if OK
+ */
function Fetch($id,$ref='')
{
$sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author,bc.fk_bank_account,bc.amount,bc.number,bc.statut,bc.nbcheque";
@@ -108,11 +109,11 @@ class RemiseCheque extends CommonObject
}
/**
- \brief Create a receipt to send cheques
- \param user Utilisateur qui effectue l'operation
- \param account_id Compte bancaire concerne
- \return int <0 if KO, >0 if OK
- */
+ * \brief Create a receipt to send cheques
+ * \param user Utilisateur qui effectue l'operation
+ * \param account_id Compte bancaire concerne
+ * \return int <0 if KO, >0 if OK
+ */
function Create($user, $account_id)
{
$this->errno = 0;
@@ -206,6 +207,7 @@ class RemiseCheque extends CommonObject
{
$result = -1;
$this->error=$this->db->lasterror();
+ $this->errno=$this->db->lasterrno();
dolibarr_syslog("RemiseCheque::Create Erreur $result INSERT Mysql");
}
@@ -286,7 +288,7 @@ class RemiseCheque extends CommonObject
$num=$this->getNextNumber();
- if ($this->errno == 0)
+ if ($this->errno == 0 && $num)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
$sql.= " SET statut=1, number='".$num."'";
@@ -305,19 +307,19 @@ class RemiseCheque extends CommonObject
else
{
$this->errno = -1029;
- dolibarr_syslog("Remisecheque::Validate Erreur UPDATE ($this->errno)");
+ dolibarr_syslog("Remisecheque::Validate Error ".$this->errno, LOG_ERR);
}
}
else
{
$this->errno = -1033;
- dolibarr_syslog("Remisecheque::Validate Erreur UPDATE ($this->errno)");
+ dolibarr_syslog("Remisecheque::Validate Error ".$this->errno, LOG_ERR);
}
}
if ($this->errno == 0)
{
- $this->GeneratePdf();
+ $result=$this->GeneratePdf();
}
// Commit/Rollback
@@ -412,8 +414,6 @@ class RemiseCheque extends CommonObject
require_once(DOL_DOCUMENT_ROOT ."/compta/bank/account.class.php");
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/cheque/pdf/pdf_".$model.".class.php");
- $result = $this->Fetch($this->id);
-
$class='BordereauCheque'.ucfirst($model);
$pdf = new $class($db);
@@ -424,8 +424,8 @@ class RemiseCheque extends CommonObject
$sql.= " AND bc.rowid = ".$this->id;
$sql.= " ORDER BY b.emetteur ASC, b.rowid ASC;";
+ dolibarr_syslog("RemiseCheque::GeneratePdf sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql);
-
if ($result)
{
$i = 0;
@@ -451,7 +451,8 @@ class RemiseCheque extends CommonObject
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output;
- if ($pdf->write_file(DOL_DATA_ROOT.'/compta/bordereau', $this->number, $outputlangs) > 0)
+ $result=$pdf->write_file(DOL_DATA_ROOT.'/compta/bordereau', $this->number, $outputlangs);
+ if ($result > 0)
{
$outputlangs->charset_output=$sav_charset_output;
return 1;
diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php
index a24e125e9d6..57580b9b919 100644
--- a/htdocs/html.formfile.class.php
+++ b/htdocs/html.formfile.class.php
@@ -118,9 +118,9 @@ class FormFile
/**
* \brief Affiche la cartouche de la liste des documents d'une propale, facture...
* \param modulepart propal=propal, facture=facture, ...
- * \param filename Sous rep � scanner (vide si filedir deja complet)
- * \param filedir Repertoire � scanner
- * \param urlsource Url page origine (pour retour)
+ * \param filename Sub dir to scan (vide si filedir deja complet)
+ * \param filedir Dir to scan
+ * \param urlsource Url of origin page (for return)
* \param genallowed G�n�ration autoris�e (1/0 ou array des formats)
* \param delallowed Suppression autoris�e (1/0)
* \param modelselected Modele � pr�-s�lectionner par d�faut
diff --git a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
index 378b2555e46..796cd7d00e6 100644
--- a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
+++ b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
@@ -64,20 +64,26 @@ class BordereauChequeBlochet extends FPDF
$this->marge_haute=10;
$this->marge_basse=10;
- $this->line_height = 5;
+ // Recupere emmetteur
+ $this->emetteur=$mysoc;
+ if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini
+
+ // Defini position des colonnes
+ $this->line_height = 5;
$this->line_per_page = 25;
$this->tab_height = 200; //$this->line_height * $this->line_per_page;
}
/**
- * \brief Fonction generant le rapport sur le disque
- * \param _dir Directory
- * \param number Number
- * \param outputlangs Lang output object
+ * \brief Fonction generant le rapport sur le disque
+ * \param _dir Directory
+ * \param number Number
+ * \param outputlangs Lang output object
+ * \return int 1=ok, 0=ko
*/
function write_file($_dir, $number, $outputlangs)
{
- global $user,$conf,$langs,$mysoc;
+ global $user,$conf,$langs;
if (! is_object($outputlangs)) $outputlangs=$langs;
// Force output charset to ISO, because, FPDF expect text encoded in ISO
@@ -148,6 +154,9 @@ class BordereauChequeBlochet extends FPDF
$pdf->Output($_file);
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
+
+ $langs->setPhpLang(); // On restaure langue session
+ return 1; // Pas d'erreur
}
@@ -160,15 +169,18 @@ class BordereauChequeBlochet extends FPDF
}
/**
- \brief Generate Header
- \param pdf pdf object
- \param page current page number
- \param pages number of pages
- */
+ * \brief Generate Header
+ * \param pdf pdf object
+ * \param page current page number
+ * \param pages number of pages
+ */
function Header(&$pdf, $page, $pages, $outputlangs)
{
global $langs;
+ $outputlangs->load("compta");
+ $outputlangs->load("banks");
+
$title = $outputlangs->transnoentities("CheckReceipt");
$pdf->SetFont('Arial','B',10);
$pdf->Text(10, 10, $title);