| [ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> 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, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 20 * $Id: fiche.php,v 1.64 2005/10/08 18:09:53 eldy Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/action/fiche.php,v $ 22 */ 23 24 /** 25 \file htdocs/comm/action/fiche.php 26 \ingroup commercial 27 \brief Page de la fiche action commercial 28 \version $Revision: 1.64 $ 29 */ 30 31 require_once ("./pre.inc.php"); 32 require_once (DOL_DOCUMENT_ROOT."/contact.class.php"); 33 require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php"); 34 require_once (DOL_DOCUMENT_ROOT."/actioncomm.class.php"); 35 36 $langs->load("companies"); 37 $langs->load("commercial"); 38 $langs->load("other"); 39 $langs->load("bills"); 40 41 // Sécurité accés client 42 if ($user->societe_id > 0) 43 { 44 $action = ''; 45 $socidp = $user->societe_id; 46 } 47 if (isset($_GET["error"])) $error=$_GET["error"]; 48 49 50 /* 51 * Action création de l'action 52 * 53 */ 54 if ($_POST["action"] == 'add_action') 55 { 56 if ($_POST["contactid"]) 57 { 58 $contact = new Contact($db); 59 $contact->fetch($_POST["contactid"]); 60 } 61 if ($_POST["socid"]) 62 { 63 $societe = new Societe($db); 64 $societe->fetch($_POST["socid"]); 65 } 66 67 if ($_POST["actionid"]) 68 { 69 $db->begin(); 70 71 $cactioncomm = new CActionComm($db); 72 $cactioncomm->fetch($_POST["actionid"]); 73 74 // Initialisation objet actioncomm 75 $actioncomm = new ActionComm($db); 76 77 $actioncomm->type_id = $_POST["actionid"]; 78 $actioncomm->type_code = $cactioncomm->code; 79 $actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0; 80 $actioncomm->label = $_POST["label"]; 81 if (! $_POST["label"]) 82 { 83 if ($_POST["actionid"] == 5 && $contact->fullname) 84 { 85 $actioncomm->label = $langs->trans("TaskRDVWith",$contact->fullname); 86 } 87 else 88 { 89 if ($langs->trans("Action".$actioncomm->type_code) != "Action".$actioncomm->type_code) 90 { 91 $actioncomm->label = $langs->trans("Action".$actioncomm->type_code)."\n"; 92 } 93 } 94 } 95 $actioncomm->date = mktime($_POST["heurehour"], 96 $_POST["heuremin"], 97 0, 98 $_POST["acmonth"], 99 $_POST["acday"], 100 $_POST["acyear"]); 101 $actioncomm->duree=(($_POST["dureehour"] * 60) + $_POST["dureemin"]) * 60; 102 $actioncomm->percent = isset($_POST["percentage"])?$_POST["percentage"]:0; 103 $actioncomm->user = $user; 104 $actioncomm->note = $_POST["note"]; 105 if (isset($_POST["contactid"])) $actioncomm->contact = $contact; 106 if (isset($_POST["socid"])) $actioncomm->societe = $societe; 107 if ($_POST["todo_webcal"] == 'on') $actioncomm->use_webcal=1; 108 109 // On crée l'action 110 $idaction=$actioncomm->add($user); 111 112 if ($idaction > 0) 113 { 114 if (! $actioncomm->error) 115 { 116 $db->commit(); 117 Header("Location: ".$_POST["from"]); 118 exit; 119 } 120 else 121 { 122 // Si erreur 123 $db->rollback(); 124 $_GET["id"]=$idaction; 125 $error=$actioncomm->error; 126 } 127 } 128 else 129 { 130 $db->rollback(); 131 dolibarr_print_error($db); 132 } 133 } 134 else 135 { 136 dolibarr_print_error('',"Le type d'action n'a pas été choisi"); 137 } 138 139 } 140 141 /* 142 * Action suppression de l'action 143 * 144 */ 145 if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') 146 { 147 $actioncomm = new ActionComm($db); 148 $actioncomm->delete($_GET["id"]); 149 150 Header("Location: index.php"); 151 exit; 152 } 153 154 /* 155 * Action mise à jour de l'action 156 * 157 */ 158 if ($_POST["action"] == 'update') 159 { 160 if (! $_POST["cancel"]) 161 { 162 $action = new Actioncomm($db); 163 $action->fetch($_POST["id"]); 164 $action->percent = stripslashes($_POST["percent"]); 165 $action->contact->id = stripslashes($_POST["contactid"]); 166 $action->note = stripslashes($_POST["note"]); 167 $action->update(); 168 } 169 170 Header("Location: ".$_POST["from"]); 171 exit; 172 } 173 174 175 176 llxHeader(); 177 178 $html = new Form($db); 179 180 /* ************************************************************************** */ 181 /* */ 182 /* Affichage fiche en mode création */ 183 /* */ 184 /* ************************************************************************** */ 185 186 if ($_GET["action"] == 'create') 187 { 188 $caction = new CActioncomm($db); 189 190 if ($_GET["contactid"]) 191 { 192 $contact = new Contact($db); 193 $contact->fetch($_GET["contactid"]); 194 } 195 196 print '<form action="fiche.php" method="post">'; 197 print '<input type="hidden" name="from" value="'.$_SERVER["HTTP_REFERER"].'">'; 198 print '<input type="hidden" name="action" value="add_action">'; 199 200 /* 201 * Si action de type Rendez-vous 202 * 203 */ 204 if ($_GET["actionid"] == 5) 205 { 206 print_titre ($langs->trans("AddActionRendezVous")); 207 print "<br>"; 208 209 print '<input type="hidden" name="date" value="'.$db->idate(time()).'">'."\n"; 210 211 print '<table class="border" width="100%">'; 212 213 // Type d'action 214 print '<input type="hidden" name="actionid" value="5">'; 215 216 // Societe, contact 217 print '<tr><td nowrap>'.$langs->trans("ActionOnCompany").'</td><td>'; 218 if ($_GET["socid"]) 219 { 220 $societe = new Societe($db); 221 $societe->fetch($_GET["socid"]); 222 print $societe->nom_url; 223 print '<input type="hidden" name="socid" value="'.$_GET["socid"].'">'; 224 } 225 else 226 { 227 print $html->select_societes('','socid',1,1); 228 } 229 print '</td></tr>'; 230 231 // Si la societe est imposée, on propose ces contacts 232 if ($_GET["socid"]) 233 { 234 print '<tr><td>'.$langs->trans("ActionOnContact").'</td><td width="40%">'; 235 print $html->select_contacts($_GET["socid"],'','contactid',1,1); 236 print '</td></tr>'; 237 } 238 239 print '<tr><td>'.$langs->trans("Date").'</td><td>'; 240 $html->select_date('','ac'); 241 print '</td></tr>'; 242 print '<tr><td>'.$langs->trans("Hour").'</td><td>'; 243 print_heure_select("heure",8,20); 244 print '</td></tr>'; 245 print '<tr><td>'.$langs->trans("Duration").'</td><td>'; 246 print_duree_select("duree"); 247 print '</td></tr>'; 248 249 add_row_for_webcal_link(); 250 251 print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>'; 252 print '<textarea cols="60" rows="6" name="note"></textarea></td></tr>'; 253 print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>'; 254 print '</table>'; 255 } 256 257 /* 258 * Si action de type autre que rendez-vous 259 * 260 */ 261 else 262 { 263 /* 264 * Click to dial 265 * 266 */ 267 if ($conf->clicktodial->enabled) 268 { 269 $user->fetch_clicktodial(); 270 271 if ($_GET["call"] && $user->clicktodial_enabled == 1) 272 { 273 274 print '<Script language=javascript>'."\n"; 275 276 $url = CLICKTODIAL_URL ."?login=".$user->clicktodial_login."&password=".$user->clicktodial_password."&caller=".$user->clicktodial_poste ."&called=".$_GET["call"]; 277 278 print 'window.open("'.$url.'","clicktodial", "toolbar=no,location=0,directories=0,status=0,menubar=no,scrollbars=1,resizable=1,copyhistory=0,width=400,height=300,top=10,left=10");'; 279 print "\n</script>\n"; 280 } 281 } 282 283 /* 284 * 285 * 286 */ 287 288 print_titre ($langs->trans("AddAnAction")); 289 print "<br>"; 290 291 print '<table class="border" width="100%">'; 292 293 // Type d'action actifs 294 print '<tr><td>'.$langs->trans("Action").'</td><td>'; 295 if ($_GET["actionid"]) 296 { 297 print '<input type="hidden" name="actionid" value="'.$_GET["actionid"].'">'."\n"; 298 print $caction->get_nom($_GET["actionid"]); 299 } 300 else 301 { 302 $html->select_array("actionid", $caction->liste_array(1), 0); 303 } 304 print '</td></tr>'; 305 306 print '<tr><td>'.$langs->trans("Title").'</td><td><input type="text" name="label" size="30"></td></tr>'; 307 308 // Societe, contact 309 print '<tr><td nowrap>'.$langs->trans("ActionOnCompany").'</td><td>'; 310 if ($_GET["socid"]) 311 { 312 $societe = new Societe($db); 313 $societe->fetch($_GET["socid"]); 314 print img_object($langs->trans("ShowCompany"),'company').' '.$societe->nom_url; 315 print '<input type="hidden" name="socid" value="'.$_GET["socid"].'">'; 316 } 317 else 318 { 319 print $html->select_societes('','socid',1,1); 320 } 321 print '</td></tr>'; 322 323 // Si la societe est imposée, on propose ces contacts 324 if ($_GET["socid"]) 325 { 326 print '<tr><td nowrap>'.$langs->trans("ActionOnContact").'</td><td>'; 327 print $html->select_contacts($_GET["socid"],'','contactid',1,1); 328 print '</td></tr>'; 329 } 330 331 // Avancement 332 if ($_GET["afaire"] == 1) 333 { 334 print '<input type="hidden" name="percentage" value="0">'; 335 print '<input type="hidden" name="todo" value="on">'; 336 print '<tr><td width="10%">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td>'.$langs->trans("StatusActionToDo").' / 0%</td></tr>'; 337 } 338 elseif ($_GET["afaire"] == 2) 339 { 340 print '<input type="hidden" name="percentage" value="100">'; 341 print '<tr><td>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td>'.$langs->trans("StatusActionDone").' / 100%</td></tr>'; 342 } else 343 { 344 print '<tr><td>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td><input type="text" name="percentage" value="0%"></td></tr>'; 345 } 346 347 // Date 348 print '<tr><td>'.$langs->trans("Date").'</td><td>'; 349 if ($_GET["afaire"] == 1) 350 { 351 $html->select_date('','ac'); 352 print '<tr><td>'.$langs->trans("Hour").'</td><td>'; 353 print_heure_select("heure",8,20); 354 print '</td></tr>'; 355 } 356 else if ($_GET["afaire"] == 2) 357 { 358 $html->select_date('','ac'); 359 print '<tr><td>'.$langs->trans("Hour").'</td><td>'; 360 print_heure_select("heure",8,20); 361 print '</td></tr>'; 362 } 363 else 364 { 365 $html->select_date('','ac'); 366 print '<tr><td>'.$langs->trans("Hour").'</td><td>'; 367 print_heure_select("heure",8,20); 368 print '</td></tr>'; 369 } 370 print '</td></tr>'; 371 372 add_row_for_webcal_link(); 373 374 // Note 375 print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>'; 376 print '<textarea cols="60" rows="6" name="note"></textarea></td></tr>'; 377 378 print '<tr><td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"</td></tr>'; 379 380 print '</table>'; 381 382 383 } 384 print "</form>"; 385 } 386 387 /* 388 * Affichage action en mode edition ou visu 389 * 390 */ 391 if ($_GET["id"]) 392 { 393 if ($error) 394 { 395 print '<div class="error">'.$error.'</div><br>'; 396 } 397 398 $act = new ActionComm($db); 399 $act->fetch($_GET["id"]); 400 $res=$act->societe->fetch($act->societe->id); 401 $res=$act->author->fetch(); // Le paramètre est le login, hors seul l'id est chargé. 402 $res=$act->contact->fetch($act->contact->id); 403 404 /* 405 * Affichage onglets 406 */ 407 408 $h = 0; 409 410 $head[$h][0] = DOL_URL_ROOT.'/comm/action/fiche.php?id='.$_GET["id"]; 411 $head[$h][1] = $langs->trans("CardAction"); 412 $hselected=$h; 413 $h++; 414 415 $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$_GET["id"]; 416 $head[$h][1] = $langs->trans('Documents'); 417 //$hselected=$h; 418 $h++; 419 420 dolibarr_fiche_head($head, $hselected, $langs->trans("Ref")." ".$act->id); 421 422 423 // Confirmation suppression action 424 if ($_GET["action"] == 'delete') 425 { 426 $html->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAction"),$langs->trans("ConfirmDeleteAction"),"confirm_delete"); 427 print '<br>'; 428 } 429 430 if ($_GET["action"] == 'edit') 431 { 432 // Fiche action en mode edition 433 print '<form action="fiche.php" method="post">'; 434 print '<input type="hidden" name="action" value="update">'; 435 print '<input type="hidden" name="id" value="'.$_GET["id"].'">'; 436 print '<input type="hidden" name="from" value="'.$_SERVER["HTTP_REFERER"].'">'; 437 438 print '<table class="border" width="100%">'; 439 print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$act->id.'</td></tr>'; 440 print '<tr><td>'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>'; 441 print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$act->label.'</td></tr>'; 442 print '<tr><td>'.$langs->trans("Company").'</td>'; 443 print '<td><a href="../fiche.php?socid='.$act->societe->id.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$act->societe->nom.'</a></td>'; 444 445 print '<td>'.$langs->trans("Contact").'</td><td width="30%">'; 446 $html->select_array("contactid", $act->societe->contact_array(), $act->contact->id, 1); 447 print '</td></tr>'; 448 449 // Auteur 450 print '<tr><td>'.$langs->trans("Author").'</td>'; 451 print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$act->author->id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$act->author->fullname.'</a></td></tr>'; 452 453 // Date 454 print '<tr><td>'.$langs->trans("Date").'</td><td colspan="3">'.dolibarr_print_date($act->date,'%d %B %Y %H:%M').'</td></tr>'; 455 456 print '<tr><td nowrap>'.$langs->trans("PercentDone").'</td><td colspan="3"><input name="percent" value="'.$act->percent.'" size="4">%</td></tr>'; 457 if ($act->objet_url) 458 { 459 print '<tr><td>'.$langs->trans("LinkedObject").'</td>'; 460 print '<td colspan="3">'.$act->objet_url.'</td></tr>'; 461 } 462 463 // Note 464 print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">'; 465 print '<textarea cols="60" rows="6" name="note">'.$act->note.'</textarea></td></tr>'; 466 467 print '<tr><td align="center" colspan="4"><input type="submit" class="button" name="edit" value="'.$langs->trans("Save").'">'; 468 print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; 469 print '</td></tr>'; 470 471 print '</table></form>'; 472 } 473 else 474 { 475 // Affichage fiche action en mode visu 476 print '<table class="border" width="100%"'; 477 print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$act->id.'</td></tr>'; 478 print '<tr><td>'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>'; 479 print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$act->label.'</td></tr>'; 480 print '<tr><td>'.$langs->trans("Company").'</td>'; 481 print '<td>'.img_object($langs->trans("ShowCompany"),'company').' '.$act->societe->nom_url.'</td>'; 482 483 print '<td>'.$langs->trans("Contact").'</td>'; 484 print '<td>'; 485 if ($act->contact->id) print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$act->contact->id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.$act->contact->fullname.'</a>'; 486 else print $langs->trans("None"); 487 print '</td></tr>'; 488 489 // Auteur 490 print '<tr><td>'.$langs->trans("Author").'</td>'; 491 print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$act->author->id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$act->author->fullname.'</a></td></tr>'; 492 493 // Date 494 print '<tr><td>'.$langs->trans("Date").'</td><td colspan="3">'.dolibarr_print_date($act->date,'%d %B %Y %H:%M').'</td></tr>'; 495 496 print '<tr><td nowrap>'.$langs->trans("PercentDone").'</td><td colspan="3">'.$act->percent.' %</td></tr>'; 497 if ($act->objet_url) 498 { 499 print '<tr><td>'.$langs->trans("LinkedObject").'</td>'; 500 print '<td colspan="3">'.$act->objet_url.'</td></tr>'; 501 } 502 503 // Note 504 print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">'; 505 print nl2br($act->note).'</td></tr>'; 506 507 print '</table>'; 508 } 509 510 print "</div>\n"; 511 512 513 /** 514 * Barre d'actions 515 * 516 */ 517 518 print '<div class="tabsAction">'; 519 520 if ($_GET["action"] != 'edit') 521 { 522 print '<a class="butAction" href="fiche.php?action=edit&id='.$act->id.'">'.$langs->trans("Edit").'</a>'; 523 524 print '<a class="butActionDelete" href="fiche.php?action=delete&id='.$act->id.'">'.$langs->trans("Delete").'</a>'; 525 } 526 527 print '</div>'; 528 } 529 530 $db->close(); 531 532 llxFooter('$Date: 2005/10/08 18:09:53 $ - $Revision: 1.64 $'); 533 534 535 /** 536 \brief Ajoute une ligne de tableau a 2 colonnes pour avoir l'option webcalendar 537 \return int Retourne le nombre de lignes ajoutées 538 */ 539 function add_row_for_webcal_link() 540 { 541 global $conf,$langs,$user; 542 $nbtr=0; 543 544 // Lien avec calendrier si module activé 545 if ($conf->webcal->enabled) 546 { 547 if ($conf->global->PHPWEBCALENDAR_SYNCRO != 'never') 548 { 549 $langs->load("other"); 550 if (! $user->webcal_login) 551 { 552 print '<tr><td width="25%" nowrap>'.$langs->trans("AddCalendarEntry").'</td>'; 553 print '<td><input type="checkbox" disabled name="todo_webcal">'; 554 print ' '.$langs->transnoentities("ErrorWebcalLoginNotDefined","<a href=\"".DOL_URL_ROOT."/user/fiche.php?id=".$user->id."\">".$user->login."</a>"); 555 print '</td>'; 556 print '</tr>'; 557 $nbtr++; 558 } 559 else 560 { 561 if ($conf->global->PHPWEBCALENDAR_SYNCRO == 'always') 562 { 563 print '<input type="hidden" name="todo_webcal" value="on">'; 564 } 565 else 566 { 567 print '<tr><td width="25%" nowrap>'.$langs->trans("AddCalendarEntry").'</td>'; 568 print '<td><input type="checkbox" name="todo_webcal"'.(($conf->global->PHPWEBCALENDAR_SYNCRO=='always' || $conf->global->PHPWEBCALENDAR_SYNCRO=='yesbydefault')?' checked':'').'></td>'; 569 print '</tr>'; 570 $nbtr++; 571 } 572 } 573 } 574 } 575 576 return $nbtr; 577 } 578 579 580 ?> 581 582
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 |
|