| [ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * $Id: ligne.php,v 1.20 2005/09/17 13:03:38 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/contrat/ligne.php,v $ 21 */ 22 23 /** 24 \file htdocs/contrat/ligne.php 25 \ingroup contrat 26 \brief Fiche contrat 27 \version $Revision: 1.20 $ 28 */ 29 30 require ("./pre.inc.php"); 31 require_once(DOL_DOCUMENT_ROOT."/product.class.php"); 32 if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/project.class.php"); 33 if ($conf->propal->enabled) require_once (DOL_DOCUMENT_ROOT."/propal.class.php"); 34 if ($conf->contrat->enabled) require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); 35 36 $langs->load("contracts"); 37 $langs->load("orders"); 38 $langs->load("companies"); 39 40 $user->getrights('contrat'); 41 42 if (!$user->rights->contrat->lire) 43 accessforbidden(); 44 45 46 47 /* 48 * Sécurité accés client 49 */ 50 if ($user->societe_id > 0) 51 { 52 $action = ''; 53 $socidp = $user->societe_id; 54 } 55 56 57 /* 58 * Actions 59 */ 60 if ($_POST["action"] == 'confirm_active' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer) 61 { 62 $contrat = new Contrat($db); 63 $contrat->fetch($_GET["id"]); 64 65 $result = $contrat->active_line($user, $_GET["ligne"], $_GET["date"], $_GET["dateend"]); 66 67 if ($result > 0) 68 { 69 Header("Location: fiche.php?id=".$contrat->id); 70 exit; 71 } 72 else { 73 $mesg=$contrat->error; 74 } 75 } 76 77 if ($_POST["action"] == 'confirm_close' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer) 78 { 79 $contrat = new Contrat($db); 80 $contrat->fetch($_GET["id"]); 81 82 $result = $contrat->close_line($user, $_GET["ligne"], $_GET["dateend"]); 83 84 if ($result > 0) 85 { 86 Header("Location: fiche.php?id=".$contrat->id); 87 exit; 88 } 89 else { 90 $mesg=$contrat->error; 91 } 92 } 93 94 95 96 97 llxHeader('',$langs->trans("ContractCard"),"Contrat"); 98 99 $html = new Form($db); 100 101 /* *************************************************************************** */ 102 /* */ 103 /* Mode vue et edition */ 104 /* */ 105 /* *************************************************************************** */ 106 107 $id = $_GET["id"]; 108 if ($id > 0) 109 { 110 $contrat = New Contrat($db); 111 if ( $contrat->fetch($id) > 0) 112 { 113 114 $author = new User($db); 115 $author->id = $contrat->user_author_id; 116 $author->fetch(); 117 118 /* Remplacé par fonctions des contacts de contrat 119 $commercial_signature = new User($db); 120 $commercial_signature->id = $contrat->commercial_signature_id; 121 $commercial_signature->fetch(); 122 123 $commercial_suivi = new User($db); 124 $commercial_suivi->id = $contrat->commercial_suivi_id; 125 $commercial_suivi->fetch(); 126 */ 127 $h = 0; 128 $head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; 129 $head[$h][1] = $langs->trans("ContractCard"); 130 $h++; 131 132 $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id; 133 $head[$h][1] = $langs->trans("ContractContacts"); 134 $h++; 135 136 $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id; 137 $head[$h][1] = $langs->trans("Info"); 138 $hselected = $h; 139 $h++; 140 141 $head[$h][0] = DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id."&ligne=".$_GET["ligne"]; 142 $head[$h][1] = $langs->trans($langs->trans("EditServiceLine")); 143 $hselected = $h; 144 145 dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->id); 146 147 148 /* 149 * Confirmation de la validation activation 150 */ 151 if ($_GET["action"] == 'active' && $user->rights->contrat->activer) 152 { 153 $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); 154 $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); 155 $html->form_confirm("ligne.php?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend,$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",strftime("%A %d %B %Y", $dateactstart)),"confirm_active"); 156 print '<br />'; 157 } 158 159 /* 160 * Confirmation de la validation fermeture 161 */ 162 if ($_GET["action"] == 'close' && $user->rights->contrat->activer) 163 { 164 $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); 165 $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); 166 $html->form_confirm("ligne.php?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend,$langs->trans("CloseService"),$langs->trans("ConfirmCloseService",strftime("%A %d %B %Y", $dateactstart)),"confirm_close"); 167 print '<br />'; 168 } 169 170 171 /* 172 * Contrat 173 */ 174 print '<table class="border" width="100%">'; 175 176 // Reference du contrat 177 print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'; 178 print $contrat->ref; 179 print "</td></tr>"; 180 181 // Customer 182 print "<tr><td>".$langs->trans("Customer")."</td>"; 183 print '<td colspan="3">'; 184 print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$contrat->societe->id.'">'.$contrat->societe->nom.'</a></b></td></tr>'; 185 186 // Statut contrat 187 print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'; 188 print $contrat->statuts[$contrat->statut]; 189 print "</td></tr>"; 190 191 // Date 192 print '<tr><td>'.$langs->trans("Date").'</td>'; 193 print '<td colspan="3">'.dolibarr_print_date($contrat->date_contrat,"%A %d %B %Y")."</td></tr>\n"; 194 195 // Factures associées 196 /* 197 TODO 198 */ 199 200 // Projet 201 if ($conf->projet->enabled) 202 { 203 $langs->load("projects"); 204 print '<tr><td>'; 205 print '<table width="100%" class="nobordernopadding"><tr><td>'; 206 print $langs->trans("Project"); 207 print '</td>'; 208 if ($_GET["action"] != "classer") print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classer&id='.$id.'&ligne='.$_GET["ligne"].'">'.img_edit($langs->trans("SetProject")).'</a></td>'; 209 print '</tr></table>'; 210 print '</td><td colspan="3">'; 211 if ($_GET["action"] == "classer") 212 { 213 $html->form_project($_SERVER["PHP_SELF"]."?id=$id&ligne=".$_GET["ligne"],$contrat->fk_soc,$contrat->fk_projet,"projetid"); 214 } 215 else 216 { 217 $html->form_project($_SERVER["PHP_SELF"]."?id=$id&ligne=".$_GET["ligne"],$contrat->fk_soc,$contrat->fk_projet,"none"); 218 } 219 print "</td></tr>"; 220 } 221 222 /* Fonction remplacé par les contacts de contrat 223 // Commerciaux 224 print '<tr><td width="25%">'.$langs->trans("SalesRepresentativeFollowUp").'</td><td>'.$commercial_suivi->fullname.'</td>'; 225 print '<td width="25%">'.$langs->trans("SalesRepresentativeSignature").'</td><td>'.$commercial_signature->fullname.'</td></tr>'; 226 */ 227 print "</table>"; 228 229 230 /* 231 * Lignes de contrats 232 */ 233 print '<br><table class="noborder" width="100%">'; 234 235 $sql = "SELECT cd.statut, cd.label, cd.fk_product, cd.description, cd.price_ht, cd.qty, cd.rowid, cd.tva_tx, cd.remise_percent, cd.subprice,"; 236 $sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_debut, ".$db->pdate("cd.date_ouverture")." as date_debut_reelle,"; 237 $sql.= " ".$db->pdate("cd.date_fin_validite")." as date_fin, ".$db->pdate("cd.date_cloture")." as date_fin_reelle,"; 238 $sql.= " p.ref, p.label"; 239 $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; 240 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; 241 $sql.= " WHERE cd.fk_contrat = ".$id; 242 $sql.= " AND cd.rowid = ".$_GET["ligne"]; 243 $sql.= " ORDER BY cd.rowid"; 244 245 $result = $db->query($sql); 246 if ($result) 247 { 248 $num = $db->num_rows($result); 249 $i = 0; $total = 0; 250 251 if ($num) 252 { 253 print '<tr class="liste_titre">'; 254 print '<td>'.$langs->trans("Service").'</td>'; 255 print '<td width="50" align="center">'.$langs->trans("VAT").'</td>'; 256 print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>'; 257 print '<td width="30" align="center">'.$langs->trans("Qty").'</td>'; 258 print '<td width="50" align="right">'.$langs->trans("Discount").'</td>'; 259 print '<td width="16"> </td>'; 260 print '<td width="30" align="center">'.$langs->trans("Status").'</td>'; 261 print "</tr>\n"; 262 } 263 $var=true; 264 while ($i < $num) 265 { 266 $objp = $db->fetch_object($result); 267 268 $var=!$var; 269 print "<tr $bc[$var] valign=\"top\">\n"; 270 271 // Libelle 272 if ($objp->fk_product > 0) 273 { 274 print '<td>'; 275 print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; 276 print img_object($langs->trans("ShowService"),"service").' '.$objp->ref.'</a>'; 277 print $objp->label?' - '.$objp->label:''; 278 if ($objp->description) print '<br />'.stripslashes(nl2br($objp->description)); 279 print '</td>'; 280 } 281 else 282 { 283 print "<td>".stripslashes(nl2br($objp->description))."</td>\n"; 284 } 285 286 // TVA 287 print '<td align="center">'.$objp->tva_tx.'%</td>'; 288 289 print '<td align="right">'.price($objp->subprice)."</td>\n"; 290 291 print '<td align="center">'.$objp->qty.'</td>'; 292 293 if ($objp->remise_percent > 0) 294 { 295 print '<td align="right">'.$objp->remise_percent."%</td>\n"; 296 } 297 else 298 { 299 print '<td> </td>'; 300 } 301 302 print '<td> </td>'; 303 304 // Statut 305 print '<td align="center">'.img_statut($objp->statut,$langs->trans("ServiceStatusInitial")).'</td>'; 306 307 print "</tr>\n"; 308 309 if ($objp->date_debut) $dateactstart=$objp->date_debut; 310 if ($objp->date_fin) $dateactend=$objp->date_fin; 311 312 // Dates de en service prévues et effectives 313 314 print '<tr '.$bc[$var].'>'; 315 print '<td colspan="7">'; 316 317 // Date prévues 318 print $langs->trans("DateStartPlanned").': '; 319 if ($objp->date_debut) { 320 print dolibarr_print_date($objp->date_debut); 321 // Warning si date prevu passée et pas en service 322 if ($objp->statut == 0 && $objp->date_debut < time() - $conf->contrat->warning_delay) { print " ".img_warning($langs->trans("Late")); } 323 } 324 else print $langs->trans("Unknown"); 325 print ' - '; 326 print $langs->trans("DateEndPlanned").': '; 327 if ($objp->date_fin) { 328 print dolibarr_print_date($objp->date_fin); 329 if ($objp->statut == 4 && $objp->date_fin < time() - $conf->contrat->warning_delay) { print " ".img_warning($langs->trans("Late")); } 330 } 331 else print $langs->trans("Unknown"); 332 333 print '<br>'; 334 335 // Si pas encore activé 336 if (! $objp->date_debut_reelle) { 337 print $langs->trans("DateStartReal").': '; 338 if ($objp->date_debut_reelle) print dolibarr_print_date($objp->date_debut_reelle); 339 else print $langs->trans("ContractStatusNotRunning"); 340 } 341 // Si activé et en cours 342 if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) { 343 print $langs->trans("DateStartReal").': '; 344 print dolibarr_print_date($objp->date_debut_reelle); 345 } 346 // Si désactivé 347 if ($objp->date_debut_reelle && $objp->date_fin_reelle) { 348 print $langs->trans("DateStartReal").': '; 349 print dolibarr_print_date($objp->date_debut_reelle); 350 print ' - '; 351 print $langs->trans("DateEndReal").': '; 352 print dolibarr_print_date($objp->date_fin_reelle); 353 } 354 print '</td>'; 355 print '</tr>'; 356 357 358 $i++; 359 } 360 $db->free($result); 361 } 362 else 363 { 364 dolibarr_print_error($db); 365 } 366 367 print '</table>'; 368 print '</div>'; 369 370 if ($user->rights->contrat->activer && $contrat->statut == 1 && $objp->statut <> 4) 371 { 372 /** 373 * Activer la ligne de contrat 374 */ 375 $form = new Form($db); 376 377 print '<form action="ligne.php?id='.$contrat->id.'&ligne='.$_GET["ligne"].'&action=active" method="post">'; 378 379 print '<table class="noborder" width="100%">'; 380 print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ActivateService").'</td></tr>'; 381 382 // Definie date debut et fin par defaut 383 if ($_POST["remonth"]) $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); 384 elseif (! $dateactstart) $dateactstart = time(); 385 386 if ($_POST["endmonth"]) $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); 387 elseif (! $dateactend) 388 { 389 if ($objp->fk_product > 0) 390 { 391 $product=new Product($db); 392 $product->fetch($objp->fk_product); 393 $dateactend = dolibarr_time_plus_duree (time(), $product->duration_value, $product->duration_unit); 394 } 395 } 396 397 print '<tr '.$bc[$var].'><td>'.$langs->trans("DateServiceActivate").'</td><td>'; 398 print $form->select_date($dateactstart); 399 print '</td>'; 400 401 print '<td>'.$langs->trans("DateEndPlanned").'</td><td>'; 402 print $form->select_date($dateactend,"end"); 403 print '</td>'; 404 405 print '<td align="center" rowspan="2" valign="middle"><input type="submit" class="button" value="'.$langs->trans("Activate").'"></td>'; 406 407 print '</tr>'; 408 409 print '<tr '.$bc[$var].'><td>'.$langs->trans("Comment").'</td><td colspan="3"><input size="80" type="text" name="commentaire" value="'.$_POST["commentaire"].'"></td></tr>'; 410 411 print '</table>'; 412 413 print '</form>'; 414 } 415 416 if ($user->rights->contrat->activer && $contrat->statut == 1 && $objp->statut == 4) 417 { 418 /** 419 * Désactiver la ligne de contrat 420 */ 421 $form = new Form($db); 422 423 print '<form action="ligne.php?id='.$contrat->id.'&ligne='.$_GET["ligne"].'&action=close" method="post">'; 424 425 print '<table class="noborder" width="100%">'; 426 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("CloseService").'</td></tr>'; 427 428 // Definie date debut et fin par defaut 429 if ($_POST["remonth"]) $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); 430 elseif (! $dateactstart) $dateactstart = time(); 431 432 if ($_POST["endmonth"]) $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); 433 elseif (! $dateactend) 434 { 435 if ($objp->fk_product > 0) 436 { 437 $product=new Product($db); 438 $product->fetch($objp->fk_product); 439 $dateactend = dolibarr_time_plus_duree (time(), $product->duration_value, $product->duration_unit); 440 } 441 } 442 443 print '<tr '.$bc[$var].'><td>'.$langs->trans("DateEndReal").'</td><td>'; 444 print $form->select_date($dateactend,"end"); 445 print '</td>'; 446 447 print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Close").'"></td></tr>'; 448 449 print '<tr '.$bc[$var].'><td>'.$langs->trans("Comment").'</td><td colspan="3"><input size="70" type="text" name="commentaire" value="'.$_POST["commentaire"].'"></td></tr>'; 450 print '</table>'; 451 452 print '</form>'; 453 } 454 455 } 456 else 457 { 458 // Contrat non trouvé 459 print "Contrat inexistant ou accés refusé"; 460 } 461 } 462 463 $db->close(); 464 465 llxFooter('$Date: 2005/09/17 13:03:38 $ - $Revision: 1.20 $'); 466 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
|