card.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
  6. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  7. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  8. * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
  9. * Copyright (C) 2013 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  10. * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
  11. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 3 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. */
  26. /**
  27. * \file htdocs/comm/card.php
  28. * \ingroup commercial compta
  29. * \brief Page to show customer card of a third party
  30. */
  31. require '../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  37. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  38. if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  39. if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
  40. if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
  41. if (! empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
  42. if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  43. if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  44. if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
  45. $langs->load("companies");
  46. $langs->load('banks');
  47. if (! empty($conf->contrat->enabled)) $langs->load("contracts");
  48. if (! empty($conf->commande->enabled)) $langs->load("orders");
  49. if (! empty($conf->expedition->enabled)) $langs->load("sendings");
  50. if (! empty($conf->facture->enabled)) $langs->load("bills");
  51. if (! empty($conf->projet->enabled)) $langs->load("projects");
  52. if (! empty($conf->ficheinter->enabled)) $langs->load("interventions");
  53. if (! empty($conf->notification->enabled)) $langs->load("mails");
  54. // Security check
  55. $id = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
  56. if ($user->societe_id > 0) $id=$user->societe_id;
  57. $result = restrictedArea($user,'societe',$id,'&societe');
  58. $action = GETPOST('action');
  59. $mode = GETPOST("mode");
  60. $modesearch = GETPOST("mode_search");
  61. $sortfield = GETPOST("sortfield",'alpha');
  62. $sortorder = GETPOST("sortorder",'alpha');
  63. $page = GETPOST("page",'int');
  64. if ($page == -1) { $page = 0; }
  65. $offset = $conf->liste_limit * $page;
  66. $pageprev = $page - 1;
  67. $pagenext = $page + 1;
  68. if (! $sortorder) $sortorder="ASC";
  69. if (! $sortfield) $sortfield="nom";
  70. $cancelbutton = GETPOST('cancel');
  71. $object = new Client($db);
  72. $extrafields = new ExtraFields($db);
  73. // fetch optionals attributes and labels
  74. $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
  75. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  76. $hookmanager->initHooks(array('commcard','globalcard'));
  77. /*
  78. * Actions
  79. */
  80. $parameters = array('socid' => $id);
  81. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
  82. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  83. if (empty($reshook))
  84. {
  85. if ($cancelbutton)
  86. {
  87. $action="";
  88. }
  89. // set accountancy code
  90. if ($action == 'setcustomeraccountancycode')
  91. {
  92. $result=$object->fetch($id);
  93. $object->code_compta=$_POST["customeraccountancycode"];
  94. $result=$object->update($object->id,$user,1,1,0);
  95. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  96. }
  97. // conditions de reglement
  98. if ($action == 'setconditions' && $user->rights->societe->creer)
  99. {
  100. $object->fetch($id);
  101. $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
  102. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  103. }
  104. // mode de reglement
  105. if ($action == 'setmode' && $user->rights->societe->creer)
  106. {
  107. $object->fetch($id);
  108. $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
  109. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  110. }
  111. // Bank account
  112. if ($action == 'setbankaccount' && $user->rights->societe->creer)
  113. {
  114. $object->fetch($id);
  115. $result=$object->setBankAccount(GETPOST('fk_account','int'));
  116. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  117. }
  118. // customer preferred shipping method
  119. if ($action == 'setshippingmethod' && $user->rights->societe->creer)
  120. {
  121. $object->fetch($id);
  122. $result = $object->setShippingMethod(GETPOST('shipping_method_id','int'));
  123. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  124. }
  125. // assujetissement a la TVA
  126. if ($action == 'setassujtva' && $user->rights->societe->creer)
  127. {
  128. $object->fetch($id);
  129. $object->tva_assuj=$_POST['assujtva_value'];
  130. $result=$object->update($object->id);
  131. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  132. }
  133. // set prospect level
  134. if ($action == 'setprospectlevel' && $user->rights->societe->creer)
  135. {
  136. $object->fetch($id);
  137. $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha');
  138. $result=$object->update($object->id, $user);
  139. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  140. }
  141. // set communication status
  142. if ($action == 'setstcomm')
  143. {
  144. $object->fetch($id);
  145. $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm');
  146. $result=$object->update($object->id, $user);
  147. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  148. }
  149. // update outstandng limit
  150. if ($action == 'setoutstanding_limit')
  151. {
  152. $object->fetch($id);
  153. $object->outstanding_limit=GETPOST('outstanding_limit');
  154. $result=$object->update($object->id, $user);
  155. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  156. }
  157. }
  158. /*
  159. * View
  160. */
  161. $contactstatic = new Contact($db);
  162. $userstatic=new User($db);
  163. $form = new Form($db);
  164. $formcompany=new FormCompany($db);
  165. if ($id > 0 && empty($object->id))
  166. {
  167. // Load data of third party
  168. $res=$object->fetch($id);
  169. if ($object->id <= 0) dol_print_error($db,$object->error);
  170. }
  171. $title=$langs->trans("CustomerCard");
  172. if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name;
  173. $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
  174. llxHeader('',$title,$help_url);
  175. /*
  176. if ($mode == 'search')
  177. {
  178. if ($modesearch == 'soc')
  179. {
  180. // TODO move to DAO class
  181. $sql = "SELECT s.rowid";
  182. if (!$user->rights->societe->client->voir && !$id) $sql .= ", sc.fk_soc, sc.fk_user ";
  183. $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
  184. if (!$user->rights->societe->client->voir && !$id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  185. $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'";
  186. if (!$user->rights->societe->client->voir && !$id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  187. }
  188. $resql=$db->query($sql);
  189. if ($resql)
  190. {
  191. if ( $db->num_rows($resql) == 1)
  192. {
  193. $obj = $db->fetch_object($resql);
  194. $id = $obj->rowid;
  195. }
  196. $db->free($resql);
  197. }
  198. }
  199. */
  200. if ($id > 0)
  201. {
  202. $head = societe_prepare_head($object);
  203. dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"),0,'company');
  204. dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
  205. print '<div class="fichecenter"><div class="fichehalfleft">';
  206. print '<div class="underbanner clearboth"></div>';
  207. print '<table class="border" width="100%">';
  208. // Prospect/Customer
  209. print '<tr><td width="30%">'.$langs->trans('ProspectCustomer').'</td><td width="70%" colspan="3">';
  210. print $object->getLibCustProspStatut();
  211. print '</td></tr>';
  212. // Prefix
  213. if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
  214. {
  215. print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
  216. print ($object->prefix_comm?$object->prefix_comm:'&nbsp;');
  217. print '</td></tr>';
  218. }
  219. if ($object->client)
  220. {
  221. $langs->load("compta");
  222. print '<tr><td>';
  223. print $langs->trans('CustomerCode').'</td><td colspan="3">';
  224. print $object->code_client;
  225. if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
  226. print '</td></tr>';
  227. print '<tr>';
  228. print '<td>';
  229. print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
  230. print '</td><td colspan="3">';
  231. print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
  232. print '</td>';
  233. print '</tr>';
  234. }
  235. // Skype
  236. if (! empty($conf->skype->enabled))
  237. {
  238. print '<td>'.$langs->trans('Skype').'</td><td colspan="3">'.dol_print_skype($object->skype,0,$object->id,'AC_SKYPE').'</td></tr>';
  239. }
  240. // Assujeti a TVA ou pas
  241. print '<tr>';
  242. print '<td class="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
  243. print yn($object->tva_assuj);
  244. print '</td>';
  245. print '</tr>';
  246. // Local Taxes
  247. if ($mysoc->useLocalTax(1))
  248. {
  249. print '<tr><td class="nowrap">'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
  250. print yn($object->localtax1_assuj);
  251. print '</td></tr>';
  252. }
  253. if ($mysoc->useLocalTax(2))
  254. {
  255. print '<tr><td class="nowrap">'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
  256. print yn($object->localtax2_assuj);
  257. print '</td></tr>';
  258. }
  259. // TVA Intra
  260. print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td colspan="3">';
  261. print $object->tva_intra;
  262. print '</td></tr>';
  263. // Conditions de reglement par defaut
  264. $langs->load('bills');
  265. print '<tr><td>';
  266. print '<table width="100%" class="nobordernopadding"><tr><td>';
  267. print $langs->trans('PaymentConditions');
  268. print '<td>';
  269. if (($action != 'editconditions') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
  270. print '</tr></table>';
  271. print '</td><td colspan="3">';
  272. if ($action == 'editconditions')
  273. {
  274. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id',1);
  275. }
  276. else
  277. {
  278. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'none');
  279. }
  280. print "</td>";
  281. print '</tr>';
  282. // Mode de reglement par defaut
  283. print '<tr><td class="nowrap">';
  284. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  285. print $langs->trans('PaymentMode');
  286. print '<td>';
  287. if (($action != 'editmode') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
  288. print '</tr></table>';
  289. print '</td><td colspan="3">';
  290. if ($action == 'editmode')
  291. {
  292. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
  293. }
  294. else
  295. {
  296. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement_id,'none');
  297. }
  298. print "</td>";
  299. print '</tr>';
  300. // Compte bancaire par défaut
  301. print '<tr><td class="nowrap">';
  302. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  303. print $langs->trans('BankAccount');
  304. print '<td>';
  305. if (($action != 'editbankaccount') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
  306. print '</tr></table>';
  307. print '</td><td colspan="3">';
  308. if ($action == 'editbankaccount')
  309. {
  310. $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_account,'fk_account',1);
  311. }
  312. else
  313. {
  314. $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_account,'none');
  315. }
  316. print "</td>";
  317. print '</tr>';
  318. // Relative discounts (Discounts-Drawbacks-Rebates)
  319. print '<tr><td class="nowrap">';
  320. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  321. print $langs->trans("CustomerRelativeDiscountShort");
  322. print '<td><td align="right">';
  323. if ($user->rights->societe->creer && !$user->societe_id > 0)
  324. {
  325. print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
  326. }
  327. print '</td></tr></table>';
  328. print '</td><td colspan="3">'.($object->remise_percent?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>':$langs->trans("DiscountNone")).'</td>';
  329. print '</tr>';
  330. // Absolute discounts (Discounts-Drawbacks-Rebates)
  331. print '<tr><td class="nowrap">';
  332. print '<table width="100%" class="nobordernopadding">';
  333. print '<tr><td class="nowrap">';
  334. print $langs->trans("CustomerAbsoluteDiscountShort");
  335. print '<td><td align="right">';
  336. if ($user->rights->societe->creer && !$user->societe_id > 0)
  337. {
  338. print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>';
  339. }
  340. print '</td></tr></table>';
  341. print '</td>';
  342. print '<td colspan="3">';
  343. $amount_discount=$object->getAvailableDiscounts();
  344. if ($amount_discount < 0) dol_print_error($db,$object->error);
  345. if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).'</a>';
  346. else print $langs->trans("DiscountNone");
  347. print '</td>';
  348. print '</tr>';
  349. if ($object->client)
  350. {
  351. print '<tr>';
  352. print '<td>';
  353. print $form->editfieldkey("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer);
  354. print '</td><td colspan="3">';
  355. $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount';
  356. print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : ''));
  357. if (empty($object->outstanding_limit)) print $langs->trans("NoLimit");
  358. print '</td>';
  359. print '</tr>';
  360. }
  361. // Multiprice level
  362. if (! empty($conf->global->PRODUIT_MULTIPRICES))
  363. {
  364. print '<tr><td class="nowrap">';
  365. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  366. print $langs->trans("PriceLevel");
  367. print '<td><td align="right">';
  368. if ($user->rights->societe->creer)
  369. {
  370. print '<a href="'.DOL_URL_ROOT.'/comm/multiprix.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
  371. }
  372. print '</td></tr></table>';
  373. print '</td><td colspan="3">';
  374. print $object->price_level;
  375. $keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$object->price_level;
  376. if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
  377. print "</td>";
  378. print '</tr>';
  379. }
  380. if ($object->client == 2 || $object->client == 3)
  381. {
  382. // Level of prospect
  383. print '<tr><td class="nowrap">';
  384. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  385. print $langs->trans('ProspectLevel');
  386. print '<td>';
  387. if ($action != 'editlevel' && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;socid='.$object->id.'">'.img_edit($langs->trans('Modify'),1).'</a></td>';
  388. print '</tr></table>';
  389. print '</td><td colspan="3">';
  390. if ($action == 'editlevel')
  391. $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1);
  392. else
  393. print $object->getLibProspLevel();
  394. print "</td>";
  395. print '</tr>';
  396. // Status
  397. $object->loadCacheOfProspStatus();
  398. print '<tr><td>'.$langs->trans("StatusProsp").'</td><td colspan="3">'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
  399. print ' &nbsp; &nbsp; <div class="floatright">';
  400. foreach($object->cacheprospectstatus as $key => $val)
  401. {
  402. $titlealt='default';
  403. if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
  404. if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm">'.img_action($titlealt,$val['code']).'</a>';
  405. }
  406. print '</div></td></tr>';
  407. }
  408. // Preferred shipping Method
  409. if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) {
  410. print '<tr><td class="nowrap">';
  411. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  412. print $langs->trans('SendingMethod');
  413. print '<td>';
  414. if (($action != 'editshipping') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshipping&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
  415. print '</tr></table>';
  416. print '</td><td colspan="3">';
  417. if ($action == 'editshipping')
  418. {
  419. $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->shipping_method_id,'shipping_method_id');
  420. }
  421. else
  422. {
  423. $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->shipping_method_id,'none');
  424. }
  425. print "</td>";
  426. print '</tr>';
  427. }
  428. // Categories
  429. if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
  430. $langs->load("categories");
  431. print '<tr><td>' . $langs->trans("CustomersCategoriesShort") . '</td>';
  432. print '<td colspan="3">';
  433. print $form->showCategories( $object->id, 'customer', 1 );
  434. print "</td></tr>";
  435. }
  436. // Other attributes
  437. $parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
  438. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
  439. print $hookmanager->resPrint;
  440. if (empty($reshook) && ! empty($extrafields->attribute_label))
  441. {
  442. print $object->showOptionals($extrafields);
  443. }
  444. // Sales representative
  445. include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
  446. // Module Adherent
  447. if (! empty($conf->adherent->enabled))
  448. {
  449. $langs->load("members");
  450. $langs->load("users");
  451. print '<tr><td width="25%">'.$langs->trans("LinkedToDolibarrMember").'</td>';
  452. print '<td colspan="3">';
  453. $adh=new Adherent($db);
  454. $result=$adh->fetch('','',$object->id);
  455. if ($result > 0)
  456. {
  457. $adh->ref=$adh->getFullName($langs);
  458. print $adh->getNomUrl(1);
  459. }
  460. else
  461. {
  462. print $langs->trans("ThirdpartyNotLinkedToMember");
  463. }
  464. print '</td>';
  465. print "</tr>\n";
  466. }
  467. print "</table>";
  468. print '</div><div class="fichehalfright"><div class="ficheaddleft">';
  469. // Nbre max d'elements des petites listes
  470. $MAXLIST=$conf->global->MAIN_SIZE_SHORTLISTE_LIMIT;
  471. // Lien recap
  472. $outstandingBills = $object->get_OutstandingBill();
  473. $warn = '';
  474. if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingBills)
  475. {
  476. $warn = img_warning($langs->trans("OutstandingBillReached"));
  477. }
  478. print '<table class="noborder" width="100%">';
  479. print '<tr class="liste_titre">';
  480. print '<td>'.$langs->trans("Summary").'</td>';
  481. print '<td align="right"><a href="'.DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id.'">'.$langs->trans("ShowCustomerPreview").'</a></td>';
  482. print '</tr>';
  483. print '<tr class="impair">';
  484. print '<td>'.$langs->trans("CurrentOutstandingBill").'</td>';
  485. print '<td align="right">'.price($outstandingBills).$warn.'</td>';
  486. print '</tr>';
  487. print '</table>';
  488. print '<br>';
  489. $now=dol_now();
  490. /*
  491. * Last proposals
  492. */
  493. if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
  494. {
  495. $propal_static = new Propal($db);
  496. $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht";
  497. $sql.= ", p.tva as total_tva";
  498. $sql.= ", p.total as total_ttc";
  499. $sql.= ", p.ref, p.ref_client, p.remise";
  500. $sql.= ", p.datep as dp, p.fin_validite as datelimite";
  501. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
  502. $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
  503. $sql.= " AND s.rowid = ".$object->id;
  504. $sql.= " AND p.entity = ".$conf->entity;
  505. $sql.= " ORDER BY p.datep DESC";
  506. $resql=$db->query($sql);
  507. if ($resql)
  508. {
  509. $var=true;
  510. $num = $db->num_rows($resql);
  511. if ($num > 0)
  512. {
  513. print '<table class="noborder" width="100%">';
  514. print '<tr class="liste_titre">';
  515. print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id.'">'.$langs->trans("AllPropals").' <span class="badge">'.$num.'</span></a></td>';
  516. print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
  517. print '</tr></table></td>';
  518. print '</tr>';
  519. }
  520. $i = 0;
  521. while ($i < $num && $i < $MAXLIST)
  522. {
  523. $objp = $db->fetch_object($resql);
  524. $var=!$var;
  525. print "<tr ".$bc[$var].">";
  526. print '<td class="nowrap">';
  527. $propal_static->id = $objp->propalid;
  528. $propal_static->ref = $objp->ref;
  529. $propal_static->ref_client = $objp->ref_client;
  530. $propal_static->total_ht = $objp->total_ht;
  531. $propal_static->total_tva = $objp->total_tva;
  532. $propal_static->total_ttc = $objp->total_ttc;
  533. print $propal_static->getNomUrl(1);
  534. if ( ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 ) {
  535. print " ".img_warning();
  536. }
  537. print '</td><td align="right" width="80px">'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
  538. print '<td align="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
  539. print '<td align="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut,5).'</td></tr>';
  540. $i++;
  541. }
  542. $db->free($resql);
  543. if ($num > 0) print "</table>";
  544. }
  545. else
  546. {
  547. dol_print_error($db);
  548. }
  549. }
  550. /*
  551. * Last orders
  552. */
  553. if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
  554. {
  555. $commande_static=new Commande($db);
  556. $sql = "SELECT s.nom, s.rowid";
  557. $sql.= ", c.rowid as cid, c.total_ht";
  558. $sql.= ", c.tva as total_tva";
  559. $sql.= ", c.total_ttc";
  560. $sql.= ", c.ref, c.ref_client, c.fk_statut, c.facture";
  561. $sql.= ", c.date_commande as dc";
  562. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
  563. $sql.= " WHERE c.fk_soc = s.rowid ";
  564. $sql.= " AND s.rowid = ".$object->id;
  565. $sql.= " AND c.entity = ".$conf->entity;
  566. $sql.= " ORDER BY c.date_commande DESC";
  567. $resql=$db->query($sql);
  568. if ($resql)
  569. {
  570. $var=true;
  571. $num = $db->num_rows($resql);
  572. if ($num > 0)
  573. {
  574. // Check if there are orders billable
  575. $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
  576. $sql2.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as facturee';
  577. $sql2.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
  578. $sql2.= ', '.MAIN_DB_PREFIX.'commande as c';
  579. $sql2.= ' WHERE c.fk_soc = s.rowid';
  580. $sql2.= ' AND s.rowid = '.$object->id;
  581. // Show orders with status validated, shipping started and delivered (well any order we can bill)
  582. $sql2.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
  583. $resql2=$db->query($sql2);
  584. $orders2invoice = $db->num_rows($resql2);
  585. $db->free($resql2);
  586. print '<table class="noborder" width="100%">';
  587. print '<tr class="liste_titre">';
  588. print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomerOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'">'.$langs->trans("AllOrders").' <span class="badge">'.$num.'</span></a></td>';
  589. print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
  590. //if($num2 > 0) print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').'</a></td>';
  591. //else print '<td width="20px" align="right"><a href="#">'.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'</a></td>';
  592. print '</tr></table></td>';
  593. print '</tr>';
  594. }
  595. $i = 0;
  596. while ($i < $num && $i < $MAXLIST)
  597. {
  598. $objp = $db->fetch_object($resql);
  599. $var=!$var;
  600. print "<tr ".$bc[$var].">";
  601. print '<td class="nowrap">';
  602. $commande_static->id = $objp->cid;
  603. $commande_static->ref = $objp->ref;
  604. $commande_static->ref_client=$objp->ref_client;
  605. $commande_static->total_ht = $objp->total_ht;
  606. $commande_static->total_tva = $objp->total_tva;
  607. $commande_static->total_ttc = $objp->total_ttc;
  608. print $commande_static->getNomUrl(1);
  609. print '</td><td align="right" width="80px">'.dol_print_date($db->jdate($objp->dc),'day')."</td>\n";
  610. print '<td align="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
  611. print '<td align="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut,$objp->facture,5).'</td></tr>';
  612. $i++;
  613. }
  614. $db->free($resql);
  615. if ($num >0) print "</table>";
  616. }
  617. else
  618. {
  619. dol_print_error($db);
  620. }
  621. }
  622. /*
  623. * Last sendings
  624. */
  625. if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
  626. $sendingstatic = new Expedition($db);
  627. $sql = 'SELECT e.rowid as id';
  628. $sql.= ', e.ref';
  629. $sql.= ', e.date_creation';
  630. $sql.= ', e.fk_statut as statut';
  631. $sql.= ', s.nom';
  632. $sql.= ', s.rowid as socid';
  633. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e";
  634. $sql.= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id;
  635. $sql.= " AND e.entity IN (".getEntity('expedition', 1).")";
  636. $sql.= ' GROUP BY e.rowid';
  637. $sql.= ', e.ref';
  638. $sql.= ', e.date_creation';
  639. $sql.= ', e.fk_statut';
  640. $sql.= ', s.nom';
  641. $sql.= ', s.rowid';
  642. $sql.= " ORDER BY e.date_creation DESC";
  643. $resql = $db->query($sql);
  644. if ($resql) {
  645. $var = true;
  646. $num = $db->num_rows($resql);
  647. $i = 0;
  648. if ($num > 0) {
  649. print '<table class="noborder" width="100%">';
  650. print '<tr class="liste_titre">';
  651. print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSendings",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/expedition/list.php?socid='.$object->id.'">'.$langs->trans("AllSendings").' <span class="badge">'.$num.'</span></a></td>';
  652. print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/expedition/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
  653. print '</tr></table></td>';
  654. print '</tr>';
  655. }
  656. while ($i < $num && $i < $MAXLIST) {
  657. $objp = $db->fetch_object($resql);
  658. $var = ! $var;
  659. print "<tr " . $bc[$var] . ">";
  660. print '<td class="nowrap">';
  661. $sendingstatic->id = $objp->id;
  662. $sendingstatic->ref = $objp->ref;
  663. print $sendingstatic->getNomUrl(1);
  664. print '</td>';
  665. if ($objp->date_creation > 0) {
  666. print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>';
  667. } else {
  668. print '<td align="right"><b>!!!</b></td>';
  669. }
  670. print '<td align="right" class="nowrap" width="100" >' . $sendingstatic->LibStatut($objp->statut, 5) . '</td>';
  671. print "</tr>\n";
  672. $i++;
  673. }
  674. $db->free($resql);
  675. if ($num > 0)
  676. print "</table>";
  677. } else {
  678. dol_print_error($db);
  679. }
  680. }
  681. /*
  682. * Last linked contracts
  683. */
  684. if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
  685. {
  686. $contratstatic=new Contrat($db);
  687. $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc, c.date_contrat as dcon, c.ref_supplier as refsup";
  688. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
  689. $sql.= " WHERE c.fk_soc = s.rowid ";
  690. $sql.= " AND s.rowid = ".$object->id;
  691. $sql.= " AND c.entity = ".$conf->entity;
  692. $sql.= " ORDER BY c.datec DESC";
  693. $resql=$db->query($sql);
  694. if ($resql)
  695. {
  696. $var=true;
  697. $num = $db->num_rows($resql);
  698. if ($num >0 )
  699. {
  700. print '<table class="noborder" width="100%">';
  701. print '<tr class="liste_titre">';
  702. print '<td colspan="6"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastContracts",($num<=$MAXLIST?"":$MAXLIST)).'</td>';
  703. print '<td align="right"><a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->id.'">'.$langs->trans("AllContracts").' <span class="badge">'.$num.'</span></a></td></tr></table></td>';
  704. print '</tr>';
  705. }
  706. $i = 0;
  707. while ($i < $num && $i < $MAXLIST)
  708. {
  709. $contrat=new Contrat($db);
  710. $objp = $db->fetch_object($resql);
  711. $var=!$var;
  712. print "<tr ".$bc[$var].">";
  713. print '<td class="nowrap">';
  714. $contrat->id=$objp->id;
  715. $contrat->ref=$objp->ref?$objp->ref:$objp->id;
  716. print $contrat->getNomUrl(1,12);
  717. print "</td>\n";
  718. print '<td class="nowrap">'.dol_trunc($objp->refsup,12)."</td>\n";
  719. print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->dc),'day')."</td>\n";
  720. print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->dcon),'day')."</td>\n";
  721. print '<td width="20">&nbsp;</td>';
  722. print '<td align="right" class="nowrap">';
  723. $contrat->fetch_lines();
  724. print $contrat->getLibStatut(4);
  725. print "</td>\n";
  726. print '</tr>';
  727. $i++;
  728. }
  729. $db->free($resql);
  730. if ($num > 0) print "</table>";
  731. }
  732. else
  733. {
  734. dol_print_error($db);
  735. }
  736. }
  737. /*
  738. * Last interventions
  739. */
  740. if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
  741. {
  742. $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate";
  743. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
  744. $sql.= " WHERE f.fk_soc = s.rowid";
  745. $sql.= " AND s.rowid = ".$object->id;
  746. $sql.= " AND f.entity = ".$conf->entity;
  747. $sql.= " ORDER BY f.tms DESC";
  748. $fichinter_static=new Fichinter($db);
  749. $resql=$db->query($sql);
  750. if ($resql)
  751. {
  752. $var=true;
  753. $num = $db->num_rows($resql);
  754. if ($num > 0)
  755. {
  756. print '<table class="noborder" width="100%">';
  757. print '<tr class="liste_titre">';
  758. print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$object->id.'">'.$langs->trans("AllInterventions").' <span class="badge">'.$num.'</span></td></tr></table></td>';
  759. print '</tr>';
  760. $var=!$var;
  761. }
  762. $i = 0;
  763. while ($i < $num && $i < $MAXLIST)
  764. {
  765. $objp = $db->fetch_object($resql);
  766. $fichinter_static->id=$objp->id;
  767. $fichinter_static->statut=$objp->fk_statut;
  768. print "<tr ".$bc[$var].">";
  769. print '<td class="nowrap"><a href="'.DOL_URL_ROOT.'/fichinter/card.php?id='.$objp->id.'">'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.'</a></td>'."\n";
  770. //print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
  771. print '<td align="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n";
  772. print '<td align="right" class="nowrap" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).'</td>'."\n";
  773. print '</tr>';
  774. $var=!$var;
  775. $i++;
  776. }
  777. $db->free($resql);
  778. if ($num > 0) print "</table>";
  779. }
  780. else
  781. {
  782. dol_print_error($db);
  783. }
  784. }
  785. /*
  786. * Last invoices
  787. */
  788. if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
  789. {
  790. $facturestatic = new Facture($db);
  791. $sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount';
  792. $sql.= ', f.total as total_ht';
  793. $sql.= ', f.tva as total_tva';
  794. $sql.= ', f.total_ttc';
  795. $sql.= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut';
  796. $sql.= ', s.nom, s.rowid as socid';
  797. $sql.= ', SUM(pf.amount) as am';
  798. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
  799. $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
  800. $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
  801. $sql.= " AND f.entity = ".$conf->entity;
  802. $sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.tva, f.total_ttc,';
  803. $sql.= ' f.datef, f.datec, f.paye, f.fk_statut,';
  804. $sql.= ' s.nom, s.rowid';
  805. $sql.= " ORDER BY f.datef DESC, f.datec DESC";
  806. $resql=$db->query($sql);
  807. if ($resql)
  808. {
  809. $var=true;
  810. $num = $db->num_rows($resql);
  811. $i = 0;
  812. if ($num > 0)
  813. {
  814. print '<table class="noborder" width="100%">';
  815. print '<tr class="liste_titre">';
  816. print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllBills").' <span class="badge">'.$num.'</span></a></td>';
  817. print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
  818. print '</tr></table></td>';
  819. print '</tr>';
  820. }
  821. while ($i < $num && $i < $MAXLIST)
  822. {
  823. $objp = $db->fetch_object($resql);
  824. $var=!$var;
  825. print "<tr ".$bc[$var].">";
  826. print '<td class="nowrap">';
  827. $facturestatic->id = $objp->facid;
  828. $facturestatic->ref = $objp->facnumber;
  829. $facturestatic->type = $objp->type;
  830. $facturestatic->total_ht = $objp->total_ht;
  831. $facturestatic->total_tva = $objp->total_tva;
  832. $facturestatic->total_ttc = $objp->total_ttc;
  833. print $facturestatic->getNomUrl(1);
  834. print '</td>';
  835. if ($objp->df > 0)
  836. {
  837. print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->df),'day').'</td>';
  838. }
  839. else
  840. {
  841. print '<td align="right"><b>!!!</b></td>';
  842. }
  843. print '<td align="right" style="min-width: 60px">';
  844. print price($objp->total_ht);
  845. print '</td>';
  846. if (! empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES))
  847. {
  848. print '<td align="right" style="min-width: 60px">';
  849. print price($objp->total_ttc);
  850. print '</td>';
  851. }
  852. print '<td align="right" class="nowrap" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am)).'</td>';
  853. print "</tr>\n";
  854. $i++;
  855. }
  856. $db->free($resql);
  857. if ($num > 0) print "</table>";
  858. }
  859. else
  860. {
  861. dol_print_error($db);
  862. }
  863. }
  864. print '</div></div></div>';
  865. print '<div style="clear:both"></div>';
  866. dol_fiche_end();
  867. /*
  868. * Barre d'actions
  869. */
  870. print '<div class="tabsAction">';
  871. $parameters = array();
  872. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
  873. if (empty($reshook))
  874. {
  875. if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1)
  876. {
  877. $langs->load("propal");
  878. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a></div>';
  879. }
  880. if (! empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status==1)
  881. {
  882. $langs->load("orders");
  883. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddOrder").'</a></div>';
  884. }
  885. if ($user->rights->contrat->creer && $object->status==1)
  886. {
  887. $langs->load("contracts");
  888. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddContract").'</a></div>';
  889. }
  890. if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status==1)
  891. {
  892. $langs->load("fichinter");
  893. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddIntervention").'</a></div>';
  894. }
  895. // Add invoice
  896. if ($user->societe_id == 0)
  897. {
  898. if (! empty($conf->deplacement->enabled) && $object->status==1)
  899. {
  900. $langs->load("trips");
  901. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>';
  902. }
  903. if (! empty($conf->facture->enabled))
  904. {
  905. if ($user->rights->facture->creer && $object->status==1)
  906. {
  907. $langs->load("bills");
  908. $langs->load("orders");
  909. if (! empty($conf->commande->enabled))
  910. {
  911. if (! empty($orders2invoice) && $orders2invoice > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
  912. else print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
  913. }
  914. if ($object->client != 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>';
  915. else print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
  916. }
  917. else
  918. {
  919. print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
  920. }
  921. }
  922. }
  923. // Add action
  924. if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
  925. {
  926. if ($user->rights->agenda->myactions->create)
  927. {
  928. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a></div>';
  929. }
  930. else
  931. {
  932. print '<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a></div>';
  933. }
  934. }
  935. }
  936. print '</div>';
  937. if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
  938. {
  939. // List of contacts
  940. show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
  941. }
  942. // Addresses list
  943. if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB))
  944. {
  945. show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
  946. }
  947. if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
  948. {
  949. print load_fiche_titre($langs->trans("ActionsOnCompany"),'','');
  950. // List of todo actions
  951. show_actions_todo($conf,$langs,$db,$object);
  952. // List of done actions
  953. show_actions_done($conf,$langs,$db,$object);
  954. }
  955. }
  956. else
  957. {
  958. dol_print_error($db,'Bad value for socid parameter');
  959. }
  960. // End of page
  961. llxFooter();
  962. $db->close();