diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 6f7e231d90c..0d91e7d4edf 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -513,6 +513,7 @@ class RemiseCheque extends CommonObject $i = 0; while ($objp = $this->db->fetch_object($result)) { + $docmodel->lines[$i] = (object) array(); $docmodel->lines[$i]->bank_chq = $objp->banque; $docmodel->lines[$i]->emetteur_chq = $objp->emetteur; $docmodel->lines[$i]->amount_chq = $objp->amount; diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php index 6c49ce2a582..94ef6ce5414 100644 --- a/htdocs/compta/paiement/cheque/fiche.php +++ b/htdocs/compta/paiement/cheque/fiche.php @@ -1,8 +1,8 @@ - * Copyright (C) 2007-2011 Laurent Destailleur - * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2011 Juanjo Menent +/* Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007-2011 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,19 +36,20 @@ $langs->load('companies'); $langs->load('compta'); $id =GETPOST('id','int'); -$ref=GETPOST("ref"); -$action=GETPOST('action'); +$ref=GETPOST('ref', 'alpha'); +$action=GETPOST('action', 'alpha'); +$confirm=GETPOST('confirm', 'alpha'); // Security check -$fieldid = isset($_GET["ref"])?'number':'rowid'; +$fieldname = (! empty($ref)?'number':'rowid'); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','',$fieldid); +$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','',$fieldname); $mesg=''; -$sortfield=GETPOST("sortfield"); -$sortorder=GETPOST("sortorder"); -$page=$_GET["page"]; +$sortfield=GETPOST('sortfield', 'alpha'); +$sortorder=GETPOST('sortorder', 'alpha'); +$page=GETPOST('page', 'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="b.dateo,b.rowid"; if ($page < 0) { $page = 0 ; } @@ -56,32 +57,34 @@ $limit = $conf->liste_limit; $offset = $limit * $page ; $dir=$conf->banque->dir_output.'/bordereau/'; -$filterdate=dol_mktime(0,0,0,$_POST['fdmonth'],$_POST['fdday'],$_POST['fdyear']); +$filterdate=dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear')); $filteraccountid=GETPOST('accountid'); //var_dump($_POST); +$object = new RemiseCheque($db); + + /* * Actions */ if ($action == 'setdate' && $user->rights->banque->cheque) { - $remisecheque = new RemiseCheque($db); - $result = $remisecheque->fetch(GETPOST('id','int')); + $result = $object->fetch(GETPOST('id','int')); if ($result > 0) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $date=dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']); - $result=$remisecheque->set_date($user,$date); + $result=$object->set_date($user,$date); if ($result < 0) { - $mesg='
'.$remisecheque->error.'
'; + $mesg='
'.$object->error.'
'; } } else { - $mesg='
'.$remisecheque->error.'
'; + $mesg='
'.$object->error.'
'; } } @@ -89,13 +92,12 @@ if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->che { if (is_array($_POST['toRemise'])) { - $remisecheque = new RemiseCheque($db); - $result = $remisecheque->create($user, $_POST["accountid"], 0, $_POST['toRemise']); + $result = $object->create($user, $_POST["accountid"], 0, $_POST['toRemise']); if ($result > 0) { - if ($remisecheque->statut == 1) // If statut is validated, we build doc + if ($object->statut == 1) // If statut is validated, we build doc { - $remisecheque->fetch($remisecheque->id); // To force to reload all properties in correct property name + $object->fetch($object->id); // To force to reload all properties in correct property name // Define output language $outputlangs = $langs; $newlang=''; @@ -106,15 +108,15 @@ if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->che $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result = $remisecheque->generatePdf($_POST["model"], $outputlangs); + $result = $object->generatePdf($_POST["model"], $outputlangs); } - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id); + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else { - $mesg='
'.$remisecheque->error.'
'; + $mesg='
'.$object->error.'
'; } } else @@ -124,27 +126,25 @@ if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->che } } -if ($action == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $user->rights->banque->cheque) +if ($action == 'remove' && $id > 0 && $_GET["lineid"] > 0 && $user->rights->banque->cheque) { - $remisecheque = new RemiseCheque($db); - $remisecheque->id = $_GET["id"]; - $result = $remisecheque->removeCheck($_GET["lineid"]); + $object->id = $id; + $result = $object->removeCheck($_GET["lineid"]); if ($result === 0) { - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id); + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else { - $mesg='
'.$paiement->error.'
'; + $mesg='
'.$object->error.'
'; } } -if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque) +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->cheque) { - $remisecheque = new RemiseCheque($db); - $remisecheque->id = $_GET["id"]; - $result = $remisecheque->delete(); + $object->id = $id; + $result = $object->delete(); if ($result == 0) { Header("Location: index.php"); @@ -156,11 +156,10 @@ if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->right } } -if ($action == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque) +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->cheque) { - $remisecheque = new RemiseCheque($db); - $result = $remisecheque->fetch($_GET["id"]); - $result = $remisecheque->validate($user); + $result = $object->fetch($_GET["id"]); + $result = $object->validate($user); if ($result >= 0) { // Define output language @@ -173,9 +172,9 @@ if ($action == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->right $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result = $remisecheque->generatePdf($_POST["model"], $outputlangs); + $result = $object->generatePdf(GETPOST('model'), $outputlangs); - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$remisecheque->id); + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else @@ -186,12 +185,11 @@ if ($action == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->right if ($action == 'builddoc' && $user->rights->banque->cheque) { - $remisecheque = new RemiseCheque($db); - $result = $remisecheque->fetch($_GET["id"]); + $result = $object->fetch($_GET["id"]); /*if ($_REQUEST['model']) { - $remisecheque->setDocModel($user, $_REQUEST['model']); + $object->setDocModel($user, $_REQUEST['model']); }*/ $outputlangs = $langs; @@ -203,15 +201,15 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result = $remisecheque->generatePdf($_POST["model"], $outputlangs); + $result = $object->generatePdf($_POST["model"], $outputlangs); if ($result <= 0) { - dol_print_error($db,$remisecheque->error); + dol_print_error($db,$object->error); exit; } else { - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$remisecheque->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } @@ -245,20 +243,19 @@ if ($action == 'new') } else { - $remisecheque = new RemiseCheque($db); - $result = $remisecheque->fetch($_REQUEST["id"],$_REQUEST["ref"]); + $result = $object->fetch($id, $ref); if ($result < 0) { - dol_print_error($db,$remisecheque->error); + dol_print_error($db,$object->error); exit; } $h=0; - $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$remisecheque->id; + $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id; $head[$h][1] = $langs->trans("CheckReceipt"); $hselected = $h; $h++; - // $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/info.php?id='.$remisecheque->id; + // $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/info.php?id='.$object->id; // $head[$h][1] = $langs->trans("Info"); // $h++; @@ -269,7 +266,7 @@ else */ if ($action == 'delete') { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$remisecheque->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete','','',1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete','','',1); if ($ret == 'html') print '
'; } @@ -278,8 +275,7 @@ else */ if ($action == 'valide') { - $facid = $_GET['facid']; - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$remisecheque->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide','','',1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide','','',1); if ($ret == 'html') print '
'; } } @@ -287,10 +283,10 @@ else dol_htmloutput_errors($mesg); +$accounts = array(); if ($action == 'new') { - $accounts = array(); $lines = array(); $now=dol_now(); @@ -402,8 +398,10 @@ if ($action == 'new') { $var=!$var; - $account_id = $objp->bid; - $accounts[$objp->bid] += 1; + $account_id = $bid; + if (! isset($accounts[$bid])) + $accounts[$bid]=0; + $accounts[$bid] += 1; print ""; print ''.dol_print_date($value["date"],'day').''; @@ -436,19 +434,18 @@ if ($action == 'new') } else { - $object=$remisecheque; $linkback=''.$langs->trans("BackToList").''; $paymentstatic=new Paiement($db); $accountlinestatic=new AccountLine($db); $accountstatic=new Account($db); - $accountstatic->id=$remisecheque->account_id; - $accountstatic->label=$remisecheque->account_label; + $accountstatic->id=$object->account_id; + $accountstatic->label=$object->account_label; print ''; print '"; print "\n"; @@ -484,15 +481,15 @@ else // Nb of cheques print ''; print ''; print ''; print '
'.$langs->trans('Ref').''; - print $form->showrefnav($remisecheque,'ref',$linkback, 1, 'number'); + print $form->showrefnav($object,'ref',$linkback, 1, 'number'); print "
'.$langs->trans('NbOfCheques').''; - print $remisecheque->nbcheque; + print $object->nbcheque; print '
'.$langs->trans('Total').''; - print price($remisecheque->amount); + print price($object->amount); print '
'.$langs->trans('Status').''; - print $remisecheque->getLibStatut(4); + print $object->getLibStatut(4); print '

'; @@ -501,14 +498,14 @@ else // Liste des cheques $sql = "SELECT b.rowid, b.amount, b.num_chq, b.emetteur,"; $sql.= " b.dateo as date, b.datec as datec, b.banque,"; - $sql.= " p.rowid as pid"; + $sql.= " p.rowid as pid, ba.rowid as bid"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."bank as b"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql.= " WHERE ba.rowid = b.fk_account"; $sql.= " AND ba.entity = ".$conf->entity; $sql.= " AND b.fk_type= 'CHQ'"; - $sql.= " AND b.fk_bordereau = ".$remisecheque->id; + $sql.= " AND b.fk_bordereau = ".$object->id; $sql.= " ORDER BY $sortfield $sortorder"; dol_syslog("sql=".$sql); @@ -519,7 +516,7 @@ else print ''; - $param="&id=".$remisecheque->id; + $param="&id=".$object->id; print ''; print_liste_field_titre($langs->trans("Cheque"),'','','','','width="30"'); print_liste_field_titre($langs->trans("DateChequeReceived"),$_SERVER["PHP_SELF"],"b.dateo,b.rowid", "",$param,'align="center"',$sortfield,$sortorder); @@ -532,9 +529,11 @@ else print "\n"; $i=1; $var=false; - while ( $objp = $db->fetch_object($resql) ) + while ($objp = $db->fetch_object($resql)) { $account_id = $objp->bid; + if (! isset($accounts[$objp->bid])) + $accounts[$objp->bid]=0; $accounts[$objp->bid] += 1; print ""; @@ -555,9 +554,9 @@ else print ' '; } print ''; - if($remisecheque->statut == 0) + if ($object->statut == 0) { - print ''; + print ''; } else { @@ -591,14 +590,14 @@ if ($user->societe_id == 0 && count($accounts) == 1 && $action == 'new' && $user print ''.$langs->trans('NewCheckReceipt').''; } -if ($user->societe_id == 0 && $remisecheque->statut == 0 && $remisecheque->id && $user->rights->banque->cheque) +if ($user->societe_id == 0 && ! empty($object->id) && $object->statut == 0 && $user->rights->banque->cheque) { - print ''.$langs->trans('Valid').''; + print ''.$langs->trans('Valid').''; } -if ($user->societe_id == 0 && $remisecheque->id && $user->rights->banque->cheque) +if ($user->societe_id == 0 && ! empty($object->id) && $user->rights->banque->cheque) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } print ''; @@ -607,10 +606,10 @@ print ''; if ($action != 'new') { - if ($remisecheque->statut == 1) + if ($object->statut == 1) { - $dirchequereceipts = $dir.get_exdir($remisecheque->number,2,1).$remisecheque->ref; - $formfile->show_documents("remisecheque",$remisecheque->ref,$dirchequereceipts,$_SERVER["PHP_SELF"].'?id='.$remisecheque->id,1,1); + $dirchequereceipts = $dir.get_exdir($object->number,2,1).$object->ref; + $formfile->show_documents("remisecheque",$object->ref,$dirchequereceipts,$_SERVER["PHP_SELF"].'?id='.$object->id,1,1); print '
'; } } diff --git a/htdocs/compta/paiement/cheque/liste.php b/htdocs/compta/paiement/cheque/liste.php index 4ccdef894d3..36b3fd860bd 100644 --- a/htdocs/compta/paiement/cheque/liste.php +++ b/htdocs/compta/paiement/cheque/liste.php @@ -1,7 +1,7 @@ - * Copyright (C) 2007-2009 Laurent Destailleur - * Copyright (C) 2009 Regis Houssin +/* Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007-2009 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin * * 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 @@ -61,9 +61,9 @@ $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE bc.fk_bank_account = ba.rowid"; $sql.= " AND bc.entity = ".$conf->entity; -if ($_GET["search_montant"]) +if (GETPOST('search_montant')) { - $sql.=" AND bc.amount=".price2num($_GET["search_montant"]); + $sql.=" AND bc.amount=".price2num(GETPOST('search_montant')); } $sql.= " ORDER BY $sortfield $sortorder"; $sql.= $db->plimit($limit+1, $offset); @@ -75,18 +75,19 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; + $params=''; - print_barre_liste($langs->trans("MenuChequeDeposits"), $page, "liste.php",$paramlist,$sortfield,$sortorder,'',$num); + print_barre_liste($langs->trans("MenuChequeDeposits"), $page, 'liste.php', $params, $sortfield, $sortorder, '', $num); print '
'; print '
rowid.'">'.img_delete().'rowid.'">'.img_delete().'
'; print ''; - print_liste_field_titre($langs->trans("Ref"),"liste.php","bc.number","",$paramlist,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),"liste.php","dp","",$paramlist,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Account"),"liste.php","ba.label","",$paramlist,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("NbOfCheques"),"liste.php","bc.nbcheque","",$paramlist,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"),"liste.php","bc.amount","",$paramlist,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),"liste.php","bc.statut","",$paramlist,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"),"liste.php","bc.number","",$params,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),"liste.php","dp","",$params,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Account"),"liste.php","ba.label","",$params,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("NbOfCheques"),"liste.php","bc.nbcheque","",$params,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Amount"),"liste.php","bc.amount","",$params,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),"liste.php","bc.statut","",$params,'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre @@ -96,7 +97,7 @@ if ($resql) print ''; print ''; print ''; print '
  '; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php index c543d83979b..7fd66e94a76 100644 --- a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php @@ -111,8 +111,6 @@ class BordereauChequeBlochet extends ModeleChequeReceipts } } - $month = sprintf("%02d",$month); - $year = sprintf("%04d",$year); $_file = $dir . "/bordereau-".$number.".pdf"; // Create PDF instance