PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/compta/propal.php

https://github.com/asterix14/dolibarr
PHP | 708 lines | 515 code | 111 blank | 82 comment | 108 complexity | 65933f4e2e57c46aa5d18c8ee7644ef4 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
  6. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  7. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/compta/propal.php
  24. * \ingroup propale
  25. * \brief Page liste des propales (vision compta)
  26. */
  27. require('../main.inc.php');
  28. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
  29. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
  30. require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
  31. require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
  32. if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
  33. if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php');
  34. $langs->load('companies');
  35. $langs->load('compta');
  36. $langs->load('orders');
  37. $langs->load('bills');
  38. $id=GETPOST('id');
  39. $ref=GETPOST('ref');
  40. $socid=GETPOST('socid');
  41. $action=GETPOST('action');
  42. $sortfield = GETPOST("sortfield",'alpha');
  43. $sortorder = GETPOST("sortorder",'alpha');
  44. $page = GETPOST("page",'int');
  45. if ($page == -1) { $page = 0; }
  46. $offset = $conf->liste_limit * $page;
  47. $pageprev = $page - 1;
  48. $pagenext = $page + 1;
  49. $viewstatut=$_GET['viewstatut'];
  50. $propal_statut = $_GET['propal_statut'];
  51. if($propal_statut != '')
  52. $viewstatut=$propal_statut;
  53. if (! $sortorder) $sortorder="DESC";
  54. if (! $sortfield) $sortfield="p.datep";
  55. $module='propale';
  56. if (! empty($_GET["socid"]))
  57. {
  58. $objectid=$_GET["socid"];
  59. $module='societe';
  60. $dbtable='';
  61. }
  62. else if (! empty($id))
  63. {
  64. $objectid=$id;
  65. $module='propale';
  66. $dbtable='propal';
  67. }
  68. // Security check
  69. if ($user->societe_id) $socid=$user->societe_id;
  70. $result = restrictedArea($user, $module, $objectid, $dbtable);
  71. $object = new Propal($db);
  72. /******************************************************************************/
  73. /* Actions */
  74. /******************************************************************************/
  75. if ($action == 'setstatut')
  76. {
  77. // Close proposal
  78. $object->id = $id;
  79. $object->cloture($user, $_GET["statut"], $note);
  80. }
  81. // Set project
  82. if ($action == 'classin')
  83. {
  84. $object->fetch($id);
  85. $object->setProject($_POST['projectid']);
  86. }
  87. /*
  88. * View
  89. */
  90. $now=gmmktime();
  91. llxHeader();
  92. $form = new Form($db);
  93. $htmlother = new FormOther($db);
  94. $formfile = new FormFile($db);
  95. $societestatic=new Societe($db);
  96. $propalstatic=new Propal($db);
  97. $now=gmmktime();
  98. if ($id > 0 || ! empty($ref))
  99. {
  100. if ($mesg) print "$mesg<br>";
  101. $product_static=new Product($db);
  102. $object->fetch($id,$ref);
  103. $societe = new Societe($db);
  104. $societe->fetch($object->socid);
  105. $head = propal_prepare_head($object);
  106. dol_fiche_head($head, 'compta', $langs->trans('Proposal'), 0, 'propal');
  107. /*
  108. * Proposal card
  109. */
  110. print '<table class="border" width="100%">';
  111. $linkback="<a href=\"".$_SERVER["PHP_SELF"]."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder\">".$langs->trans("BackToList")."</a>";
  112. // Ref
  113. print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="5">';
  114. print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
  115. print '</td></tr>';
  116. // Ref client
  117. print '<tr><td>';
  118. print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
  119. print $langs->trans('RefCustomer').'</td><td align="left">';
  120. print '</td>';
  121. if ($action != 'refclient' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&amp;id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
  122. print '</tr></table>';
  123. print '</td><td colspan="5">';
  124. print $object->ref_client;
  125. print '</td>';
  126. print '</tr>';
  127. $rowspan=8;
  128. // Company
  129. print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>';
  130. // Ligne info remises tiers
  131. print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
  132. if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
  133. else print $langs->trans("CompanyHasNoRelativeDiscount");
  134. $absolute_discount=$societe->getAvailableDiscounts();
  135. print '. ';
  136. if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->monnaie));
  137. else print $langs->trans("CompanyHasNoAbsoluteDiscount");
  138. print '.';
  139. print '</td></tr>';
  140. // Dates
  141. print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
  142. print dol_print_date($object->date,'daytext');
  143. print '</td>';
  144. if ($conf->projet->enabled) $rowspan++;
  145. //Local taxes
  146. if ($mysoc->pays_code=='ES')
  147. {
  148. if($mysoc->localtax1_assuj=="1") $rowspan++;
  149. if($mysoc->localtax2_assuj=="1") $rowspan++;
  150. }
  151. // Note
  152. print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('NotePublic').' :<br>'. nl2br($object->note_public).'</td>';
  153. print '</tr>';
  154. // Date fin propal
  155. print '<tr>';
  156. print '<td>'.$langs->trans('DateEndPropal').'</td><td colspan="3">';
  157. if ($object->fin_validite)
  158. {
  159. print dol_print_date($object->fin_validite,'daytext');
  160. if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
  161. }
  162. else
  163. {
  164. print $langs->trans("Unknown");
  165. }
  166. print '</td>';
  167. print '</tr>';
  168. // Payment term
  169. print '<tr><td>';
  170. print '<table class="nobordernopadding" width="100%"><tr><td>';
  171. print $langs->trans('PaymentConditionsShort');
  172. print '</td>';
  173. if ($action != 'editconditions' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
  174. print '</tr></table>';
  175. print '</td><td colspan="3">';
  176. if ($action == 'editconditions')
  177. {
  178. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
  179. }
  180. else
  181. {
  182. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none');
  183. }
  184. print '</td>';
  185. // Payment mode
  186. print '<tr>';
  187. print '<td width="25%">';
  188. print '<table class="nobordernopadding" width="100%"><tr><td>';
  189. print $langs->trans('PaymentMode');
  190. print '</td>';
  191. if ($action != 'editmode' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
  192. print '</tr></table>';
  193. print '</td><td colspan="3">';
  194. if ($action == 'editmode')
  195. {
  196. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
  197. }
  198. else
  199. {
  200. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none');
  201. }
  202. print '</td></tr>';
  203. // Project
  204. if ($conf->projet->enabled)
  205. {
  206. $langs->load("projects");
  207. print '<tr><td>';
  208. print '<table class="nobordernopadding" width="100%"><tr><td>';
  209. print $langs->trans('Project').'</td>';
  210. if (1 == 2 && $user->rights->propale->creer)
  211. {
  212. if ($action != 'classify') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
  213. print '</tr></table>';
  214. print '</td><td colspan="3">';
  215. if ($action == 'classify')
  216. {
  217. $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid');
  218. }
  219. else
  220. {
  221. $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none');
  222. }
  223. print '</td></tr>';
  224. }
  225. else
  226. {
  227. print '</td></tr></table>';
  228. if (!empty($object->fk_project))
  229. {
  230. print '<td colspan="3">';
  231. $project = new Project($db);
  232. $project->fetch($object->fk_project);
  233. print '<a href="../projet/fiche.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
  234. print $project->ref;
  235. print '</a>';
  236. print '</td>';
  237. }
  238. else
  239. {
  240. print '<td colspan="3">&nbsp;</td>';
  241. }
  242. }
  243. print '</tr>';
  244. }
  245. // Amount
  246. print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
  247. print '<td align="right" colspan="2"><b>'.price($object->total_ht).'</b></td>';
  248. print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
  249. print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2">'.price($object->total_tva).'</td>';
  250. print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
  251. // Amount Local Taxes
  252. if ($mysoc->pays_code=='ES')
  253. {
  254. if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
  255. {
  256. print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->pays_code).'</td>';
  257. print '<td align="right" colspan="2">'.price($object->total_localtax1).'</td>';
  258. print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
  259. }
  260. if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
  261. {
  262. print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->pays_code).'</td>';
  263. print '<td align="right" colspan="2">'.price($object->total_localtax2).'</td>';
  264. print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
  265. }
  266. }
  267. print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2">'.price($object->total_ttc).'</td>';
  268. print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
  269. // Statut
  270. print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$object->getLibStatut(4).'</td></tr>';
  271. print '</table><br>';
  272. /*
  273. * Lines
  274. */
  275. print '<table class="noborder" width="100%">';
  276. $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.fk_remise_except,';
  277. $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
  278. $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc,';
  279. $sql.= ' pt.product_type,';
  280. $sql.= ' p.rowid as prodid, p.label as product_label, p.ref, p.fk_product_type, ';
  281. $sql.= ' p.description as product_desc';
  282. $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
  283. $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
  284. $sql.= ' WHERE pt.fk_propal = '.$object->id;
  285. $sql.= ' ORDER BY pt.rang ASC, pt.rowid';
  286. $resql = $db->query($sql);
  287. if ($resql)
  288. {
  289. $num_lignes = $db->num_rows($resql);
  290. $i = 0;
  291. $total = 0;
  292. if ($num_lignes)
  293. {
  294. print '<tr class="liste_titre">';
  295. print '<td>'.$langs->trans('Description').'</td>';
  296. print '<td align="right" width="50">'.$langs->trans('VAT').'</td>';
  297. print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
  298. print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
  299. print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>';
  300. print '<td align="right" nowrap="nowrap">'.$langs->trans('AmountHT').'</td>';
  301. print '<td width="16">&nbsp;</td>';
  302. print '<td width="16">&nbsp;</td>';
  303. print '<td width="16">&nbsp;</td>';
  304. print "</tr>\n";
  305. }
  306. $var=true;
  307. while ($i < $num_lignes)
  308. {
  309. $objp = $db->fetch_object($resql);
  310. $var=!$var;
  311. // Show product and description
  312. $type=$objp->product_type?$objp->product_type:$objp->fk_product_type;
  313. // Try to enhance type detection using date_start and date_end for free lines where type
  314. // was not saved.
  315. if (! empty($objp->date_start)) $type=1;
  316. if (! empty($objp->date_end)) $type=1;
  317. if ($action != 'editline' || $_GET['rowid'] != $objp->rowid)
  318. {
  319. print '<tr '.$bc[$var].'>';
  320. if ($objp->fk_product > 0)
  321. {
  322. print '<td>';
  323. print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne;
  324. // Show product and description
  325. $product_static->type=$objp->fk_product_type;
  326. $product_static->id=$objp->fk_product;
  327. $product_static->ref=$objp->ref;
  328. $product_static->libelle=$objp->product_label;
  329. $text=$product_static->getNomUrl(1);
  330. $text.= ' - '.$objp->product_label;
  331. $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
  332. print $form->textwithtooltip($text,$description,3,'','',$i);
  333. // Show range
  334. print_date_range($objp->date_start,$objp->date_end);
  335. // Add description in form
  336. if ($conf->global->PRODUIT_DESC_IN_FORM)
  337. {
  338. print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
  339. }
  340. print '</td>';
  341. }
  342. else
  343. {
  344. print '<td>';
  345. print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
  346. if (($objp->info_bits & 2) == 2)
  347. {
  348. print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->socid.'">';
  349. print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
  350. print '</a>';
  351. if ($objp->description)
  352. {
  353. if ($objp->description == '(CREDIT_NOTE)')
  354. {
  355. $discount=new DiscountAbsolute($db);
  356. $discount->fetch($objp->fk_remise_except);
  357. print ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
  358. }
  359. else
  360. {
  361. print ' - '.nl2br($objp->description);
  362. }
  363. }
  364. }
  365. else
  366. {
  367. if ($type==1) $text = img_object($langs->trans('Service'),'service');
  368. else $text = img_object($langs->trans('Product'),'product');
  369. print $text.' '.nl2br($objp->description);
  370. // Show range
  371. print_date_range($objp->date_start,$objp->date_end);
  372. }
  373. print "</td>\n";
  374. }
  375. print '<td align="right">'.vatrate($objp->tva_tx).'%</td>';
  376. print '<td align="right">'.price($objp->subprice)."</td>\n";
  377. // Qty
  378. print '<td align="right">';
  379. if (($objp->info_bits & 2) != 2)
  380. {
  381. print $objp->qty;
  382. }
  383. else print '&nbsp;';
  384. print '</td>';
  385. if ($objp->remise_percent > 0)
  386. {
  387. print '<td align="right">'.$objp->remise_percent."%</td>\n";
  388. }
  389. else
  390. {
  391. print '<td>&nbsp;</td>';
  392. }
  393. print '<td align="right">'.price($objp->total_ht)."</td>\n";
  394. print '<td colspan="3">&nbsp;</td>';
  395. print '</tr>';
  396. }
  397. $i++;
  398. }
  399. $db->free($resql);
  400. }
  401. else
  402. {
  403. dol_print_error($db);
  404. }
  405. print '</table>';
  406. print '</div>';
  407. /*
  408. * Boutons Actions
  409. */
  410. print '<div class="tabsAction">';
  411. if ($object->statut <> 4 && $user->societe_id == 0)
  412. {
  413. if ($object->statut == 2 && $user->rights->facture->creer)
  414. {
  415. print '<a class="butAction" href="facture.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("BuildBill").'</a>';
  416. }
  417. $arraypropal=$object->getInvoiceArrayList();
  418. if ($object->statut == 2 && is_array($arraypropal) && count($arraypropal) > 0)
  419. {
  420. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=setstatut&statut=4&socid='.$object->socid.'">'.$langs->trans("ClassifyBilled").'</a>';
  421. }
  422. }
  423. print "</div>";
  424. print "<br>\n";
  425. print '<table width="100%"><tr><td width="50%" valign="top">';
  426. /*
  427. * Documents generes
  428. */
  429. $filename=dol_sanitizeFileName($object->ref);
  430. $filedir=$conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref);
  431. $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
  432. $genallowed=0;
  433. $delallowed=0;
  434. $var=true;
  435. $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed);
  436. /*
  437. * Linked object block
  438. */
  439. $somethingshown=$object->showLinkedObjectBlock();
  440. print '</td><td valign="top" width="50%">';
  441. // List of actions on element
  442. include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php');
  443. $formactions=new FormActions($db);
  444. $somethingshown=$formactions->showactions($object,'propal',$socid);
  445. print '</td></tr></table>';
  446. }
  447. else
  448. {
  449. /**
  450. *
  451. * Mode List
  452. *
  453. */
  454. $now=dol_now();
  455. $limit = $conf->liste_limit;
  456. $offset = $limit * $page ;
  457. $pageprev = $page - 1;
  458. $pagenext = $page + 1;
  459. $year = $_REQUEST["year"];
  460. $month = $_REQUEST["month"];
  461. $sql = "SELECT s.nom, s.rowid as socid, s.client,";
  462. $sql.= " p.rowid as propalid, p.ref, p.fk_statut,";
  463. $sql.= " p.total_ht, p.tva, p.total,";
  464. $sql.= " p.datep as dp,";
  465. $sql.= " p.fin_validite as dfin";
  466. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
  467. $sql.= ", ".MAIN_DB_PREFIX."propal as p";
  468. if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  469. $sql.= " WHERE p.fk_soc = s.rowid";
  470. $sql.= " AND p.entity = ".$conf->entity;
  471. if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  472. if ($socid) $sql.= " AND s.rowid = ".$socid;
  473. if ($viewstatut <> '') $sql.= " AND p.fk_statut in ($viewstatut)"; // viewstatut peut etre combinaisons separe par virgules
  474. if ($month > 0)
  475. {
  476. if ($year > 0)
  477. $sql.= " AND date_format(p.datep, '%Y-%m') = '".$year."-".$month."'";
  478. else
  479. $sql.= " AND date_format(p.datep, '%m') = '".$month."'";
  480. }
  481. if ($year > 0) $sql .= " AND date_format(p.datep, '%Y') = '".$year."'";
  482. if (!empty($_GET['search_ref']))
  483. {
  484. $sql.= " AND p.ref LIKE '%".$db->escape($_GET['search_ref'])."%'";
  485. }
  486. if (!empty($_GET['search_societe']))
  487. {
  488. $sql.= " AND s.nom LIKE '%".$db->escape($_GET['search_societe'])."%'";
  489. }
  490. if (!empty($_GET['search_montant_ht']))
  491. {
  492. $sql.= " AND p.price='".$db->escape($_GET['search_montant_ht'])."'";
  493. }
  494. $sql.= " ORDER BY $sortfield $sortorder, p.rowid DESC ";
  495. $sql.= $db->plimit($limit + 1,$offset);
  496. $result = $db->query($sql);
  497. if ($result)
  498. {
  499. $num = $db->num_rows($result);
  500. print_barre_liste($langs->trans("Proposals"), $page, "propal.php","&socid=$socid&month=$month&year=$year&search_ref=$search_ref&search_societe=$search_societe&search_montant_ht=$search_montant_ht".'&amp;viewstatut='.$viewstatut,$sortfield,$sortorder,'',$num);
  501. $i = 0;
  502. $var=true;
  503. print "<table class=\"noborder\" width=\"100%\">";
  504. print '<tr class="liste_titre">';
  505. print_liste_field_titre($langs->trans("Ref"),"propal.php","p.ref","","&year=$year&viewstatut=$viewstatut",'width=20%',$sortfield,$sortorder);
  506. print_liste_field_titre($langs->trans("Company"),"propal.php","s.nom","&viewstatut=$viewstatut","",'',$sortfield,$sortorder);
  507. print_liste_field_titre($langs->trans("Date"),"propal.php","p.datep","&viewstatut=$viewstatut","",'align="right"',$sortfield,$sortorder);
  508. print_liste_field_titre($langs->trans("AmountHT"),"propal.php","p.price","&viewstatut=$viewstatut","",'align="right"',$sortfield,$sortorder);
  509. print_liste_field_titre($langs->trans("Status"),"propal.php","p.fk_statut","&viewstatut=$viewstatut","",'align="right"',$sortfield,$sortorder);
  510. print '<td class="liste_titre">&nbsp;</td>';
  511. print "</tr>\n";
  512. // Lignes des champs de filtre
  513. print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
  514. print '<tr class="liste_titre">';
  515. print '<td class="liste_titre" valign="right">';
  516. print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET['search_ref'].'">';
  517. print '</td>';
  518. print '<td class="liste_titre" align="left">';
  519. print '<input class="flat" type="text" size="40" name="search_societe" value="'.$_GET['search_societe'].'">';
  520. print '</td>';
  521. print '<td class="liste_titre" colspan="1" align="right">';
  522. print $langs->trans('Month').': <input class="flat" type="text" size="2" maxlength="2" name="month" value="'.$month.'">';
  523. print '&nbsp;'.$langs->trans('Year').': ';
  524. $syear = $year;
  525. if($syear == '')
  526. $syear = date("Y");
  527. $htmlother->select_year($syear,'year',1, 20, 5);
  528. print '</td>';
  529. print '<td class="liste_titre" align="right">';
  530. print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET['search_montant_ht'].'">';
  531. print '</td>';
  532. print '<td class="liste_titre" align="right">';
  533. $form->select_propal_statut($viewstatut);
  534. print '</td>';
  535. print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
  536. print '</td>';
  537. print "</tr>\n";
  538. print '</form>';
  539. while ($i < min($num, $limit))
  540. {
  541. $objp = $db->fetch_object($result);
  542. $var=!$var;
  543. print "<tr $bc[$var]>";
  544. print '<td nowrap="nowrap">';
  545. $propalstatic->id=$objp->propalid;
  546. $propalstatic->ref=$objp->ref;
  547. //Ref
  548. print '<table class="nobordernopadding"><tr class="nocellnopadd">';
  549. print '<td width="90" class="nobordernopadding" nowrap="nowrap">';
  550. print $propalstatic->getNomUrl(1, '', "&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder");
  551. print '</td>';
  552. print '<td width="20" class="nobordernopadding" nowrap="nowrap">';
  553. if ($objp->fk_statut == 1 && $db->jdate($objp->dfin) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
  554. print '</td>';
  555. print '<td width="16" align="right" class="nobordernopadding">';
  556. $filename=dol_sanitizeFileName($objp->ref);
  557. $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($objp->ref);
  558. $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->propalid;
  559. $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1);
  560. print '</td></tr></table>';
  561. print "</td>\n";
  562. // Societe
  563. print "<td>";
  564. $societestatic->nom=$objp->nom;
  565. $societestatic->id=$objp->socid;
  566. $societestatic->client=$objp->client;
  567. print $societestatic->getNomUrl(1,'customer',44);
  568. print "</td>";
  569. // Date
  570. print "<td align=\"right\">";
  571. $y = dol_print_date($db->jdate($objp->dp),"%Y");
  572. $m = dol_print_date($db->jdate($objp->dp),"%m");
  573. $mt = dol_print_date($db->jdate($objp->dp),"%b");
  574. $d = dol_print_date($db->jdate($objp->dp),"%d");
  575. print $d."\n";
  576. print " <a href=\"propal.php?year=$y&month=$m\">";
  577. print $mt."</a>\n";
  578. print " <a href=\"propal.php?year=$y\">";
  579. print $y."</a></td>\n";
  580. // Prix
  581. print "<td align=\"right\">".price($objp->total_ht)."</td>\n";
  582. print "<td align=\"right\">".$propalstatic->LibStatut($objp->fk_statut,5)."</td>\n";
  583. print "<td>&nbsp;</td>";
  584. print "</tr>\n";
  585. $i++;
  586. }
  587. print "</table>";
  588. $db->free($result);
  589. }
  590. else
  591. {
  592. dol_print_error($db);
  593. }
  594. }
  595. $db->close();
  596. llxFooter();
  597. ?>