您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <?php
  2. $res=0;
  3. if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php';
  4. if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php';
  5. if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php';
  6. if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
  7. if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
  8. if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
  9. if (! $res) die("Include of main fails");
  10. // Change this following line to use the correct relative path from htdocs
  11. dol_include_once('/photocopies/class/phcp.class.php');
  12. dol_include_once('/photocopies/class/societe.class.php');
  13. // Load traductions files requiredby by page
  14. $langs->load("companies");
  15. $langs->load("other");
  16. // Get parameters
  17. $id = GETPOST('id','int');
  18. $action = GETPOST('action','alpha') ?: 'list';
  19. $myparam = GETPOST('myparam','alpha');
  20. $url = DOL_URL_ROOT."/photocopies/phcp.php";
  21. $phcp = null;
  22. $title = null;
  23. /*******************************************************************
  24. * ACTIONS
  25. *
  26. * Put here all code to do according to value of "action" parameter
  27. ********************************************************************/
  28. $phcp = new Phcp($db);
  29. if($id) $phcp->fetch($id);
  30. else $phcp->initAsSpecimen();
  31. //------------------------------------------------------------------------------
  32. if ($action == 'create') {
  33. $phcp->ref=$_POST["ref"];
  34. $phcp->nom=$_POST["nom"];
  35. $phcp->fk_phcp_type= $_POST["fk_phcp_type"] ?: null;
  36. $phcp->fk_societe= $_POST["fk_societe"] ?: null;
  37. if ($phcp->create($user) >= 0)
  38. $action = 'show';
  39. else
  40. $action = 'edit';
  41. }
  42. //------------------------------------------------------------------------------
  43. elseif ($action == 'update'){
  44. $phcp->ref=$_POST["ref"];
  45. $phcp->nom=$_POST["nom"];
  46. $phcp->fk_phcp_type=$_POST["fk_phcp_type"] ?: null;
  47. $phcp->fk_societe= $_POST["fk_societe"] ?: null;
  48. if ($phcp->update($user) >= 0)
  49. $action = 'show';
  50. else
  51. $action = 'edit';
  52. }
  53. //------------------------------------------------------------------------------
  54. elseif ($action == 'delete'){
  55. if ($phcp->delete($user) >= 0)
  56. $action = 'list';
  57. else
  58. $action = 'list';
  59. }
  60. switch($action){
  61. case 'new': $title = "Nouveau Photocopieur"; llxHeader('',$title,''); break;
  62. case 'edit': $title = "Modifier Photocopieur"; llxHeader('',$title,''); break;
  63. case 'list': $title = "Liste des Photocopieurs"; llxHeader('',$title,''); break;
  64. case 'show': $title = "Photocopieur : ".$phcp->nom; llxHeader('',$title,''); break;
  65. }
  66. //===============================[TEMPLATE]=====================================
  67. if($phcp && $phcp->error){
  68. ?>
  69. <script type="text/javascript">
  70. $(document).ready(function(){
  71. $.jnotify("<?= $phcp->error ?>", "error");
  72. })
  73. </script>
  74. <?php } ?>
  75. <script type="text/javascript">
  76. function deletePhcp(){
  77. return confirm("Cette action entrainera la suppression des compteurs auquels le photcopieur est associé. Êtes-vous sûr de vouloir continuer ?");
  78. }
  79. </script>
  80. <div class="fiche">
  81. <table width="100%" border="0" style="margin-bottom: 2px;" class="notopnoleftnoright" summary="">
  82. <tbody>
  83. <tr>
  84. <td width="40" valign="middle" align="left" class="nobordernopadding hideonsmartphone">
  85. <img border="0" id="pictotitle" title="" alt="" src="/dolibarr/theme/auguria/img/title.png">
  86. </td>
  87. <td valign="middle" class="nobordernopadding">
  88. <div class="titre"><?= $title ?></div>
  89. </td>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <div class="fichecenter">
  94. <!--div class="fichethirdleft"-->
  95. <?php
  96. //------------------------------------------------------------------------------
  97. if (($action == 'new') || ($action == 'edit')){
  98. ?>
  99. <form action="<?= $url."?action=".($action=='new'?'create':'update') ?>" method="POST">
  100. <?php if($id){ ?><input type="hidden" name="id" value="<?= $id ?>" /><?php } ?>
  101. <table width="100%" class="border">
  102. <tbody>
  103. <tr>
  104. <td class="fieldrequired" width="20%"><label for="phcp_ref">Ref.</label></td>
  105. <td><input type="text" id="phcp_ref" name="ref" value="<?= $phcp->ref ?>" placeholder="Reference" /></td>
  106. </tr>
  107. <tr>
  108. <td class="fieldrequired"><label for="phcp_nom">Label</label></td>
  109. <td><input name="nom" id="phcp_nom" type="text" placeholder="Label" value="<?= $phcp->nom ?>" /></td>
  110. </tr>
  111. <tr>
  112. <td class=""><label for="phcp_type">Modèle de photocopieur</label></td>
  113. <td>
  114. <select name="fk_phcp_type" id="phcp_type" placeholder="Modèle de photocopieur" <?= $action=='edit' && $phcp->fk_phcp_type ?'disabled="disabled"':'' ?>>
  115. <option value="">AUCUN</option>
  116. <?php
  117. $phcptype = new PhcpType($db);
  118. foreach($phcptype->all() as $pt){
  119. ?>
  120. <option value="<?= $pt->id ?>" <?= intval($pt->id) == intval($phcp->fk_phcp_type) ? 'selected="selected"':'' ?>><?= $pt->nom ?></option>
  121. <?php } ?>
  122. </select>
  123. </td>
  124. </tr>
  125. <tr>
  126. <td class=""><label for="societe">Chez Client</label></td>
  127. <td>
  128. <select name="fk_societe" id="societe" placeholder="Chez Client">
  129. <option value="">NON</option>
  130. <?php
  131. $societe = new CSociete($db);
  132. foreach($societe->all() as $s){
  133. ?>
  134. <option value="<?= $s->id ?>" <?= intval($s->id) == intval($phcp->fk_societe) ? 'selected="selected"':'' ?>><?= $s->nom ?></option>
  135. <?php } ?>
  136. </select>
  137. </td>
  138. </tr>
  139. </tbody>
  140. </table>
  141. <div class="tabsAction">
  142. <div class="inline-block divButAction">
  143. <input type="submit" class="butAction" value="<?= $action=='new'?'Créer':'Modifier' ?>" />
  144. </div>
  145. </div>
  146. </form>
  147. <?php
  148. }
  149. //------------------------------------------------------------------------------
  150. elseif ($action == 'show') {
  151. ?>
  152. <div class="tabBar">
  153. <table width="100%" class="border">
  154. <tbody>
  155. <tr>
  156. <td width="15%">Ref.</td>
  157. <td colspan="2"><?= $phcp->ref ?></td>
  158. </tr>
  159. <tr>
  160. <td>Label</td>
  161. <td colspan="2"><?= $phcp->nom ?></td>
  162. </tr>
  163. <tr>
  164. <td>Modèle de photocopieur</td>
  165. <td colspan="2">
  166. <?php if($phcp->phcp_type) { ?>
  167. <a href="<?= DOL_URL_ROOT.'/photocopies/phcptype.php?action=show&id='.$phcp->phcp_type->id ?>">
  168. <?= $phcp->phcp_type->ref ?> - <?= $phcp->phcp_type->nom ?>
  169. </a>
  170. <?php } else echo 'AUCUN' ?>
  171. </td>
  172. </tr>
  173. <tr>
  174. <td>Chez Client</td>
  175. <td colspan="2">
  176. <?php if($phcp->societe) { ?>
  177. <a href="<?= DOL_URL_ROOT.'/societe/soc.php?socid='.$phcp->societe->id ?>">
  178. <?= $phcp->societe->nom ?>
  179. </a>
  180. <?php } else echo 'NON' ?>
  181. </td>
  182. </tr>
  183. </tbody>
  184. </table>
  185. </div>
  186. <div class="tabsAction">
  187. <div class="inline-block divButAction">
  188. <a href="<?= $url."?id=".$phcp->id."&action=edit" ?>" class="butAction">
  189. Modifier
  190. </a>
  191. </div>
  192. <div class="inline-block divButAction">
  193. <a class="butActionDelete" id="action-delete" href="<?= $url.'?id='.$phcp->id.'&action=delete' ?>" onClick="return deletePhcp()">Supprimer</a>
  194. </div>
  195. </div>
  196. <?php
  197. }
  198. //------------------------------------------------------------------------------
  199. else { ?>
  200. <?php
  201. $sortfield = GETPOST('sortfield', 'alpha') ?: 'p.ref';
  202. $sortorder = GETPOST('sortorder', 'alpha') == 'desc' ? 'DESC' : 'ASC';
  203. ?>
  204. <table class="noborder" width="100%">
  205. <thead>
  206. <tr class="liste_titre">
  207. <?php
  208. print_liste_field_titre($langs->trans('Ref.'),$_SERVER['PHP_SELF'],'p.ref','',$param,'',$sortfield,$sortorder);
  209. print_liste_field_titre($langs->trans('Label'),$_SERVER['PHP_SELF'],'p.nom','',$param,'',$sortfield,$sortorder);
  210. print_liste_field_titre($langs->trans('Modèle de photocopieur'),$_SERVER['PHP_SELF'],'pt.nom','',$param,'',$sortfield,$sortorder);
  211. print_liste_field_titre($langs->trans('Chez Client'),$_SERVER['PHP_SELF'],'s.nom','',$param,'',$sortfield,$sortorder);
  212. ?>
  213. <th>&nbsp;</th>
  214. </tr>
  215. </thead>
  216. <tbody>
  217. <?php foreach($phcp->all($sortfield, $sortorder) as $p){ ?>
  218. <tr>
  219. <td>
  220. <a href="<?= $url.'?id='.$p->id.'&action=show' ?>">
  221. <?= $p->ref ?>
  222. </a>
  223. </td>
  224. <td>
  225. <a href="<?= $url.'?id='.$p->id.'&action=show' ?>">
  226. <?= $p->nom ?>
  227. </a>
  228. </td>
  229. <td>
  230. <?php if($p->fk_phcp_type){ ?>
  231. <a href="<?= DOL_URL_ROOT.'/photocopies/phcptype.php?id='.$p->fk_phcp_type.'&action=show' ?>">
  232. <?= $p->phcp_type->nom ?>
  233. </a>
  234. <?php } else echo 'AUCUN'; ?>
  235. </td>
  236. <td>
  237. <?php if($p->fk_societe){ ?>
  238. <a href="<?= DOL_URL_ROOT.'/societe/soc.php?socid='.$p->fk_societe ?>">
  239. <?= $p->societe->nom ?>
  240. </a>
  241. <?php } else echo 'NON'; ?>
  242. </td>
  243. <td align="right"><a href="<?= $url.'?id='.$p->id.'&action=delete' ?>" onClick="return deletePhcp()">X</a></td>
  244. </tr>
  245. <?php } ?>
  246. </tbody>
  247. </table>
  248. <?php } ?>
  249. <!--/div-->
  250. </div>
  251. </div>
  252. <?php
  253. // End of page
  254. llxFooter();
  255. $db->close();
  256. ?>