diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index 982deb4d889..1421e193c93 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -352,7 +352,7 @@ class Contrat extends CommonObject $sql.= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = p.rowid"; $sql.= " ORDER by d.rowid ASC"; - dolibarr_syslog("Contrat.class.php::fetch_lignes sql=".$sql); + dolibarr_syslog("Contrat::fetch_lignes sql=".$sql); $result = $this->db->query($sql); if ($result) { @@ -384,7 +384,7 @@ class Contrat extends CommonObject $ligne->date_fin_prevue = $objp->date_fin_validite; $ligne->date_fin_reel = $objp->date_cloture; - $this->lignes[$i] = $ligne; + $this->lignes[] = $ligne; //dolibarr_syslog("1 ".$ligne->desc); //dolibarr_syslog("2 ".$ligne->product_desc); $i++; @@ -414,12 +414,12 @@ class Contrat extends CommonObject while ($j < $num) { $objp = $this->db->fetch_object($result); - $ligne = new ContratLigne(); - $ligne->id = $objp->rowid; + $ligne = new ContratLigne($this->db); + $ligne->id = $objp->rowid; $ligne->libelle = stripslashes($objp->description); $ligne->desc = stripslashes($objp->description); $ligne->qty = $objp->qty; - $ligne->statut = $objp->statut; + $ligne->statut = $objp->statut; $ligne->ref = $objp->ref; $ligne->tva_tx = $objp->tva_tx; $ligne->subprice = $objp->subprice; @@ -432,7 +432,7 @@ class Contrat extends CommonObject $ligne->date_fin_prevue = $objp->date_fin_validite; $ligne->date_fin_reel = $objp->date_cloture; - $this->lignes[$i] = $ligne; + $this->lignes[] = $ligne; $i++; $j++; } diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 072d1a28eb7..6f8539dd981 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2006 Andre Cianfarani * 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 @@ -34,12 +34,13 @@ $langs->load("contracts"); $langs->load("orders"); $langs->load("companies"); $langs->load("bills"); +$langs->load("products"); if (! $user->rights->contrat->lire) accessforbidden(); -// S�curit� acc�s client et commerciaux +// Securite acces client et commerciaux $contratid = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id > 0) @@ -67,7 +68,46 @@ if ($contratid && !$user->rights->commercial->client->voir) } -// Si ajout champ produit pr�d�fini + + +/* + * Actions + */ + +if ($_POST["action"] == 'confirm_active' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer) +{ + $contrat = new Contrat($db); + $contrat->fetch($_GET["id"]); + + $result = $contrat->active_line($user, $_GET["ligne"], $_GET["date"], $_GET["dateend"]); + + if ($result > 0) + { + Header("Location: fiche.php?id=".$contrat->id); + exit; + } + else { + $mesg=$contrat->error; + } +} + +if ($_POST["action"] == 'confirm_closeline' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer) +{ + $contrat = new Contrat($db); + $contrat->fetch($_GET["id"]); + $result = $contrat->close_line($user, $_GET["ligne"], $_GET["dateend"]); + + if ($result > 0) + { + Header("Location: fiche.php?id=".$contrat->id); + exit; + } + else { + $mesg=$contrat->error; + } +} + +// Si ajout champ produit predefini if ($_POST["mode"]=='predefined') { $date_start=''; @@ -284,7 +324,7 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer) } } -if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && $_POST["save"]) +if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && ! $_POST["cancel"]) { $contrat = new Contrat($db,"",$_GET["id"]); if ($contrat->fetch($_GET["id"])) @@ -317,12 +357,6 @@ if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && $_POST } } -if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && $_POST["cancel"]) -{ - Header("Location: fiche.php?id=".$_GET["id"]); - exit; -} - if ($_GET["action"] == 'deleteline' && $user->rights->contrat->creer) { $contrat = new Contrat($db); @@ -375,6 +409,8 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') llxHeader('',$langs->trans("ContractCard"),"Contrat"); $form = new Form($db); +$html = new Form($db); + $contratlignestatic=new ContratLigne($db); @@ -554,8 +590,9 @@ else $id = $_GET["id"]; if ($id > 0) { - $contrat = New Contrat($db); + $contrat = new Contrat($db); $result=$contrat->fetch($id); + if ($result > 0) $result=$contrat->fetch_lignes(); if ($result < 0) { dolibarr_print_error($db,$contrat->error); @@ -680,307 +717,469 @@ else print ''; } + echo '
'; + + $servicepos=(isset($_REQUEST["servicepos"])?$_REQUEST["servicepos"]:1); + $nbofservices=sizeof($contrat->lignes); + $colorb='333333'; + /* * Lignes de contrats */ - echo '
'; + + // Menu list of services + print '
'; // Array with (n*2)+1 lines + $cursorline=1; + while ($cursorline <= $nbofservices) + { + print ''; + print ''; - $sql = "SELECT cd.statut, cd.label as label_det, cd.fk_product, cd.description, cd.price_ht, cd.qty, cd.rowid, cd.tva_tx, cd.remise_percent, cd.subprice,"; - $sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_debut, ".$db->pdate("cd.date_ouverture")." as date_debut_reelle,"; - $sql.= " ".$db->pdate("cd.date_fin_validite")." as date_fin, ".$db->pdate("cd.date_cloture")." as date_fin_reelle,"; - $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.fk_contrat = ".$id; - $sql.= " ORDER BY cd .rowid"; + print '"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + /* + * Confirmation de la validation activation + */ + if ($_REQUEST["action"] == 'active' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $contrat->lignes[$cursorline-1]->id == $_GET["ligne"]) + { + //print '
'; + $dateactstart = dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $dateactend = dolibarr_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + $html->form_confirm($_SERVER["PHP_SELF"]."?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend,$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",strftime("%A %d %B %Y", $dateactstart)),"confirm_active"); + //print '
'; + } - $var=false; + /* + * Confirmation de la validation fermeture + */ + if ($_REQUEST["action"] == 'closeline' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $contrat->lignes[$cursorline-1]->id == $_GET["ligne"]) + { + //print '
'; + $dateactstart = dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $dateactend = dolibarr_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + $html->form_confirm($_SERVER["PHP_SELF"]."?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend,$langs->trans("CloseService"),$langs->trans("ConfirmCloseService",strftime("%A %d %B %Y", $dateactend)),"confirm_closeline"); + //print '
'; + } + + // Area with activation info + if ($contrat->statut > 0) + { + print '
'; + print $langs->trans("ServiceNb",$cursorline).''; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $total = 0; + // Area with common detail of line + print ''; - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($result); + $sql = "SELECT cd.statut, cd.label as label_det, cd.fk_product, cd.description, cd.price_ht, cd.qty, cd.rowid, cd.tva_tx, cd.remise_percent, cd.subprice,"; + $sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_debut, ".$db->pdate("cd.date_ouverture")." as date_debut_reelle,"; + $sql.= " ".$db->pdate("cd.date_fin_validite")." as date_fin, ".$db->pdate("cd.date_cloture")." as date_fin_reelle,"; + $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 = ".$contrat->lignes[$cursorline-1]->id; - $var=!$var; + $result = $db->query($sql); + if ($result) + { + $total = 0; - if ($_GET["action"] != 'editline' || $_GET["rowid"] != $objp->rowid) - { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - print ''; - // Libelle - if ($objp->fk_product > 0) - { - print ''; - } - else - { - print "\n"; - } - // TVA - print ''; - // Prix - print '\n"; - // Quantit� - print ''; - // Remise - if ($objp->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } - // Icon update et delete (statut contrat 0=brouillon,1=valid�,2=ferm�) - print ''; - - // Statut - print ''; + $var=true; - print "\n"; + $objp = $db->fetch_object($result); + + $var=!$var; - // Dates de en service pr�vues et effectives - if ($objp->subprice >= 0) - { - print ''; - print ''; + // Libelle + if ($objp->fk_product > 0) + { + print ''; + } + else + { + print "\n"; + } + // TVA + print ''; + // Prix + print '\n"; + // Quantite + print ''; + // Remise + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + // Icon update et delete (statut contrat 0=brouillon,1=valid�,2=ferm�) + print ''; + + print "\n"; + + // Dates de en service prevues et effectives + if ($objp->subprice >= 0) + { + print ''; + print ''; - print ''; - } - } + print ''; + print ''; + } + } + // Ligne en mode update + else + { + print ""; + print ''; + print ''; + // Ligne carac + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + // Ligne dates prevues + print ""; + print ''; + print ''; - // Ligne en mode update - else - { - print ""; - print ''; - print ''; - // Ligne carac - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - // Ligne dates prevues - print ""; - print ''; - print ''; + print "\n"; + } + + $db->free($result); + } + else + { + dolibarr_print_error($db); + } - print "\n"; - } - $i++; - } - $db->free($result); - } - else - { - dolibarr_print_error($db); - } + print "
'.$langs->trans("Service").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").' '.$langs->trans("Status").'
'.$langs->trans("Service").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").' 
'; - print ''; - print img_object($langs->trans("ShowService"),"service").' '.$objp->ref.''; - print $objp->label?' - '.$objp->label:''; - if ($objp->description) print '
'.nl2br($objp->description); - print '
".nl2br($objp->description)."'.vatrate($objp->tva_tx).'%'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent."% '; - if ($contrat->statut != 2 && $user->rights->contrat->creer) - { - print ''; - print img_edit(); - print ''; - } - else { - print ' '; - } - if ($contrat->statut == 0 && $user->rights->contrat->creer) - { - print ' '; - print ''; - print img_delete(); - print ''; - } - print ''; - // Activation desativation du contact - if ($contrat->statut > 0) print '';; - print $contratlignestatic->LibStatut($objp->statut,3); - if ($contrat->statut >= 0) print ''; - print '
'; + if ($_GET["action"] != 'editline' || $_GET["rowid"] != $objp->rowid) + { + print '
'; + print ''; + print img_object($langs->trans("ShowService"),"service").' '.$objp->ref.''; + print $objp->label?' - '.$objp->label:''; + if ($objp->description) print '
'.nl2br($objp->description); + print '
".nl2br($objp->description)."'.vatrate($objp->tva_tx).'%'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent."% '; + if ($contrat->statut != 2 && $user->rights->contrat->creer) + { + print ''; + print img_edit(); + print ''; + } + else { + print ' '; + } + if ($contrat->statut == 0 && $user->rights->contrat->creer) + { + print ' '; + print ''; + print img_delete(); + print ''; + } + print '
'; - // Date pr�vues - print $langs->trans("DateStartPlanned").': '; - if ($objp->date_debut) { - print dolibarr_print_date($objp->date_debut); - // Warning si date prevu pass�e et pas en service - if ($objp->statut == 0 && $objp->date_debut < time() - $conf->contrat->warning_delay) { print " ".img_warning($langs->trans("Late")); } - } - else print $langs->trans("Unknown"); - print '  -  '; - print $langs->trans("DateEndPlanned").': '; - if ($objp->date_fin) { - print dolibarr_print_date($objp->date_fin); - if ($objp->statut == 4 && $objp->date_fin < time() - $conf->contrat->services->inactifs->warning_delay) { print " ".img_warning($langs->trans("Late")); } - } - else print $langs->trans("Unknown"); + // Date pr�vues + print $langs->trans("DateStartPlanned").': '; + if ($objp->date_debut) { + print dolibarr_print_date($objp->date_debut); + // Warning si date prevu pass�e et pas en service + if ($objp->statut == 0 && $objp->date_debut < time() - $conf->contrat->warning_delay) { print " ".img_warning($langs->trans("Late")); } + } + else print $langs->trans("Unknown"); + print '  -  '; + print $langs->trans("DateEndPlanned").': '; + if ($objp->date_fin) { + print dolibarr_print_date($objp->date_fin); + if ($objp->statut == 4 && $objp->date_fin < time() - $conf->contrat->services->inactifs->warning_delay) { print " ".img_warning($langs->trans("Late")); } + } + else print $langs->trans("Unknown"); - print '
'; - - // Si pas encore activ� - if (! $objp->date_debut_reelle) { - print $langs->trans("DateStartReal").': '; - if ($objp->date_debut_reelle) print dolibarr_print_date($objp->date_debut_reelle); - else print $langs->trans("ContractStatusNotRunning"); - } - // Si activ� et en cours - if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) { - print $langs->trans("DateStartReal").': '; - print dolibarr_print_date($objp->date_debut_reelle); - } - // Si d�sactiv� - if ($objp->date_debut_reelle && $objp->date_fin_reelle) { - print $langs->trans("DateStartReal").': '; - print dolibarr_print_date($objp->date_debut_reelle); - print '  -  '; - print $langs->trans("DateEndReal").': '; - print dolibarr_print_date($objp->date_fin_reelle); - } - print '
'; + if ($objp->fk_product) + { + print ''; + print img_object($langs->trans("ShowService"),"service").' '.$objp->ref.''; + print $objp->label?' - '.$objp->label:''; + print '
'; + } + else + { + print $objp->label?$objp->label.'
':''; + } + print '
'; + print $form->select_tva("eltva_tx",$objp->tva_tx,$mysoc,$contrat->societe); + print '%'; + print '
'; + print '
'; + print $langs->trans("DateStartPlanned").' '; + $form->select_date($objp->date_debut,"date_start_update",0,0,($objp->date_debut>0?0:1),"update"); + print '   '.$langs->trans("DateEndPlanned").' '; + $form->select_date($objp->date_fin,"date_end_update",0,0,($objp->date_fin>0?0:1),"update"); + print '
'; - if ($objp->fk_product) - { - print ''; - print img_object($langs->trans("ShowService"),"service").' '.$objp->ref.''; - print $objp->label?' - '.$objp->label:''; - print '
'; - } - else - { - print $objp->label?$objp->label.'
':''; - } - print '
'; - print $form->select_tva("eltva_tx",$objp->tva_tx,$mysoc,$contrat->societe); - print '%'; - print '
'; - print '
'; - print $langs->trans("DateStartPlanned").' '; - $form->select_date($objp->date_debut,"date_start_update",0,0,($objp->date_debut>0?0:1),"update"); - print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date($objp->date_fin,"date_end_update",0,0,($objp->date_fin>0?0:1),"update"); - if ($objp->statut >= 4) - { - print '
'; - print $langs->trans("DateStartReal").' '; - $form->select_date($objp->date_debut_reelle,"date_start_real_update",0,0,($objp->date_debut_reelle>0?0:1),"update"); - print '   '; - if ($objp->statut == 5) - { - print $langs->trans("DateEndReal").' '; - $form->select_date($objp->date_fin_reelle,"date_end_real_update",0,0,($objp->date_fin_reelle>0?0:1),"update"); - } - } - print '
"; - /* - * Ajouter une ligne produit/service - */ - if ($user->rights->contrat->creer && $contrat->statut == 0) - { - print "
'.$langs->trans("Service").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").'  
'; - // Service sur produit predefini - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print "\n"; - print ""; - print ''; + print ''; + print ''; + print "\n"; + + print ''; + + print ''; + + // Statut + print ''; + print '
'.$langs->trans("Activation").' 
'; + print '
'.$langs->trans("Status").': '.$contrat->lignes[$cursorline-1]->getLibStatut(4).' 
'; + // Si pas encore active + if (! $objp->date_debut_reelle) { + print $langs->trans("DateStartReal").': '; + if ($objp->date_debut_reelle) print dolibarr_print_date($objp->date_debut_reelle); + else print $langs->trans("ContractStatusNotRunning"); + } + // Si active et en cours + if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) { + print $langs->trans("DateStartReal").': '; + print dolibarr_print_date($objp->date_debut_reelle); + } + // Si desactive + if ($objp->date_debut_reelle && $objp->date_fin_reelle) { + print $langs->trans("DateStartReal").': '; + print dolibarr_print_date($objp->date_debut_reelle); + print '  -  '; + print $langs->trans("DateEndReal").': '; + print dolibarr_print_date($objp->date_fin_reelle); + } + print ''; + if ($user->societe_id == 0) + { + if ($contrat->statut > 0 && $_REQUEST["action"] != 'activateline' && $_REQUEST["action"] != 'unactivateline') + { + $action='activateline'; + if ($objp->statut == 4) $action='unactivateline'; + print ''; + print img_edit(); + print ''; + } + } + print '
'; + } + + if ($user->rights->contrat->activer && $_REQUEST["action"] == 'activateline' && $contrat->lignes[$cursorline-1]->id == $_GET["ligne"]) + { + /** + * Activer la ligne de contrat + */ + print ''; + + print ''; + //print ''; + + // Definie date debut et fin par defaut + if ($_POST["remonth"]) $dateactstart = dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + elseif (! $dateactstart) $dateactstart = time(); + + if ($_POST["endmonth"]) $dateactend = dolibarr_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + elseif (! $dateactend) + { + if ($objp->fk_product > 0) + { + $product=new Product($db); + $product->fetch($objp->fk_product); + $dateactend = dolibarr_time_plus_duree (time(), $product->duration_value, $product->duration_unit); + } + } + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print '
'.$langs->trans("Status").'
'.$langs->trans("DateServiceActivate").''; + print $html->select_date($dateactstart,'','','','',"active"); + print ''.$langs->trans("DateEndPlanned").''; + print $html->select_date($dateactend,"end",'','','',"active"); + print ''; + print '
'; + print ''; + print '
'.$langs->trans("Comment").'
'; + + print ''; + } + + if ($user->rights->contrat->activer && $_REQUEST["action"] == 'unactivateline' && $contrat->lignes[$cursorline-1]->id == $_GET["ligne"]) + { + /** + * Desactiver la ligne de contrat + */ + print '
'; + + print ''; + + // Definie date debut et fin par defaut + $dateactstart = $objp->date_debut_reelle; + if ($_POST["remonth"]) $dateactstart = dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + elseif (! $dateactstart) $dateactstart = time(); + + $dateactend = $objp->date_fin_reelle; + if ($_POST["endmonth"]) $dateactend = dolibarr_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + elseif (! $dateactend) + { + if ($objp->fk_product > 0) + { + $product=new Product($db); + $product->fetch($objp->fk_product); + $dateactend = dolibarr_time_plus_duree (time(), $product->duration_value, $product->duration_unit); + } + } + $now=mktime(); + if ($dateactend > $now) $dateactend=$now; + + print ''; + + print ''; + + print ''; + print '
'; + if ($objp->statut >= 4) + { + if ($objp->statut == 4) + { + print $langs->trans("DateEndReal").' '; + $form->select_date($dateactend,"end",0,0,($objp->date_fin_reelle>0?0:1),"closeline"); + } + } + print '
'; + print ''; + print '
'.$langs->trans("Comment").'
'; + + print '
'; + } + + print ''; // End td if line is 1 + + print ''; + print ' '; + $cursorline++; + } + print ''; + + /* + * Ajouter une ligne produit/service + */ + if ($user->rights->contrat->creer && $contrat->statut == 0) + { + print '
'; + print ''; // Array with (n*2)+1 lines + + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=false; + + // Service sur produit predefini + print ''; + print ''; + print ''; + print ''; + + print ""; + print ''; + $form->select_produits('','p_idprod','',$conf->produit->limit_size); + if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''."\n"; - - print ""; - print ''; - print ''; - - print ''; + print ''; + print ''; + print ''; + print ''."\n"; + + print ""; + print ''; + print ''; + + print ''; - $var=!$var; - - // Service libre - print ''; - print ''; - print ''; - print ''; + $var=!$var; + + // Service libre + print ''; + print ''; + print ''; + print ''; - print ""; - print ''; + print ""; + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print ''."\n"; + print ''."\n"; - print ""; - print ''; - print ''; - - print ''; - } - print "
'.$langs->trans("Service").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").'  
'; // multiprix if($conf->global->PRODUIT_MULTIPRICES == 1) $form->select_produits('','p_idprod','',$conf->produit->limit_size,$contrat->societe->price_level); else - $form->select_produits('','p_idprod','',$conf->produit->limit_size); - if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; - print ''; - print '
%
'; - print $langs->trans("DateStartPlanned").' '; - $form->select_date('',"date_start",0,0,1,"addligne"); - print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date('',"date_end",0,0,1,"addligne"); - print '
%
'; + print $langs->trans("DateStartPlanned").' '; + $form->select_date('',"date_start",0,0,1,"addligne"); + print '   '.$langs->trans("DateEndPlanned").' '; + $form->select_date('',"date_end",0,0,1,"addligne"); + print '
'; - $form->select_tva("tva_tx",$conf->defaulttx,$mysoc,$contrat->societe); - print '%'; + $form->select_tva("tva_tx",$conf->defaulttx,$mysoc,$contrat->societe); + print '%
'; - print $langs->trans("DateStartPlanned").' '; - $form->select_date('',"date_start_sl",0,0,1,"addligne_sl"); - print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date('',"date_end_sl",0,0,1,"addligne_sl"); - print '
"; - /* - * Fin Ajout ligne - */ + print ""; + print ''; + print $langs->trans("DateStartPlanned").' '; + $form->select_date('',"date_start_sl",0,0,1,"addligne_sl"); + print '   '.$langs->trans("DateEndPlanned").' '; + $form->select_date('',"date_end_sl",0,0,1,"addligne_sl"); + print ''; + print ''; + + print ''; + print ''; + } + + + + //print ''; + + //print ''; + print ''; @@ -1018,6 +1217,7 @@ else } print ""; + print '
'; } } diff --git a/htdocs/contrat/ligne.php b/htdocs/contrat/ligne.php deleted file mode 100644 index 09d472ebd8c..00000000000 --- a/htdocs/contrat/ligne.php +++ /dev/null @@ -1,462 +0,0 @@ - - * Copyright (C) 2004-2007 Laurent Destailleur - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ - */ - -/** - \file htdocs/contrat/ligne.php - \ingroup contrat - \brief Fiche contrat - \version $Revision$ -*/ - -require("./pre.inc.php"); -require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php'); -require_once(DOL_DOCUMENT_ROOT."/product.class.php"); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/project.class.php"); -if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); -if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); - -$langs->load("contracts"); -$langs->load("orders"); -$langs->load("companies"); -$langs->load("bills"); - -if (!$user->rights->contrat->lire) -accessforbidden(); - - - -/* - * S�curit� acc�s client - */ -if ($user->societe_id > 0) -{ - $action = ''; - $socid = $user->societe_id; -} - - -/* - * Actions - */ -if ($_POST["action"] == 'confirm_active' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer) -{ - $contrat = new Contrat($db); - $contrat->fetch($_GET["id"]); - - $result = $contrat->active_line($user, $_GET["ligne"], $_GET["date"], $_GET["dateend"]); - - if ($result > 0) - { - Header("Location: fiche.php?id=".$contrat->id); - exit; - } - else { - $mesg=$contrat->error; - } -} - -if ($_POST["action"] == 'confirm_close' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer) -{ - $contrat = new Contrat($db); - $contrat->fetch($_GET["id"]); - - $result = $contrat->close_line($user, $_GET["ligne"], $_GET["dateend"]); - - if ($result > 0) - { - Header("Location: fiche.php?id=".$contrat->id); - exit; - } - else { - $mesg=$contrat->error; - } -} - - - - -llxHeader('',$langs->trans("ContractCard"),"Contrat"); - -$html = new Form($db); - -/* *************************************************************************** */ -/* */ -/* Mode vue et edition */ -/* */ -/* *************************************************************************** */ - -$lineid = $_GET["ligne"]; -if ($lineid > 0) -{ - $line = new ContratLigne($db); - $result=$line->fetch($lineid); - - $contrat = New Contrat($db); - $result=$contrat->fetch($line->fk_contrat); - - if ($result > 0) - { - $soc = new Societe($db); - $soc->fetch($contrat->socid); - - $author = new User($db); - $author->id = $contrat->user_author_id; - $author->fetch(); - - $head = contract_prepare_head($contrat); - $h=sizeof($head); - - // On ajout onglet service - $head[$h][0] = DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id."&ligne=".$line->id; - $head[$h][1] = $langs->trans($langs->trans("EditServiceLine")); - $hselected = $h; - - dolibarr_fiche_head($head, $hselected, $langs->trans("Contract")); - - - /* - * Confirmation de la validation activation - */ - if ($_GET["action"] == 'active' && $user->rights->contrat->activer) - { - $dateactstart = dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $dateactend = dolibarr_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - $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"); - print '
'; - } - - /* - * Confirmation de la validation fermeture - */ - if ($_GET["action"] == 'close' && $user->rights->contrat->activer) - { - $dateactstart = dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $dateactend = dolibarr_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - $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"); - print '
'; - } - - - /* - * Contrat - */ - print ''; - - // Reference du contrat - print '"; - - // Customer - print ""; - print ''; - - // Ligne info remises tiers - print ''; - - // Statut contrat - print '"; - - // Date - print ''; - print '\n"; - - // Projet - if ($conf->projet->enabled) - { - $langs->load("projects"); - print '"; - } - - print "
'.$langs->trans("Ref").''; - print $contrat->ref; - print "
".$langs->trans("Customer")."'.$soc->getNomUrl(1).'
'.$langs->trans('Discount').''; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount=$soc->getAvailableDiscounts(); - print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '
'.$langs->trans("Status").''; - print $contrat->getLibStatut(2); - print "
'.$langs->trans("Date").''.dolibarr_print_date($contrat->date_contrat,"dayhour")."
'; - print ''; - if ($_GET["action"] != "classer") print ''; - print '
'; - print $langs->trans("Project"); - print ''.img_edit($langs->trans("SetProject")).'
'; - print '
'; - if ($_GET["action"] == "classer") - { - $html->form_project($_SERVER["PHP_SELF"]."?id=$id&ligne=".$_GET["ligne"],$contrat->fk_soc,$contrat->fk_projet,"projetid"); - } - else - { - $html->form_project($_SERVER["PHP_SELF"]."?id=$id&ligne=".$_GET["ligne"],$contrat->fk_soc,$contrat->fk_projet,"none"); - } - print "
"; - - - /* - * Lignes de contrats - */ - print '
'; - - $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,"; - $sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_debut, ".$db->pdate("cd.date_ouverture")." as date_debut_reelle,"; - $sql.= " ".$db->pdate("cd.date_fin_validite")." as date_fin, ".$db->pdate("cd.date_cloture")." as date_fin_reelle,"; - $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.fk_contrat = ".$contrat->id; - $sql.= " AND cd.rowid = ".$line->id; - $sql.= " ORDER BY cd.rowid"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $total = 0; - - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - - $contratlignestatic = new ContratLigne($db); - - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($result); - - $var=!$var; - print "\n"; - - // Libelle - if ($objp->fk_product > 0) - { - print ''; - } - else - { - print "\n"; - } - - // TVA - print ''; - - print '\n"; - - print ''; - - if ($objp->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } - - print ''; - - // Statut - print ''; - - print "\n"; - - if ($objp->date_debut) $dateactstart=$objp->date_debut; - if ($objp->date_fin) $dateactend=$objp->date_fin; - - // Dates de en service pr�vues et effectives - - print ''; - print ''; - print ''; - - - $i++; - } - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - - print '
'.$langs->trans("Service").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").' '.$langs->trans("Status").'
'; - print ''; - print img_object($langs->trans("ShowService"),"service").' '.$objp->ref.''; - print $objp->label?' - '.$objp->label:''; - if ($objp->description) print '
'.stripslashes(nl2br($objp->description)); - print '
".stripslashes(nl2br($objp->description))."'.vatrate($objp->tva_tx).'%'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent."%  '; - print $contratlignestatic->LibStatut($objp->statut,3); - print '
'; - - // Date pr�vues - print $langs->trans("DateStartPlanned").': '; - if ($objp->date_debut) { - print dolibarr_print_date($objp->date_debut); - // Warning si date prevu pass�e et pas en service - if ($objp->statut == 0 && $objp->date_debut < time() - $conf->contrat->warning_delay) { print " ".img_warning($langs->trans("Late")); } - } - else print $langs->trans("Unknown"); - print '  -  '; - print $langs->trans("DateEndPlanned").': '; - if ($objp->date_fin) { - print dolibarr_print_date($objp->date_fin); - if ($objp->statut == 4 && $objp->date_fin < time() - $conf->contrat->warning_delay) { print " ".img_warning($langs->trans("Late")); } - } - else print $langs->trans("Unknown"); - - print '
'; - - // Si pas encore activ� - if (! $objp->date_debut_reelle) { - print $langs->trans("DateStartReal").': '; - if ($objp->date_debut_reelle) print dolibarr_print_date($objp->date_debut_reelle); - else print $langs->trans("ContractStatusNotRunning"); - } - // Si activ� et en cours - if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) { - print $langs->trans("DateStartReal").': '; - print dolibarr_print_date($objp->date_debut_reelle); - } - // Si d�sactiv� - if ($objp->date_debut_reelle && $objp->date_fin_reelle) { - print $langs->trans("DateStartReal").': '; - print dolibarr_print_date($objp->date_debut_reelle); - print '  -  '; - print $langs->trans("DateEndReal").': '; - print dolibarr_print_date($objp->date_fin_reelle); - } - print '
'; - print ''; - - if ($user->rights->contrat->activer && $contrat->statut == 1 && $objp->statut <> 4) - { - /** - * Activer la ligne de contrat - */ - $form = new Form($db); - - print '
'; - - print ''; - print ''; - - // Definie date debut et fin par defaut - if ($_POST["remonth"]) $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - elseif (! $dateactstart) $dateactstart = time(); - - if ($_POST["endmonth"]) $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - elseif (! $dateactend) - { - if ($objp->fk_product > 0) - { - $product=new Product($db); - $product->fetch($objp->fk_product); - $dateactend = dolibarr_time_plus_duree (time(), $product->duration_value, $product->duration_unit); - } - } - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print '
'.$langs->trans("ActivateService").'
'.$langs->trans("DateServiceActivate").''; - print $form->select_date($dateactstart,'','','','',"active"); - print ''.$langs->trans("DateEndPlanned").''; - print $form->select_date($dateactend,"end",'','','',"active"); - print '
'.$langs->trans("Comment").'
'; - - print '
'; - } - - if ($user->rights->contrat->activer && $contrat->statut == 1 && $objp->statut == 4) - { - /** - * D�sactiver la ligne de contrat - */ - $form = new Form($db); - - print '
'; - - print ''; - print ''; - - // Definie date debut et fin par defaut - if ($_POST["remonth"]) $dateactstart = dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - elseif (! $dateactstart) $dateactstart = time(); - - if ($_POST["endmonth"]) $dateactend = dolibarr_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - elseif (! $dateactend) - { - if ($objp->fk_product > 0) - { - $product=new Product($db); - $product->fetch($objp->fk_product); - $dateactend = dolibarr_time_plus_duree (time(), $product->duration_value, $product->duration_unit); - } - } - $now=mktime(); - if ($dateactend > $now) $dateactend=$now; - - - print ''; - - print ''; - - print ''; - print '
'.$langs->trans("CloseService").'
'.$langs->trans("DateEndReal").''; - print $form->select_date($dateactend,"end",'','','',"close"); - print '
'.$langs->trans("Comment").'
'; - - print '
'; - } - - } - else - { - // Contrat non trouv� - print "Contrat inexistant ou acc�s refus�"; - } -} - -$db->close(); - -llxFooter('$Date$ - $Revision$'); -?> diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index 8c6a0829f72..f04f5d88f17 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -31,10 +31,10 @@ CloseAContract=Close a contract ConfirmDeleteAContract=Are you sure you want to delete this contract ? ConfirmValidateContract=Are you sure you want to validate this contract ? ConfirmCloseContract=Are you sure you want to close this contract ? -ConfirmCloseService=Are you sure you want to close this service ? +ConfirmCloseService=Are you sure you want to close this service with date %s ? ValidateAContract=Validate a contract ActivateService=Activate service -ConfirmActivateService=Are you sure you want to activate this service with date of %s ? +ConfirmActivateService=Are you sure you want to activate this service with date of %s ? DateServiceActivate=Date of service activation DateServiceUnactivate=Date of service unactivation DateServiceStart=Date for beginning of service diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index d80130984c8..38e68bc2e0a 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -135,3 +135,4 @@ RecordedProducts=Products recorded RecordedProductsAndServices=Products/services recorded GenerateThumb=Generate thumb ProductCanvasAbility=Use special "canvas" addons +ServiceNb=Service #%s \ No newline at end of file diff --git a/htdocs/langs/fr_BE/contracts.lang b/htdocs/langs/fr_BE/contracts.lang index 0458eb4fc76..88980d3c81d 100644 --- a/htdocs/langs/fr_BE/contracts.lang +++ b/htdocs/langs/fr_BE/contracts.lang @@ -28,10 +28,10 @@ AddContract=Ajouter contrat SearchAContract=Rechercher un contrat DeleteAContract=Supprimer un contrat CloseAContract=Clôturer un contrat -ConfirmDeleteAContract=Êtes-vous certain de vouloir supprimer ce contrat? -ConfirmValidateContract=Êtes-vous certain de vouloir valider ce contrat? -ConfirmCloseContract=Êtes-vous certain de vouloir clôturer ce contrat? -ConfirmCloseService=Êtes-vous certain de vouloir clôturer ce service? +ConfirmDeleteAContract=Êtes-vous certain de vouloir supprimer ce contrat ? +ConfirmValidateContract=Êtes-vous certain de vouloir valider ce contrat ? +ConfirmCloseContract=Êtes-vous certain de vouloir clôturer ce contrat ? +ConfirmCloseService=Etes-vous sûr de vouloir fermer ce service à la date du %s ? ValidateAContract=Valider un contrat ActivateService=Activer service ConfirmActivateService=Êtes-vous certain de vouloir activer ce service en date du %s? diff --git a/htdocs/langs/fr_FR/contracts.lang b/htdocs/langs/fr_FR/contracts.lang index a1bd916d33a..277261bbe7a 100644 --- a/htdocs/langs/fr_FR/contracts.lang +++ b/htdocs/langs/fr_FR/contracts.lang @@ -31,10 +31,10 @@ CloseAContract=Cloturer un contract ConfirmDeleteAContract=Etes-vous sûr de vouloir supprimer ce contrat ? ConfirmValidateContract=Etes-vous sûr de vouloir valider ce contrat ? ConfirmCloseContract=Etes-vous sûr de vouloir cloturer ce contrat ? -ConfirmCloseService=Etes-vous sûr de vouloir fermer ce service ? +ConfirmCloseService=Etes-vous sûr de vouloir fermer ce service à la date du %s ? ValidateAContract=Valider un contrat ActivateService=Activer le service -ConfirmActivateService=Etes-vous sûr de vouloir activer ce service en date du %s +ConfirmActivateService=Etes-vous sûr de vouloir activer ce service en date du %s ? DateServiceActivate=Date activation du service DateServiceUnactivate=Date désactivation du service DateServiceStart=Date début du service diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index d5f7b1a1064..24bc6041255 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -135,3 +135,4 @@ RecordedProducts=Produits en vente RecordedProductsAndServices=Produits/services en vente GenerateThumb=Générer la vignette ProductCanvasAbility=Utiliser les extensions speciales "canvas" +ServiceNb=Service no %s diff --git a/htdocs/theme/eldy/eldy.css.php b/htdocs/theme/eldy/eldy.css.php index 75c9f30f6ec..8b55d5e0658 100644 --- a/htdocs/theme/eldy/eldy.css.php +++ b/htdocs/theme/eldy/eldy.css.php @@ -692,6 +692,9 @@ a.tabimage { white-space: nowrap; } +td.tab { + background: #dee7ec; +} /* ============================================================================== */ /* Boutons actions */