diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c9732bf454d..75d7e19370e 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -37,6 +37,7 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php'); @@ -3548,13 +3549,13 @@ else if ($month > 0) { if ($year > 0) - $sql.= " AND date_format(f.datef, '%Y-%m') = '$year-$month'"; + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; else $sql.= " AND date_format(f.datef, '%m') = '$month'"; } - if ($year > 0) + else if ($year > 0) { - $sql.= ' AND date_format(f.datef, \'%Y\') = '.$year; + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } if ($_POST['sf_ref']) { @@ -3567,10 +3568,8 @@ else $sql.= ' ORDER BY '; $listfield=explode(',',$sortfield); - foreach ($listfield as $key => $value) - $sql.= $listfield[$key].' '.$sortorder.','; + foreach ($listfield as $key => $value) $sql.= $listfield[$key].' '.$sortorder.','; $sql.= ' f.rowid DESC '; - $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); @@ -3671,23 +3670,9 @@ else print "\n"; // Date - if ($objp->df > 0) - { - $y = dol_print_date($db->jdate($objp->df),'%Y'); - $m = dol_print_date($db->jdate($objp->df),'%m'); - $mt = dol_print_date($db->jdate($objp->df),'%b'); - $d = dol_print_date($db->jdate($objp->df),'%d'); - print ''; - print $d; - print ' '; - print $mt.''; - print ' '; - print $y.''; - } - else - { - print '!!!'; - } + print ''; + print dol_print_date($db->jdate($objp->df),'day'); + print ''; // Date limit print ''.dol_print_date($datelimit,'day'); diff --git a/htdocs/compta/paiement/liste.php b/htdocs/compta/paiement/liste.php index 519d0a743f2..80cd3f142dd 100644 --- a/htdocs/compta/paiement/liste.php +++ b/htdocs/compta/paiement/liste.php @@ -36,18 +36,10 @@ $facid = isset($_GET["facid"])?$_GET["facid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'facture',$facid,''); - $paymentstatic=new Paiement($db); $accountstatic=new Account($db); $companystatic=new Societe($db); - -/* -* View -*/ - -llxHeader('',$langs->trans("ListPayment")); - $page=$_GET["page"]; $sortorder=$_GET["sortorder"]; $sortfield=$_GET["sortfield"]; @@ -57,7 +49,16 @@ $offset = $limit * $page ; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="p.rowid"; -$sql = "SELECT DISTINCT p.rowid,".$db->pdate("p.datep")." as dp, p.amount,"; + + + +/* +* View +*/ + +llxHeader('',$langs->trans("ListPayment")); + +$sql = "SELECT DISTINCT p.rowid, p.datep as dp, p.amount,"; $sql.= " p.statut, p.num_paiement,"; //$sql.= " c.libelle as paiement_type,"; $sql.= " c.code as paiement_code,"; @@ -84,15 +85,24 @@ if ($socid) { $sql.= " AND f.fk_soc = ".$socid; } -if ($_GET["search_montant"]) +// Search criteria +if ($_REQUEST["search_ref"]) { - $sql .=" AND p.amount=".price2num($_GET["search_montant"]); + $sql .=" AND p.rowid=".$_REQUEST["search_ref"]; +} +if ($_REQUEST["search_amount"]) +{ + $sql .=" AND p.amount=".price2num($_REQUEST["search_amount"]); +} +if ($_REQUEST["search_company"]) +{ + $sql .=" AND s.nom like '%".addslashes($_REQUEST["search_company"])."%'"; } if ($_GET["orphelins"]) // Option for debugging purpose only { - // Paiements li�s � aucune facture (pour aide au diagnostic) - $sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount,"; + // Paiements lies a aucune facture (pour aide au diagnostic) + $sql = "SELECT p.rowid, p.datep as dp, p.amount,"; $sql.= " p.statut, p.num_paiement,"; //$sql.= " c.libelle as paiement_type"; $sql.= " c.code as paiement_code,"; @@ -105,8 +115,7 @@ if ($_GET["orphelins"]) // Option for debugging purpose only $sql.= " AND s.entity = ".$conf->entity; $sql.= " AND pf.rowid IS NULL"; } -$sql.= " ORDER BY ".$sortfield." ".$sortorder; -//$sql.= ", facnumber ASC"; +$sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit( $limit+1 ,$offset); //print "$sql"; @@ -117,10 +126,15 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $paramlist=($_GET["orphelins"]?"&orphelins=1":""); + $paramlist=''; + $paramlist.=($_REQUEST["orphelins"]?"&orphelins=1":""); + $paramlist.=($_REQUEST["search_ref"]?"&search_ref=".$_REQUEST["search_ref"]:""); + $paramlist.=($_REQUEST["search_company"]?"&search_company=".$_REQUEST["search_company"]:""); + $paramlist.=($_REQUEST["search_amount"]?"&search_amount=".$_REQUEST["search_amount"]:""); + print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, "liste.php",$paramlist,$sortfield,$sortorder,'',$num); - print '
'; + print ''; print ''; print ''; print_liste_field_titre($langs->trans("RefPayment"),"liste.php","p.rowid","",$paramlist,"",$sortfield,$sortorder); @@ -136,11 +150,18 @@ if ($resql) } print "\n"; - // Lignes des champs de filtre + // Lines for filters fields print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) @@ -163,7 +184,7 @@ if ($resql) print $paymentstatic->getNomUrl(1); print ''; - print ''; + print ''; // Company print '
 '; + print ''; + print ' '; + print ''; + print ' '; - print ''; + print ''; print ''; print ''.dol_print_date($objp->dp,'day').''.dol_print_date($db->jdate($objp->dp),'day').''; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index dbc6ebcac90..7e73ab0b6c7 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -105,7 +105,7 @@ class FactureFournisseur extends Facture } /** - * \brief Creation de la facture en base + * \brief Create supplier invoice into database * \param user object utilisateur qui cree * \return int id facture si ok, < 0 si erreur */ @@ -147,7 +147,8 @@ class FactureFournisseur extends Facture $sql.= ", '".$this->db->idate($this->date)."'"; $sql.= ", '".addslashes($this->note)."'"; $sql.= ", '".addslashes($this->note_public)."'"; - $sql.= ", ".$user->id.",'".$this->db->idate($this->date_echeance)."'"; + $sql.= ", ".$user->id.","; + $sql.= $this->date_echeance!=''?"'".$this->db->idate($this->date_echeance)."'":"null"; $sql.= ")"; dol_syslog("FactureFournisseur::create sql=".$sql, LOG_DEBUG); diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index 984870f6ff1..41586da3eed 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -28,9 +28,10 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); if (!$user->rights->fournisseur->facture->lire) - accessforbidden(); +accessforbidden(); $langs->load("companies"); @@ -39,8 +40,8 @@ $socid = $_GET["socid"]; // Security check if ($user->societe_id > 0) { - $_GET["action"] = ''; - $socid = $user->societe_id; + $_GET["action"] = ''; + $socid = $user->societe_id; } $page=$_GET["page"]; @@ -55,6 +56,9 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="fac.datef"; +$month =$_GET['month']; +$year =$_GET['year']; + /* * Actions @@ -62,21 +66,21 @@ if (! $sortfield) $sortfield="fac.datef"; if ($_POST["mode"] == 'search') { - if ($_POST["mode-search"] == 'soc') - { - $sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s "; - $sql.= " WHERE s.nom like '%".addslashes(strtolower($socname))."%'"; - } - - if ( $db->query($sql) ) - { - if ( $db->num_rows() == 1) + if ($_POST["mode-search"] == 'soc') { - $obj = $db->fetch_object(); - $socid = $obj->rowid; + $sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s "; + $sql.= " WHERE s.nom like '%".addslashes(strtolower($socname))."%'"; + } + + if ( $db->query($sql) ) + { + if ( $db->num_rows() == 1) + { + $obj = $db->fetch_object(); + $socid = $obj->rowid; + } + $db->free(); } - $db->free(); - } } @@ -87,6 +91,7 @@ if ($_POST["mode"] == 'search') */ $now=gmmktime(); +$html=new Form($db); llxHeader($langs->trans("SuppliersInovices"),'','EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); @@ -100,163 +105,186 @@ $sql.= " WHERE fac.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".$socid; } if ($_GET["filtre"]) - { - $filtrearr = explode(",", $_GET["filtre"]); - foreach ($filtrearr as $fil) - { - $filt = explode(":", $fil); - $sql .= " AND " . $filt[0] . " = " . $filt[1]; - } - } +{ + $filtrearr = explode(",", $_GET["filtre"]); + foreach ($filtrearr as $fil) + { + $filt = explode(":", $fil); + $sql .= " AND " . $filt[0] . " = " . $filt[1]; + } +} if ($_REQUEST["search_ref"]) - { - $sql .= " AND fac.rowid like '%".addslashes($_REQUEST["search_ref"])."%'"; - } +{ + $sql .= " AND fac.rowid like '%".addslashes($_REQUEST["search_ref"])."%'"; +} if ($_REQUEST["search_ref_supplier"]) - { - $sql .= " AND fac.facnumber like '%".addslashes($_REQUEST["search_ref_supplier"])."%'"; - } - +{ + $sql .= " AND fac.facnumber like '%".addslashes($_REQUEST["search_ref_supplier"])."%'"; +} +if ($month > 0) +{ + if ($year > 0) + $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else + $sql.= " AND date_format(fac.datef, '%m') = '$month'"; +} +else if ($year > 0) +{ + $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; +} if ($_GET["search_libelle"]) - { - $sql .= " AND fac.libelle like '%".addslashes($_GET["search_libelle"])."%'"; - } +{ + $sql .= " AND fac.libelle like '%".addslashes($_GET["search_libelle"])."%'"; +} if ($_GET["search_societe"]) - { - $sql .= " AND s.nom like '%".addslashes($_GET["search_societe"])."%'"; - } +{ + $sql .= " AND s.nom like '%".addslashes($_GET["search_societe"])."%'"; +} if ($_GET["search_montant_ht"]) - { - $sql .= " AND fac.total_ht = '".addslashes($_GET["search_montant_ht"])."'"; - } +{ + $sql .= " AND fac.total_ht = '".addslashes($_GET["search_montant_ht"])."'"; +} if ($_GET["search_montant_ttc"]) - { - $sql .= " AND fac.total_ttc = '".addslashes($_GET["search_montant_ttc"])."'"; - } +{ + $sql .= " AND fac.total_ttc = '".addslashes($_GET["search_montant_ttc"])."'"; +} -$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit+1, $offset); +$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->plimit( $limit+1, $offset); $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - if ($socid) { - $soc = new Societe($db); - $soc->fetch($socid); - } + if ($socid) { + $soc = new Societe($db); + $soc->fetch($socid); + } - print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php","&socid=$socid",$sortfield,$sortorder,'',$num); - print ''; - print ''; - print ''; - print_liste_field_titre($langs->trans("Ref"),"index.php","fac.rowid","&socid=$socid","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("RefSupplier"),"index.php","facnumber","&socid=$socid","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),"index.php","fac.datef","&socid=$socid","",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateDue"),"index.php","fac.date_lim_reglement","&socid=$socid","",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"),"index.php","fac.libelle","&socid=$socid","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","&socid=$socid","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),"index.php","fac.total_ht","&socid=$socid","",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountTTC"),"index.php","fac.total_ttc","&socid=$socid","",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),"index.php","fk_statut,paye","&socid=$socid","",'align="center"',$sortfield,$sortorder); - print "\n"; - // Lignes des champs de filtre + $param='&socid='.$socid; + if ($month) $param.='&month='.$month; + if ($year) $param.='&year=' .$year; - print ''; - print ''; - print ''; + + print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php",$param,$sortfield,$sortorder,'',$num); + print ''; + print '
'; - print ''; - print ''; - print ''; - print '
'; + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"fac.rowid","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RefSupplier"),$_SERVER["PHP_SELF"],"facnumber","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"fac.datef","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"fac.date_lim_reglement","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"fac.libelle","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"fac.total_ht","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"fac.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye","",$param,'align="center"',$sortfield,$sortorder); + print "\n"; + + // Lignes des champs de filtre + + print ''; + print ''; + print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print "\n"; - $facturestatic=new FactureFournisseur($db); + $facturestatic=new FactureFournisseur($db); $supplierstatic=new Fournisseur($db); - $var=true; - $total=0; - $total_ttc=0; - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); - $var=!$var; + $var=true; + $total=0; + $total_ttc=0; + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); + $var=!$var; - print ""; - print '"; + print '\n"; - print '"; - print ''; - print ''; - print ''; - print '\n"; + print '"; + print ''; + print ''; + print ''; + print ''; - print ''; - $total+=$obj->total_ht; - $total_ttc+=$obj->total_ttc; + print ''; + print ''; + $total+=$obj->total_ht; + $total_ttc+=$obj->total_ttc; - // Affiche statut de la facture - print ''; + print ''; - print "\n"; - $i++; + print "\n"; + $i++; - if ($i == min($num,$limit)) - { - // Print total - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - } + if ($i == min($num,$limit)) + { + // Print total + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + } - print "
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ' '.$langs->trans('Year').': '; + $max_year = date("Y"); + $syear = $year; + //if ($syear == '') $syear = date("Y"); + $html->select_year($syear,'year',1, '', $max_year); + print '  '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print "
'; $facturestatic->id=$obj->facid; $facturestatic->ref=$obj->ref; $facturestatic->ref_supplier=$obj->facnumber; print $facturestatic->getNomUrl(1); - print "'.dol_trunc($obj->facnumber,10)."'.dol_print_date($obj->datef,'day').''.dol_print_date($obj->date_echeance,'day'); - if (($obj->paye == 0) && ($obj->fk_statut > 0) && $obj->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning"); - print ''.dol_trunc($obj->libelle,36).''; - $supplierstatic->id=$obj->socid; + print "'.dol_trunc($obj->facnumber,10)."'.dol_print_date($obj->datef,'day').''.dol_print_date($obj->date_echeance,'day'); + if (($obj->paye == 0) && ($obj->fk_statut > 0) && $obj->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning"); + print ''.dol_trunc($obj->libelle,36).''; + $supplierstatic->id=$obj->socid; $supplierstatic->nom=$obj->nom; print $supplierstatic->getNomUrl(1,'',12); //print ''.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.''; - print ''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->total_ht).''.price($obj->total_ttc).''; - // TODO le montant deja paye obj->am n'est pas definie + // Affiche statut de la facture + print ''; + // TODO le montant deja paye obj->am n'est pas definie print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$objp->am); - print '
'.$langs->trans("Total").''.price($total).''.price($total_ttc).' 
'.$langs->trans("Total").''.price($total).''.price($total_ttc).' 
\n"; - print "\n"; - $db->free($resql); + print "
\n"; + print "\n"; + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } $db->close(); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index f950f801e90..46eca94b620 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -43,6 +43,11 @@ $sortfield = isset($_GET['sortfield'])?$_GET['sortfield']:$_POST['sortfield']; $sortorder = isset($_GET['sortorder'])?$_GET['sortorder']:$_POST['sortorder']; $page=isset($_GET['page'])?$_GET['page']:$_POST['page']; +$limit = $conf->liste_limit; +$offset = $limit * $page ; +if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="p.rowid"; + // Security check $socid=0; if ($user->societe_id > 0) @@ -52,6 +57,8 @@ if ($user->societe_id > 0) } + + /* * Actions */ @@ -364,7 +371,7 @@ if (! $_GET['action'] && ! $_POST['action']) if (! $sortorder) $sortorder='DESC'; if (! $sortfield) $sortfield='p.datep'; - $sql = 'SELECT p.rowid, p.rowid as pid, '.$db->pdate('p.datep').' as dp, p.amount as pamount,'; + $sql = 'SELECT p.rowid, p.rowid as pid, p.datep as dp, p.amount as pamount,'; $sql.= ' f.rowid as facid, f.rowid as ref, f.facnumber, f.amount,'; $sql.= ' s.rowid as socid, s.nom,'; $sql.= ' c.libelle as paiement_type, p.num_paiement,'; @@ -378,13 +385,27 @@ if (! $_GET['action'] && ! $_POST['action']) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - if (!$user->rights->societe->client->voir) $sql .= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= ' WHERE 1=1'; + if (!$user->rights->societe->client->voir) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) { - $sql .= ' WHERE f.fk_soc = '.$socid; + $sql .= ' AND f.fk_soc = '.$socid; } - $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; - $sql .= $db->plimit($limit + 1 ,$offset); + // Search criteria + if ($_REQUEST["search_ref"]) + { + $sql .=" AND p.rowid=".$_REQUEST["search_ref"]; + } + if ($_REQUEST["search_amount"]) + { + $sql .=" AND p.amount=".price2num($_REQUEST["search_amount"]); + } + if ($_REQUEST["search_company"]) + { + $sql .=" AND s.nom like '%".addslashes($_REQUEST["search_company"])."%'"; + } + $sql.= $db->order($sortfield,$sortorder); + $sql.= $db->plimit($limit + 1 ,$offset); $resql = $db->query($sql); if ($resql) @@ -393,16 +414,39 @@ if (! $_GET['action'] && ! $_POST['action']) $i = 0; $var=True; - print_barre_liste($langs->trans('SupplierPayments'), $page, 'paiement.php','',$sortfield,$sortorder,'',$num); + $paramlist=''; + $paramlist.=($_REQUEST["search_ref"]?"&search_ref=".$_REQUEST["search_ref"]:""); + $paramlist.=($_REQUEST["search_company"]?"&search_company=".$_REQUEST["search_company"]:""); + $paramlist.=($_REQUEST["search_amount"]?"&search_amount=".$_REQUEST["search_amount"]:""); + + print_barre_liste($langs->trans('SupplierPayments'), $page, 'paiement.php',$paramlist,$sortfield,$sortorder,'',$num); + + print '
'; print ''; print ''; - print_liste_field_titre($langs->trans('RefPayment'),'paiement.php','rowid','','','',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Date'),'paiement.php','dp','','','align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('ThirdParty'),'paiement.php','s.nom','','','',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Type'),'paiement.php','c.libelle','','','',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Account'),'paiement.php','ba.label','','','',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Amount'),'paiement.php','f.amount','','','align="right"',$sortfield,$sortorder); - //print_liste_field_titre($langs->trans('Invoice'),'paiement.php','facnumber','','','',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('RefPayment'),'paiement.php','p.rowid','',$paramlist,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),'paiement.php','dp','',$paramlist,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('ThirdParty'),'paiement.php','s.nom','',$paramlist,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Type'),'paiement.php','c.libelle','',$paramlist,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Account'),'paiement.php','ba.label','',$paramlist,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Amount'),'paiement.php','f.amount','',$paramlist,'align="right"',$sortfield,$sortorder); + //print_liste_field_titre($langs->trans('Invoice'),'paiement.php','facnumber','',$paramlist,'',$sortfield,$sortorder); + print "\n"; + + // Lines for filters fields + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; while ($i < min($num,$limit)) @@ -415,7 +459,7 @@ if (! $_GET['action'] && ! $_POST['action']) print ''; // Date - print '\n"; + print '\n"; print '
'; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ''; + print '
'.img_object($langs->trans('ShowPayment'),'payment').' '.$objp->pid.''.dol_print_date($objp->dp,'day')."'.dol_print_date($db->jdate($objp->dp),'day')."'; if ($objp->socid) print ''.img_object($langs->trans('ShowCompany'),'company').' '.dol_trunc($objp->nom,32).''; @@ -442,6 +486,7 @@ if (! $_GET['action'] && ! $_POST['action']) $i++; } print "
"; + print "
\n"; } else { diff --git a/htdocs/lib/databases/mssql.lib.php b/htdocs/lib/databases/mssql.lib.php index 33e8ca7dcdc..d712bb30465 100644 --- a/htdocs/lib/databases/mssql.lib.php +++ b/htdocs/lib/databases/mssql.lib.php @@ -547,10 +547,10 @@ class DoliDb } /** - * \brief Formatage (par PHP) d'une date vers format texte pour insertion dans champ date. - * Fonction a utiliser pour generer les INSERT. - * \param param Date TMS a convertir - * \return date Date au format texte YYYYMMDDHHMMSS. + * \brief Convert (by PHP) a GM Timestamp date into a PHP server TZ to insert into a date field. + * Function to use to build INSERT, UPDATE or WHERE predica + * \param param Date TMS to convert + * \return string Date in a string YYYYMMDDHHMMSS */ function idate($param) { diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 608d6cfa394..c56e54cf770 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -94,13 +94,13 @@ if ($_GET["id"]) if ($month > 0) { if ($year > 0) - $sql.= " AND m.datem between '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; else $sql.= " AND date_format(m.datem, '%m') = '$month'"; } else if ($year > 0) { - $sql.= " AND m.datem between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } if (! empty($search_movment)) {