From 609d01d3864792aa5fceb2e6d5c79642a320d45c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Mar 2011 22:58:13 +0000 Subject: [PATCH] Fix: Restore previous version. Change contains new features not compatible with version. --- htdocs/contrat/fiche.php | 291 ++++++++++++++++++++------------------- 1 file changed, 147 insertions(+), 144 deletions(-) diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 77c028e944f..a77962ab725 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -1,9 +1,9 @@ * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,6 @@ require ("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php'); -require_once(DOL_DOCUMENT_ROOT."/includes/modules/contract/modules_contract.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); @@ -43,15 +42,13 @@ $langs->load("bills"); $langs->load("products"); // Security check -$socid = GETPOST("socid"); -$contratid = GETPOST("id"); +$socid=GETPOST("socid"); +$contratid = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'contrat',$contratid,'contrat'); $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; -$object = new Contrat($db); - /* * Actions @@ -59,31 +56,33 @@ $object = new Contrat($db); if ($_REQUEST["action"] == 'confirm_active' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->activer) { - $object->fetch($_GET["id"]); - $result = $object->active_line($user, $_GET["ligne"], $_GET["date"], $_GET["dateend"], $_GET["comment"]); + $contrat = new Contrat($db); + $contrat->fetch($_GET["id"]); + $result = $contrat->active_line($user, $_GET["ligne"], $_GET["date"], $_GET["dateend"], $_GET["comment"]); if ($result > 0) { - Header("Location: fiche.php?id=".$object->id); + Header("Location: fiche.php?id=".$contrat->id); exit; } else { - $mesg=$object->error; + $mesg=$contrat->error; } } if ($_REQUEST["action"] == 'confirm_closeline' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->activer) { - $object->fetch($_GET["id"]); - $result = $object->close_line($user, $_GET["ligne"], $_GET["dateend"], urldecode($_GET["comment"])); + $contrat = new Contrat($db); + $contrat->fetch($_GET["id"]); + $result = $contrat->close_line($user, $_GET["ligne"], $_GET["dateend"], urldecode($_GET["comment"])); if ($result > 0) { - Header("Location: fiche.php?id=".$object->id); + Header("Location: fiche.php?id=".$contrat->id); exit; } else { - $mesg=$object->error; + $mesg=$contrat->error; } } @@ -146,25 +145,27 @@ if ($_POST["remonth"] && $_POST["reday"] && $_POST["reyear"]) if ($_POST["action"] == 'add') { - $object->socid = $_POST["socid"]; - $object->date_contrat = $datecontrat; + $contrat = new Contrat($db); - $object->commercial_suivi_id = $_POST["commercial_suivi_id"]; - $object->commercial_signature_id = $_POST["commercial_signature_id"]; + $contrat->socid = $_POST["socid"]; + $contrat->date_contrat = $datecontrat; - $object->note = trim($_POST["note"]); - $object->fk_project = trim($_POST["projectid"]); - $object->remise_percent = trim($_POST["remise_percent"]); - $object->ref = trim($_POST["ref"]); + $contrat->commercial_suivi_id = $_POST["commercial_suivi_id"]; + $contrat->commercial_signature_id = $_POST["commercial_signature_id"]; - $result = $object->create($user,$langs,$conf); + $contrat->note = trim($_POST["note"]); + $contrat->fk_project = trim($_POST["projectid"]); + $contrat->remise_percent = trim($_POST["remise_percent"]); + $contrat->ref = trim($_POST["ref"]); + + $result = $contrat->create($user,$langs,$conf); if ($result > 0) { - Header("Location: fiche.php?id=".$object->id); + Header("Location: fiche.php?id=".$contrat->id); exit; } else { - $mesg='
'.$object->error.'
'; + $mesg='
'.$contrat->error.'
'; } $_GET["socid"]=$_POST["socid"]; $_GET["action"]='create'; @@ -173,21 +174,23 @@ if ($_POST["action"] == 'add') if ($_POST["action"] == 'classin') { - $object->fetch($_GET["id"]); - $object->setProject($_POST["projectid"]); + $contrat = new Contrat($db); + $contrat->fetch($_GET["id"]); + $contrat->setProject($_POST["projectid"]); } if ($_POST["action"] == 'addline' && $user->rights->contrat->creer) { if ($_POST["pqty"] && (($_POST["pu"] != '' && $_POST["desc"]) || $_POST["idprod"])) { - $ret=$object->fetch($_GET["id"]); + $contrat = new Contrat($db); + $ret=$contrat->fetch($_GET["id"]); if ($ret < 0) { dol_print_error($db,$commande->error); exit; } - $ret=$object->fetch_thirdparty(); + $ret=$contrat->fetch_thirdparty(); $date_start=''; $date_end=''; @@ -225,16 +228,16 @@ if ($_POST["action"] == 'addline' && $user->rights->contrat->creer) $prod = new Product($db, $_POST['idprod']); $prod->fetch($_POST['idprod']); - $tva_tx = get_default_tva($mysoc,$object->client,$prod->id); - $tva_npr = get_default_npr($mysoc,$object->client,$prod->id); + $tva_tx = get_default_tva($mysoc,$contrat->client,$prod->id); + $tva_npr = get_default_npr($mysoc,$contrat->client,$prod->id); // On defini prix unitaire - if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) + if ($conf->global->PRODUIT_MULTIPRICES && $contrat->client->price_level) { - $pu_ht = $prod->multiprices[$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; - $price_min = $prod->multiprices_min[$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; + $pu_ht = $prod->multiprices[$contrat->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$contrat->client->price_level]; + $price_min = $prod->multiprices_min[$contrat->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$contrat->client->price_level]; } else { @@ -271,21 +274,21 @@ if ($_POST["action"] == 'addline' && $user->rights->contrat->creer) $desc=$_POST['desc']; } - $localtax1_tx=get_localtax($tva_tx,1,$object->client); - $localtax2_tx=get_localtax($tva_tx,2,$object->client); + $localtax1_tx=get_localtax($tva_tx,1,$contrat->client); + $localtax2_tx=get_localtax($tva_tx,2,$contrat->client); $info_bits=0; if ($tva_npr) $info_bits |= 0x01; if($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min))) { - $object->error = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)) ; + $contrat->error = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)) ; $result = -1 ; } else { // Insert line - $result = $object->addline( + $result = $contrat->addline( $desc, $pu_ht, $_POST["pqty"], @@ -309,52 +312,52 @@ if ($_POST["action"] == 'addline' && $user->rights->contrat->creer) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$contrat->client->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - contrat_pdf_create($db, $object->id, $object->modelpdf, $outputlangs); + contrat_pdf_create($db, $contrat->id, $contrat->modelpdf, $outputlangs); */ } else { - $mesg='
'.$object->error.'
'; + $mesg='
'.$contrat->error.'
'; } } } if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && ! $_POST["cancel"]) { - $objectline = new ContratLigne($db); - if ($objectline->fetch($_POST["elrowid"])) + $contratline = new ContratLigne($db); + if ($contratline->fetch($_POST["elrowid"])) { $db->begin(); - if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture; - if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture; + if ($date_start_real_update == '') $date_start_real_update=$contratline->date_ouverture; + if ($date_end_real_update == '') $date_end_real_update=$contratline->date_cloture; - $localtax1_tx=get_localtax($_POST["eltva_tx"],1,$object->client); - $localtax2_tx=get_localtax($_POST["eltva_tx"],2,$object->client); + $localtax1_tx=get_localtax($_POST["eltva_tx"],1,$contrat->client); + $localtax2_tx=get_localtax($_POST["eltva_tx"],2,$contrat->client); - $objectline->description=$_POST["eldesc"]; - $objectline->price_ht=$_POST["elprice"]; - $objectline->subprice=$_POST["elprice"]; - $objectline->qty=$_POST["elqty"]; - $objectline->remise_percent=$_POST["elremise_percent"]; - $objectline->tva_tx=$_POST["eltva_tx"]; - $objectline->localtax1_tx=$localtax1_tx; - $objectline->localtax2_tx=$localtax2_tx; - $objectline->date_ouverture_prevue=$date_start_update; - $objectline->date_ouverture=$date_start_real_update; - $objectline->date_fin_validite=$date_end_update; - $objectline->date_cloture=$date_end_real_update; - $objectline->fk_user_cloture=$user->id; + $contratline->description=$_POST["eldesc"]; + $contratline->price_ht=$_POST["elprice"]; + $contratline->subprice=$_POST["elprice"]; + $contratline->qty=$_POST["elqty"]; + $contratline->remise_percent=$_POST["elremise_percent"]; + $contratline->tva_tx=$_POST["eltva_tx"]; + $contratline->localtax1_tx=$localtax1_tx; + $contratline->localtax2_tx=$localtax2_tx; + $contratline->date_ouverture_prevue=$date_start_update; + $contratline->date_ouverture=$date_start_real_update; + $contratline->date_fin_validite=$date_end_update; + $contratline->date_cloture=$date_end_real_update; + $contratline->fk_user_cloture=$user->id; // TODO verifier price_min si fk_product et multiprix - $result=$objectline->update($user); + $result=$contratline->update($user); if ($result > 0) { $db->commit(); @@ -373,39 +376,43 @@ if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && ! $_PO if ($_REQUEST["action"] == 'confirm_deleteline' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->creer) { - $object->fetch($_GET["id"]); - $result = $object->deleteline($_GET["lineid"],$user); + $contrat = new Contrat($db); + $contrat->fetch($_GET["id"]); + $result = $contrat->deleteline($_GET["lineid"],$user); if ($result >= 0) { - Header("Location: fiche.php?id=".$object->id); + Header("Location: fiche.php?id=".$contrat->id); exit; } else { - $mesg=$object->error; + $mesg=$contrat->error; } } if ($_REQUEST["action"] == 'confirm_valid' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->creer) { - $object->fetch($_GET["id"]); - $result = $object->validate($user,$langs,$conf); + $contrat = new Contrat($db); + $contrat->fetch($_GET["id"]); + $result = $contrat->validate($user,$langs,$conf); } // Close all lines if ($_REQUEST["action"] == 'confirm_close' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->creer) { - $object->fetch($_GET["id"]); - $result = $object->cloture($user,$langs,$conf); + $contrat = new Contrat($db); + $contrat->fetch($_GET["id"]); + $result = $contrat->cloture($user,$langs,$conf); } if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') { if ($user->rights->contrat->supprimer) { - $object->id = $_GET["id"]; - $result=$object->delete($user,$langs,$conf); + $contrat = new Contrat($db); + $contrat->id = $_GET["id"]; + $result=$contrat->delete($user,$langs,$conf); if ($result >= 0) { Header("Location: index.php"); @@ -413,7 +420,7 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') } else { - $mesg='
'.$object->error.'
'; + $mesg='
'.$contrat->error.'
'; } } } @@ -435,7 +442,7 @@ if ($_REQUEST["action"] == 'confirm_move' && $_REQUEST["confirm"] == 'yes') } else { - $mesg='
'.$object->error.'
'; + $mesg='
'.$contrat->error.'
'; } } else @@ -455,7 +462,7 @@ llxHeader('',$langs->trans("ContractCard"),"Contrat"); $form = new Form($db); $html = new Form($db); -$objectlignestatic=new ContratLigne($db); +$contratlignestatic=new ContratLigne($db); /********************************************************************* @@ -472,11 +479,6 @@ if ($_GET["action"] == 'create') $soc = new Societe($db); $soc->fetch($socid); - $object->date_contrat = time(); - if ($contratid) $result=$object->fetch($contratid); - - $numct = $object->getNextNumRef($soc); - print '
'; print ''; @@ -488,7 +490,7 @@ if ($_GET["action"] == 'create') // Ref print ''.$langs->trans("Ref").''; - print ''; + print ''; // Customer print ''.$langs->trans("Customer").''.$soc->getNomUrl(1).''; @@ -629,32 +631,33 @@ else $ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { - $result=$object->fetch($_GET['id'],$_GET['ref']); + $contrat = new Contrat($db); + $result=$contrat->fetch($_GET['id'],$_GET['ref']); if ($result > 0) { - $id = $object->id; // if $_GET['ref'] - $result=$object->fetch_lines(); + $id = $contrat->id; // if $_GET['ref'] + $result=$contrat->fetch_lines(); } if ($result < 0) { - dol_print_error($db,$object->error); + dol_print_error($db,$contrat->error); exit; } if ($mesg) print $mesg; - $nbofservices=sizeof($object->lines); + $nbofservices=sizeof($contrat->lines); $author = new User($db); - $author->fetch($object->user_author_id); + $author->fetch($contrat->user_author_id); $commercial_signature = new User($db); - $commercial_signature->fetch($object->commercial_signature_id); + $commercial_signature->fetch($contrat->commercial_signature_id); $commercial_suivi = new User($db); - $commercial_suivi->fetch($object->commercial_suivi_id); + $commercial_suivi->fetch($contrat->commercial_suivi_id); - $head = contract_prepare_head($object); + $head = contract_prepare_head($contrat); $hselected = 0; @@ -692,7 +695,7 @@ else /* * Contrat */ - if ($object->brouillon && $user->rights->contrat->creer) + if ($contrat->brouillon && $user->rights->contrat->creer) { print ''; print ''; @@ -703,18 +706,18 @@ else // Ref du contrat print ''.$langs->trans("Ref").''; - print $html->showrefnav($object,'ref','',1,'ref','ref',''); + print $html->showrefnav($contrat,'ref','',1,'ref','ref',''); print ""; // Customer print "".$langs->trans("Customer").""; - print ''.$object->societe->getNomUrl(1).''; + print ''.$contrat->societe->getNomUrl(1).''; // Ligne info remises tiers print ''.$langs->trans('Discount').''; - if ($object->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$object->societe->remise_client); + if ($contrat->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$contrat->societe->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount=$object->societe->getAvailableDiscounts(); + $absolute_discount=$contrat->societe->getAvailableDiscounts(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->monnaie)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); @@ -723,13 +726,13 @@ else // Statut contrat print ''.$langs->trans("Status").''; - if ($object->statut==0) print $object->getLibStatut(2); - else print $object->getLibStatut(4); + if ($contrat->statut==0) print $contrat->getLibStatut(2); + else print $contrat->getLibStatut(4); print ""; // Date print ''.$langs->trans("Date").''; - print ''.dol_print_date($object->date_contrat,"dayhour")."\n"; + print ''.dol_print_date($contrat->date_contrat,"dayhour")."\n"; // Projet if ($conf->projet->enabled) @@ -744,18 +747,18 @@ else print ''; if ($_GET["action"] == "classer") { - $form->form_project("fiche.php?id=$id",$object->socid,$object->fk_project,"projectid"); + $form->form_project("fiche.php?id=$id",$contrat->socid,$contrat->fk_project,"projectid"); } else { - $form->form_project("fiche.php?id=$id",$object->socid,$object->fk_project,"none"); + $form->form_project("fiche.php?id=$id",$contrat->socid,$contrat->fk_project,"none"); } print ""; } print ""; - if ($object->brouillon == 1 && $user->rights->contrat->creer) + if ($contrat->brouillon == 1 && $user->rights->contrat->creer) { print '
'; } @@ -765,7 +768,7 @@ else $servicepos=(isset($_REQUEST["servicepos"])?$_REQUEST["servicepos"]:1); $colorb='666666'; - $arrayothercontracts=$object->getListOfContracts('others'); + $arrayothercontracts=$contrat->getListOfContracts('others'); /* * Lines of contracts @@ -793,7 +796,7 @@ else $sql.= " p.ref, p.label"; $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; - $sql.= " WHERE cd.rowid = ".$object->lines[$cursorline-1]->id; + $sql.= " WHERE cd.rowid = ".$contrat->lines[$cursorline-1]->id; $result = $db->query($sql); if ($result) @@ -849,28 +852,28 @@ else } // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) print ''; - if ($user->rights->contrat->creer && sizeof($arrayothercontracts) && ($object->statut >= 0)) + if ($user->rights->contrat->creer && sizeof($arrayothercontracts) && ($contrat->statut >= 0)) { - print ''; + print ''; print img_picto($langs->trans("MoveToAnotherContract"),'uparrow'); print ''; } else { print ' '; } - if ($user->rights->contrat->creer && ($object->statut >= 0)) + if ($user->rights->contrat->creer && ($contrat->statut >= 0)) { - print ''; + print ''; print img_edit(); print ''; } else { print ' '; } - if ( $user->rights->contrat->creer && ($object->statut >= 0)) + if ( $user->rights->contrat->creer && ($contrat->statut >= 0)) { print ' '; - print ''; + print ''; print img_delete(); print ''; } @@ -929,7 +932,7 @@ else } print ''; print ''; - print $form->select_tva("eltva_tx",$objp->tva_tx,$mysoc,$object->societe); + print $form->select_tva("eltva_tx",$objp->tva_tx,$mysoc,$contrat->societe); print ''; print ''; print ''; @@ -957,7 +960,7 @@ else dol_print_error($db); } - if ($object->statut > 0) + if ($contrat->statut > 0) { print ''; print '
'; @@ -970,16 +973,16 @@ else /* * Confirmation to delete service line of contract */ - if ($_REQUEST["action"] == 'deleteline' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == $_GET["rowid"]) + if ($_REQUEST["action"] == 'deleteline' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $contrat->lines[$cursorline-1]->id == $_GET["rowid"]) { - $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".$_GET["rowid"],$langs->trans("DeleteContractLine"),$langs->trans("ConfirmDeleteContractLine"),"confirm_deleteline",'',0,1); + $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$contrat->id."&lineid=".$_GET["rowid"],$langs->trans("DeleteContractLine"),$langs->trans("ConfirmDeleteContractLine"),"confirm_deleteline",'',0,1); if ($ret == 'html') print '
'; } /* * Confirmation to move service toward another contract */ - if ($_REQUEST["action"] == 'move' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == $_GET["rowid"]) + if ($_REQUEST["action"] == 'move' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $contrat->lines[$cursorline-1]->id == $_GET["rowid"]) { $arraycontractid=array(); foreach($arrayothercontracts as $contractcursor) @@ -992,50 +995,50 @@ else 'text' => $langs->trans("ConfirmMoveToAnotherContractQuestion"), array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid)); - $html->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".$_GET["rowid"],$langs->trans("MoveToAnotherContract"),$langs->trans("ConfirmMoveToAnotherContract"),"confirm_move",$formquestion); + $html->form_confirm($_SERVER["PHP_SELF"]."?id=".$contrat->id."&lineid=".$_GET["rowid"],$langs->trans("MoveToAnotherContract"),$langs->trans("ConfirmMoveToAnotherContract"),"confirm_move",$formquestion); print '
'; } /* * Confirmation de la validation activation */ - if ($_REQUEST["action"] == 'active' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($_REQUEST["action"] == 'active' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $contrat->lines[$cursorline-1]->id == $_GET["ligne"]) { $dateactstart = dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $dateactend = dol_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); $comment = $_POST["comment"]; - $html->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment),$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",dol_print_date($dateactstart,"%A %d %B %Y")),"confirm_active", '', 0, 1); + $html->form_confirm($_SERVER["PHP_SELF"]."?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment),$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",dol_print_date($dateactstart,"%A %d %B %Y")),"confirm_active", '', 0, 1); print '
'; } /* * Confirmation de la validation fermeture */ - if ($_REQUEST["action"] == 'closeline' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($_REQUEST["action"] == 'closeline' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $contrat->lines[$cursorline-1]->id == $_GET["ligne"]) { $dateactstart = dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $dateactend = dol_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); $comment = $_POST["comment"]; - $html->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService",dol_print_date($dateactend,"%A %d %B %Y")), "confirm_closeline", '', 0, 1); + $html->form_confirm($_SERVER["PHP_SELF"]."?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService",dol_print_date($dateactend,"%A %d %B %Y")), "confirm_closeline", '', 0, 1); print '
'; } // Area with status and activation info of line - if ($object->statut > 0) + if ($contrat->statut > 0) { print ''; print ''; - print ''; + print ''; print '
'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).''.$langs->trans("ServiceStatus").': '.$contrat->lines[$cursorline-1]->getLibStatut(4).''; if ($user->societe_id == 0) { - if ($object->statut > 0 && $_REQUEST["action"] != 'activateline' && $_REQUEST["action"] != 'unactivateline') + if ($contrat->statut > 0 && $_REQUEST["action"] != 'activateline' && $_REQUEST["action"] != 'unactivateline') { $action='activateline'; if ($objp->statut == 4) $action='unactivateline'; - print ''; + print ''; print img_edit(); print ''; } @@ -1074,12 +1077,12 @@ else print '
'; } - if ($user->rights->contrat->activer && $_REQUEST["action"] == 'activateline' && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($user->rights->contrat->activer && $_REQUEST["action"] == 'activateline' && $contrat->lines[$cursorline-1]->id == $_GET["ligne"]) { /** * Activer la ligne de contrat */ - print '
'; + print ''; print ''; print ''; @@ -1124,12 +1127,12 @@ else print ''; } - if ($user->rights->contrat->activer && $_REQUEST["action"] == 'unactivateline' && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($user->rights->contrat->activer && $_REQUEST["action"] == 'unactivateline' && $contrat->lines[$cursorline-1]->id == $_GET["ligne"]) { /** * Desactiver la ligne de contrat */ - print ''; + print ''; print ''; print '
'; @@ -1185,7 +1188,7 @@ else /* * Ajouter une ligne produit/service */ - if ($user->rights->contrat->creer && ($object->statut >= 0)) + if ($user->rights->contrat->creer && ($contrat->statut >= 0)) { print '
'; print '
'; // Array with (n*2)+1 lines @@ -1213,7 +1216,7 @@ else print ''; print ''; - print ''; + print ''; print ''; print ''."\n"; @@ -1249,11 +1252,11 @@ else print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''."\n"; @@ -1289,20 +1292,20 @@ else { print '
'; - if ($object->statut == 0 && $nbofservices) + if ($contrat->statut == 0 && $nbofservices) { if ($user->rights->contrat->creer) print ''.$langs->trans("Validate").''; else print ''.$langs->trans("Validate").''; } - if ($conf->facture->enabled && $object->statut > 0) + if ($conf->facture->enabled && $contrat->statut > 0) { $langs->load("bills"); - if ($user->rights->facture->creer) print ''.$langs->trans("CreateBill").''; + if ($user->rights->facture->creer) print ''.$langs->trans("CreateBill").''; else print ''.$langs->trans("CreateBill").''; } - if ($object->nbofservicesclosed < $nbofservices) + if ($contrat->nbofservicesclosed < $nbofservices) { //if (! $numactive) //{ @@ -1317,7 +1320,7 @@ else // On peut supprimer entite si // - Droit de creer + mode brouillon (erreur creation) // - Droit de supprimer - if (($user->rights->contrat->creer && $object->statut == 0) || $user->rights->contrat->supprimer) + if (($user->rights->contrat->creer && $contrat->statut == 0) || $user->rights->contrat->supprimer) { print ''.$langs->trans("Delete").''; } @@ -1329,17 +1332,17 @@ else /* * Linked object block */ - $object->load_object_linked($object->id,$object->element); + $contrat->load_object_linked($contrat->id,$contrat->element); - if (! empty($object->linked_object)) + if (! empty($contrat->linked_object)) { print '
'; // multiprix if($conf->global->PRODUIT_MULTIPRICES) - $form->select_produits('','idprod',1,$conf->product->limit_size,$object->societe->price_level); + $form->select_produits('','idprod',1,$conf->product->limit_size,$contrat->societe->price_level); else $form->select_produits('','idprod',1,$conf->product->limit_size); if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; @@ -1221,7 +1224,7 @@ else print '
%%
'; - $form->select_tva("tva_tx",$conf->defaulttx,$mysoc,$object->societe); + $form->select_tva("tva_tx",$conf->defaulttx,$mysoc,$contrat->societe); print '%%
'; - foreach($object->linked_object as $linked_object => $linked_objectid) + foreach($contrat->linked_object as $linked_object => $linked_objectid) { - if($conf->$linked_object->enabled && $linked_object != $object->element) + if($conf->$linked_object->enabled && $linked_object != $contrat->element) { - $somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); + $somethingshown=$contrat->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); } }