PageRenderTime 185ms CodeModel.GetById 15ms RepoModel.GetById 12ms app.codeStats 0ms

/htdocs/projet/element.php

https://github.com/asterix14/dolibarr
PHP | 287 lines | 198 code | 45 blank | 44 comment | 61 complexity | 52f0ad974cfe81b251439253add7c10d MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/projet/element.php
  21. * \ingroup projet facture
  22. * \brief Page of project referrers
  23. */
  24. require("../main.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
  26. require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php");
  27. if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
  28. if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
  29. if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture-rec.class.php");
  30. if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
  31. if ($conf->fournisseur->enabled) require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php");
  32. if ($conf->fournisseur->enabled) require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php");
  33. if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
  34. if ($conf->ficheinter->enabled) require_once(DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php");
  35. if ($conf->deplacement->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/class/deplacement.class.php");
  36. if ($conf->agenda->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php");
  37. $langs->load("projects");
  38. $langs->load("companies");
  39. $langs->load("suppliers");
  40. if ($conf->facture->enabled) $langs->load("bills");
  41. if ($conf->commande->enabled) $langs->load("orders");
  42. if ($conf->propal->enabled) $langs->load("propal");
  43. $projectid='';
  44. $ref='';
  45. if (isset($_GET["id"])) { $projectid=$_GET["id"]; }
  46. if (isset($_GET["ref"])) { $ref=$_GET["ref"]; }
  47. if ($projectid == '' && $ref == '')
  48. {
  49. dol_print_error('','Bad parameter');
  50. exit;
  51. }
  52. $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
  53. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  54. // Security check
  55. $socid=0;
  56. if ($user->societe_id > 0) $socid=$user->societe_id;
  57. $result = restrictedArea($user, 'projet', $projectid);
  58. /*
  59. * View
  60. */
  61. $help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  62. llxHeader("",$langs->trans("Referers"),$help_url);
  63. $form = new Form($db);
  64. $userstatic=new User($db);
  65. $project = new Project($db);
  66. $project->fetch($_GET["id"],$_GET["ref"]);
  67. $project->societe->fetch($project->societe->id);
  68. // To verify role of users
  69. $userAccess = $project->restrictedProjectArea($user);
  70. $head=project_prepare_head($project);
  71. dol_fiche_head($head, 'element', $langs->trans("Project"),0,($project->public?'projectpub':'project'));
  72. print '<table class="border" width="100%">';
  73. print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
  74. // Define a complementary filter for search of next/prev ref.
  75. $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
  76. $project->next_prev_filter=" rowid in (".$projectsListId.")";
  77. print $form->showrefnav($project,'ref','',1,'ref','ref');
  78. print '</td></tr>';
  79. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
  80. print '<tr><td>'.$langs->trans("Company").'</td><td>';
  81. if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
  82. else print '&nbsp;';
  83. print '</td></tr>';
  84. // Visibility
  85. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  86. if ($project->public) print $langs->trans('SharedProject');
  87. else print $langs->trans('PrivateProject');
  88. print '</td></tr>';
  89. // Statut
  90. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
  91. print '</table>';
  92. print '</div>';
  93. /*
  94. * Referers types
  95. */
  96. $listofreferent=array(
  97. 'propal'=>array(
  98. 'title'=>"ListProposalsAssociatedProject",
  99. 'class'=>'Propal',
  100. 'test'=>$conf->propal->enabled),
  101. 'order'=>array(
  102. 'title'=>"ListOrdersAssociatedProject",
  103. 'class'=>'Commande',
  104. 'test'=>$conf->commande->enabled),
  105. 'invoice'=>array(
  106. 'title'=>"ListInvoicesAssociatedProject",
  107. 'class'=>'Facture',
  108. 'test'=>$conf->facture->enabled),
  109. 'invoice_predefined'=>array(
  110. 'title'=>"ListPredefinedInvoicesAssociatedProject",
  111. 'class'=>'FactureRec',
  112. 'test'=>$conf->facture->enabled),
  113. 'order_supplier'=>array(
  114. 'title'=>"ListSupplierOrdersAssociatedProject",
  115. 'class'=>'CommandeFournisseur',
  116. 'test'=>$conf->fournisseur->enabled),
  117. 'invoice_supplier'=>array(
  118. 'title'=>"ListSupplierInvoicesAssociatedProject",
  119. 'class'=>'FactureFournisseur',
  120. 'test'=>$conf->fournisseur->enabled),
  121. 'contract'=>array(
  122. 'title'=>"ListContractAssociatedProject",
  123. 'class'=>'Contrat',
  124. 'test'=>$conf->contrat->enabled),
  125. 'intervention'=>array(
  126. 'title'=>"ListFichinterAssociatedProject",
  127. 'class'=>'Fichinter',
  128. 'disableamount'=>1,
  129. 'test'=>$conf->ficheinter->enabled),
  130. 'trip'=>array(
  131. 'title'=>"ListTripAssociatedProject",
  132. 'class'=>'Deplacement',
  133. 'disableamount'=>1,
  134. 'test'=>$conf->deplacement->enabled),
  135. 'agenda'=>array(
  136. 'title'=>"ListActionsAssociatedProject",
  137. 'class'=>'ActionComm',
  138. 'disableamount'=>1,
  139. 'test'=>$conf->agenda->enabled)
  140. );
  141. foreach ($listofreferent as $key => $value)
  142. {
  143. $title=$value['title'];
  144. $classname=$value['class'];
  145. $qualified=$value['test'];
  146. if ($qualified)
  147. {
  148. print '<br>';
  149. print_titre($langs->trans($title));
  150. print '<table class="noborder" width="100%">';
  151. print '<tr class="liste_titre">';
  152. print '<td width="100">'.$langs->trans("Ref").'</td>';
  153. print '<td width="100" align="center">'.$langs->trans("Date").'</td>';
  154. print '<td>'.$langs->trans("ThirdParty").'</td>';
  155. if (empty($value['disableamount'])) print '<td align="right" width="120">'.$langs->trans("AmountHT").'</td>';
  156. if (empty($value['disableamount'])) print '<td align="right" width="120">'.$langs->trans("AmountTTC").'</td>';
  157. print '<td align="right" width="200">'.$langs->trans("Status").'</td>';
  158. print '</tr>';
  159. $elementarray = $project->get_element_list($key);
  160. if (count($elementarray)>0 && is_array($elementarray))
  161. {
  162. $var=true;
  163. $total_ht = 0;
  164. $total_ttc = 0;
  165. $num=count($elementarray);
  166. for ($i = 0; $i < $num; $i++)
  167. {
  168. $element = new $classname($db);
  169. $element->fetch($elementarray[$i]);
  170. $element->fetch_thirdparty();
  171. //print $classname;
  172. $var=!$var;
  173. print "<tr $bc[$var]>";
  174. // Ref
  175. print '<td align="left">';
  176. print $element->getNomUrl(1);
  177. print "</td>\n";
  178. // Date
  179. $date=$element->date;
  180. if (empty($date)) $date=$element->datep;
  181. if (empty($date)) $date=$element->date_contrat;
  182. print '<td align="center">'.dol_print_date($date,'day').'</td>';
  183. // Third party
  184. print '<td align="left">';
  185. if (is_object($element->client)) print $element->client->getNomUrl(1,'',48);
  186. print '</td>';
  187. // Amount
  188. if (empty($value['disableamount'])) print '<td align="right">'.(isset($element->total_ht)?price($element->total_ht):'&nbsp;').'</td>';
  189. // Amount
  190. if (empty($value['disableamount'])) print '<td align="right">'.(isset($element->total_ttc)?price($element->total_ttc):'&nbsp;').'</td>';
  191. // Status
  192. print '<td align="right">'.$element->getLibStatut(5).'</td>';
  193. print '</tr>';
  194. $total_ht = $total_ht + $element->total_ht;
  195. $total_ttc = $total_ttc + $element->total_ttc;
  196. }
  197. print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Number").': '.$i.'</td>';
  198. if (empty($value['disableamount'])) print '<td align="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_ht).'</td>';
  199. if (empty($value['disableamount'])) print '<td align="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>';
  200. print '<td>&nbsp;</td>';
  201. print '</tr>';
  202. }
  203. print "</table>";
  204. /*
  205. * Barre d'action
  206. */
  207. print '<div class="tabsAction">';
  208. if ($project->statut > 0)
  209. {
  210. if ($project->societe->prospect || $project->societe->client)
  211. {
  212. if ($key == 'propal' && $conf->propal->enabled && $user->rights->propale->creer)
  213. {
  214. print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddProp").'</a>';
  215. }
  216. if ($key == 'order' && $conf->commande->enabled && $user->rights->commande->creer)
  217. {
  218. print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddCustomerOrder").'</a>';
  219. }
  220. if ($key == 'invoice' && $conf->facture->enabled && $user->rights->facture->creer)
  221. {
  222. print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddCustomerInvoice").'</a>';
  223. }
  224. }
  225. if ($project->societe->fournisseur)
  226. {
  227. if ($key == 'order_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->commande->creer)
  228. {
  229. print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddSupplierInvoice").'</a>';
  230. }
  231. if ($key == 'invoice_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->facture->creer)
  232. {
  233. print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddSupplierOrder").'</a>';
  234. }
  235. }
  236. }
  237. print '</div>';
  238. }
  239. }
  240. $db->close();
  241. llxFooter();
  242. ?>