31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
43$action =
GETPOST(
'action',
'aZ09');
46if ($user->socid > 0) {
48 $socid = $user->socid;
51if (!$user->hasRight(
'facture',
'creer')) {
56$langs->loadLangs(array(
"companies",
"orders"));
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
62if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
66$offset = $limit * $page;
81llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-commande page-customer');
85$sql =
"SELECT s.rowid, s.nom as name, s.client, s.town, s.datec,";
86$sql .=
" st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta as code_compta_client";
87$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"c_stcomm as st, ".MAIN_DB_PREFIX.
"commande as c";
88$sql .=
" WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid";
89$sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
96if (
GETPOST(
"search_code_client")) {
101if (!$user->hasRight(
'societe',
'client',
'voir')) {
102 $search_sale = $user->id;
105if ($search_sale && $search_sale !=
'-1') {
106 if ($search_sale == -2) {
107 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
108 } elseif ($search_sale > 0) {
109 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
114 $sql .=
" AND c.fk_soc = ".((int) $socid);
116$sql .=
" AND c.fk_statut in (1, 2) AND c.facture = 0";
117$sql .=
" GROUP BY s.nom, s.rowid";
118$sql .= $db->order($sortfield, $sortorder);
121$nbtotalofrecords =
'';
123 $result = $db->query($sql);
124 $nbtotalofrecords = $db->num_rows($result);
126 if (($page * $limit) > $nbtotalofrecords) {
132$sql .= $db->plimit($limit + 1, $offset);
135$resql = $db->query($sql);
137 $num = $db->num_rows($resql);
140 print_barre_liste($langs->trans(
"MenuOrdersToBill"), $page, $_SERVER[
"PHP_SELF"],
"", $sortfield, $sortorder,
'', $num);
142 print
'<form method="GET" action="'.$_SERVER[
"PHP_SELF"].
'">';
144 print
'<table class="liste centpercent">';
145 print
'<tr class="liste_titre">';
147 print_liste_field_titre(
"Company", $_SERVER[
"PHP_SELF"],
"s.nom",
"",
"",
'valign="center"', $sortfield, $sortorder);
148 print_liste_field_titre(
"Town", $_SERVER[
"PHP_SELF"],
"s.town",
"",
"",
'valign="center"', $sortfield, $sortorder);
149 print_liste_field_titre(
"CustomerCode", $_SERVER[
"PHP_SELF"],
"s.code_client",
"",
"",
'align="left"', $sortfield, $sortorder);
150 print_liste_field_titre(
"AccountancyCode", $_SERVER[
"PHP_SELF"],
"s.code_compta",
"",
"",
'align="left"', $sortfield, $sortorder);
151 print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"datec",
"",
"",
'class="right"', $sortfield, $sortorder);
155 print
'<tr class="liste_titre">';
157 print
'<td align="left" class="liste_titre">';
158 print
'<input class="flat" type="text" name="search_nom" value="'.dol_escape_htmltag(
GETPOST(
"search_nom")).
'"></td>';
160 print
'<td class="liste_titre"> </td>';
162 print
'<td align="left" class="liste_titre">';
163 print
'<input class="flat" type="text" size="10" name="search_code_client" value="'.dol_escape_htmltag(
GETPOST(
"search_code_client")).
'">';
166 print
'<td align="left" class="liste_titre">';
167 print
'<input class="flat" type="text" size="10" name="search_compta" value="'.dol_escape_htmltag(
GETPOST(
"search_compta")).
'">';
170 print
'<td colspan="2" class="liste_titre right">';
171 print
'<input type="image" class="liste_titre" src="'.img_picto($langs->trans(
"Search"),
'search.png',
'', 0, 1).
'" name="button_search" value="'.
dol_escape_htmltag($langs->trans(
"Search")).
'" title="'.
dol_escape_htmltag($langs->trans(
"Search")).
'">';
176 while ($i < min($num, $limit)) {
177 $obj = $db->fetch_object($resql);
179 print
'<tr class="oddeven">';
180 print
'<td class="tdoverflowmax150">';
183 $link = $linkend =
'';
184 $link =
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$obj->rowid.
'">';
187 $result .= ($link.img_object($langs->trans(
"ShowCompany").
': '.$name,
'company').$linkend);
188 $result .= $link.$name.$linkend;
192 print
'<td>'.dolPrintLabel($obj->town).
'</td>';
193 print
'<td class="left">'.dolPrintLabel($obj->code_client).
'</td>';
194 print
'<td class="left">'.dolPrintLabel($obj->code_compta_client).
'</td>';
195 print
'<td class="right">'.dol_print_date($db->jdate($obj->datec)).
'</td>';
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.