* Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012 Andreu Bisquerra Gaya * Copyright (C) 2012 David Rodriguez Martinez * Copyright (C) 2012 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 * 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 . */ /** * \file htdocs/commande/customer.php * \ingroup compta * \brief Show list of customers to add an new invoice from orders */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $action=GETPOST('action','aZ09'); // Secrutiy check if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } if (! $user->rights->facture->creer) accessforbidden(); $langs->load("companies"); $langs->load("orders"); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="nom"; /* * View */ llxHeader(); $thirdpartystatic=new Societe($db); /* * Mode List */ $sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea"; $sql.= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta "; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid"; $sql.= " AND s.entity IN (".getEntity('societe').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (dol_strlen($stcomm)) { $sql.= " AND s.fk_stcomm=".$stcomm; } if (GETPOST("search_nom")) $sql.= natural_search("s.nom", GETPOST("search_nom")); if (GETPOST("search_compta")) $sql.= natural_search("s.code_compta", GETPOST("search_compta")); if (GETPOST("search_code_client")) $sql.= natural_search("s.code_client", GETPOST("search_code_client")); if (dol_strlen($begin)) { $sql.= " AND s.nom like '".$db->escape($begin)."'"; } if ($socid > 0) { $sql.= " AND s.rowid = ".$socid; } $sql.= " AND c.fk_statut in (1, 2) AND c.facture = 0"; $sql.= " GROUP BY s.nom"; $sql.= $db->order($sortfield,$sortorder); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } $sql.= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; print_barre_liste($langs->trans("MenuOrdersToBill"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num); print '
'; print ''; print ''; print_liste_field_titre("Company",$_SERVER["PHP_SELF"],"s.nom","","",'valign="center"',$sortfield,$sortorder); print_liste_field_titre("Town",$_SERVER["PHP_SELF"],"s.town","","",'valign="center"',$sortfield,$sortorder); print_liste_field_titre("CustomerCode",$_SERVER["PHP_SELF"],"s.code_client","","",'align="left"',$sortfield,$sortorder); print_liste_field_titre("AccountancyCode",$_SERVER["PHP_SELF"],"s.code_compta","","",'align="left"',$sortfield,$sortorder); print_liste_field_titre("DateCreation",$_SERVER["PHP_SELF"],"datec",$addu,"",'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $var=true; while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $i++; } print "
'; print ' '; print ''; print ''; print ''; print ''; print ''; print '
'; $result=''; $link=$linkend=''; $link = ''; $linkend=''; $name=$obj->name; $result.=($link.img_object($langs->trans("ShowCompany").': '.$name,'company').$linkend); $result.=$link.(dol_trunc($name,$maxlen)).$linkend; print $result; print ''.$obj->town.' '.$obj->code_client.' '.$obj->code_compta.' '.dol_print_date($db->jdate($obj->datec)).'
"; print '
'; $db->free($resql); } else { dol_print_error($db); } llxFooter(); $db->close();