diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index f61fdebd14b..76bb3fd7f5f 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2009 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 @@ -15,18 +15,15 @@ * 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/comm/remise.php - \ingroup commercial - \brief Onglet remise de la societe - \version $Revision$ -*/ - + * \file htdocs/comm/remise.php + * \ingroup societe + * \brief Onglet remise de la societe + * \version $Id$ + */ + require_once("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); @@ -35,17 +32,24 @@ $langs->load("companies"); $langs->load("orders"); $langs->load("bills"); +$_socid = $_GET["id"]; +// Security check +if ($user->societe_id > 0) +{ + $_socid = $user->societe_id; +} + if ($_POST["action"] == 'setremise') { - $soc = New Societe($db); - $soc->fetch($_GET["id"]); - $result=$soc->set_remise_client($_POST["remise"],$_POST["note"],$user); + $soc = New Societe($db); + $soc->fetch($_GET["id"]); + $result=$soc->set_remise_client($_POST["remise"],$_POST["note"],$user); if ($result > 0) - { - Header("Location: remise.php?id=".$_GET["id"]); - exit; + { + Header("Location: remise.php?id=".$_GET["id"]); + exit; } else { @@ -54,120 +58,123 @@ if ($_POST["action"] == 'setremise') } +/* + * View + */ + +$form=new Form($db); + llxHeader(); -$_socid = $_GET["id"]; - - -// Sécurité si un client essaye d'accéder à une autre fiche que la sienne -if ($user->societe_id > 0) -{ - $_socid = $user->societe_id; -} - /********************************************************************************* * * Mode fiche * - *********************************************************************************/ + *********************************************************************************/ if ($_socid > 0) { // On recupere les donnees societes par l'objet $objsoc = new Societe($db); $objsoc->id=$_socid; $objsoc->fetch($_socid,$to); - + if ($errmesg) { print '
'.$errmesg.'

'; } - + /* * Affichage onglets */ $head = societe_prepare_head($objsoc); - dol_fiche_head($head, 'relativediscount', $objsoc->nom); + dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty")); - /* - * - * - */ - print '
'; - print ''; - print ''; - print ''; - print ''; - - /* - * Liste de l'historique des avoirs - */ - $sql = "SELECT rc.rowid,rc.remise_client,rc.note,".$db->pdate("rc.datec")." as dc,"; - $sql.= " u.login, u.rowid as user_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE rc.fk_soc =". $objsoc->id; - $sql.= " AND u.rowid = rc.fk_user_author"; - $sql.= " ORDER BY rc.datec DESC"; - - $resql=$db->query($sql); - if ($resql) - { - print '
'; - print ''; + /* + * + * + */ + print ''; + print ''; + print ''; + print '
'; + print '"; - print '
'; + print ''; - // Remise - print '"; + // Name + print ''; + print ''; - // Nouvelle valeur - print ''; + // Remise + print '"; - // Motif/Note - print ''; + // Nouvelle valeur + print ''; - print ''; + // Motif/Note + print ''; - print "
'; - print $langs->trans("CustomerRelativeDiscount").''.$objsoc->remise_client."%
'.$langs->trans('Name').''; + print $form->showrefnav($objsoc,'id','',1,'rowid','nom'); + print '
'; - print $langs->trans("NewValue").'%
'; + print $langs->trans("CustomerRelativeDiscount").''.$objsoc->remise_client."%
'; - print $langs->trans("NoteReason").'
'; + print $langs->trans("NewValue").'%
'; + print $langs->trans("NoteReason").'
"; - print "
'; - print ""; - - print "\n"; - print '
'; + print '
'; - $tag = !$tag; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i = 0 ; - $num = $db->num_rows($resql); - - while ($i < $num ) - { - $obj = $db->fetch_object($resql); - $tag = !$tag; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - $db->free($resql); print "
'.$langs->trans("Date").''.$langs->trans("CustomerRelativeDiscountShort").''.$langs->trans("NoteReason").''.$langs->trans("User").'
'.dol_print_date($obj->dc,"dayhour").''.$obj->remise_client.' %'.$obj->note.''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'
"; - } - else - { - dol_print_error($db); - } + print ""; + print ''; + print ""; + + print "\n"; + print '
'; + + + /* + * Liste de l'historique des avoirs + */ + $sql = "SELECT rc.rowid,rc.remise_client,rc.note,".$db->pdate("rc.datec")." as dc,"; + $sql.= " u.login, u.rowid as user_id"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE rc.fk_soc =". $objsoc->id; + $sql.= " AND u.rowid = rc.fk_user_author"; + $sql.= " ORDER BY rc.datec DESC"; + + $resql=$db->query($sql); + if ($resql) + { + print ''; + $tag = !$tag; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i = 0 ; + $num = $db->num_rows($resql); + + while ($i < $num ) + { + $obj = $db->fetch_object($resql); + $tag = !$tag; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + $db->free($resql); + print "
'.$langs->trans("Date").''.$langs->trans("CustomerRelativeDiscountShort").''.$langs->trans("NoteReason").''.$langs->trans("User").'
'.dol_print_date($obj->dc,"dayhour").''.$obj->remise_client.' %'.$obj->note.''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'
"; + } + else + { + dol_print_error($db); + } } diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index d801e111263..980093e0bee 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -20,7 +20,7 @@ /** * \file htdocs/comm/remx.php - * \ingroup commercial, invoice + * \ingroup societe * \brief Page to edit absolute discounts for a customer * \version $Id$ */ diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 217d6a57c22..e0ae6bf4a2c 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -61,7 +61,7 @@ print ''; print '
'; /* - * Zone recherche + * Search form */ $var=false; print ''; @@ -69,7 +69,7 @@ print ''; print ''; print ''; print ''; +print $langs->trans("Ref").':'; print ''; print ''; print "
'.$langs->trans("SearchOrder").'
'; -print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; @@ -116,69 +116,6 @@ if ($conf->commande->enabled) } } -/* - * Orders to process - */ -if ($conf->commande->enabled) -{ - $sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid"; - $sql.=" FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " AND c.fk_statut = 1"; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= " ORDER BY c.rowid DESC"; - - if ( $db->query($sql) ) - { - print ''; - print ''; - print ''; - - $num = $db->num_rows(); - if ($num) - { - $i = 0; - $var = True; - while ($i < $num) - { - $var=!$var; - $obj = $db->fetch_object(); - print ""; - print ''; - print ''; - $i++; - } - } - - print "
'.$langs->trans("OrdersToProcess").'
'; - - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; - - print ''; - print ''; - - print ''; - - print '
'; - print $commandestatic->getNomUrl(1); - print ''; - print ' '; - print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); - print '
'; - - print '
'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).'

"; - } -} - print '
'; @@ -253,7 +190,76 @@ if ($resql) /* - * Commandes en cours + * Orders to process + */ +if ($conf->commande->enabled) +{ + $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom, s.rowid as socid"; + $sql.=" FROM ".MAIN_DB_PREFIX."commande as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 1"; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " ORDER BY c.rowid DESC"; + + if ( $db->query($sql) ) + { + $num = $db->num_rows(); + + print ''; + print ''; + print ''; + + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object(); + print ""; + print ''; + + print ''; + + print ''; + + print ''; + $i++; + } + } + + print "
'.$langs->trans("OrdersToProcess").' ('.$num.')
'; + + $commandestatic->id=$obj->rowid; + $commandestatic->ref=$obj->ref; + + print ''; + print ''; + + print ''; + + print '
'; + print $commandestatic->getNomUrl(1); + print ''; + print ' '; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); + print '
'; + + print '
'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).''.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,5).'

"; + } +} + +/* + * Commandes en cours d'expedition */ if ($conf->commande->enabled) { @@ -274,7 +280,7 @@ if ($conf->commande->enabled) print ''; print ''; - print ''; + print ''; if ($num) { @@ -309,7 +315,9 @@ if ($conf->commande->enabled) print ''; print ''; + print ''; + print ''; $i++; } diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php index ba8b6cee366..3c5ac5a5d42 100644 --- a/htdocs/commande/liste.php +++ b/htdocs/commande/liste.php @@ -113,10 +113,6 @@ if ($_GET['year'] > 0) { $sql.= " AND date_format(c.date_commande, '%Y') = $year"; } -if (strlen($_POST['sf_ref']) > 0) -{ - $sql.= " AND c.ref like '%".addslashes($_POST['sf_ref']) . "%'"; -} if (!empty($snom)) { $sql.= ' AND s.nom like \'%'.addslashes($snom).'%\''; diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index d5c893017b6..ea5dcd7ec5d 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -210,22 +210,29 @@ class Contrat extends CommonObject } } + if ($this->statut == 0) + { + $result=$this->validate($user,$langs,$conf); + if ($result < 0) $ok=false; + } + if ($ok) { $this->db->commit(); } else { - dol_print_error($db,'Failed to update contrat_det'); + dol_print_error($db,'Error in cloture function'); $this->db->rollback(); } } /** - * \brief Valide un contrat - * \param user Objet User qui valide - * \param langs Environnement langue de l'utilisateur - * \param conf Environnement de configuration lors de l'op�ration + * \brief Validate a contract + * \param user Objet User + * \param langs Environnement langue de l'utilisateur + * \param conf Environnement de configuration lors de l'operation + * \return int <0 if KO, >0 if OK */ function validate($user,$langs,$conf) { @@ -1072,8 +1079,8 @@ class Contrat extends CommonObject $text.=' '.$langs->trans("Services"); $text.=':     '; $text.=$this->nbofserviceswait.' '.$line->LibStatut(0,3).'   '; - $text.=$this->nbofservicesopened.' '.$line->LibStatut(4,3,false).'   '; - $text.=$this->nbofservicesexpired.' '.$line->LibStatut(4,3,true).'   '; + $text.=$this->nbofservicesopened.' '.$line->LibStatut(4,3,0).'   '; + $text.=$this->nbofservicesexpired.' '.$line->LibStatut(4,3,1).'   '; $text.=$this->nbofservicesclosed.' '.$line->LibStatut(5,3); return $text; } @@ -1417,60 +1424,66 @@ class ContratLigne */ function getLibStatut($mode) { - return $this->LibStatut($this->statut,$mode,(isset($this->date_fin_validite) && $this->date_fin_validite < gmmktime())); + return $this->LibStatut($this->statut,$mode,(isset($this->date_fin_validite)?($this->date_fin_validite < dol_now('tzref')?1:0):-1)); } /** * \brief Return label of a contract line status * \param statut id statut * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * \param expired true=Expired + * \param expired 0=Not expired, 1=Expired, -1=Both or unknown * \return string Libelle */ - function LibStatut($statut,$mode,$expired=false) + function LibStatut($statut,$mode,$expired=-1) { global $langs; $langs->load("contracts"); if ($mode == 0) { if ($statut == 0) { return $langs->trans("ServiceStatusInitial"); } - if ($statut == 4 && ! $expired) { return $langs->trans("ServiceStatusRunning"); } - if ($statut == 4 && $expired) { return $langs->trans("ServiceStatusLate"); } + if ($statut == 4 && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } + if ($statut == 4 && $expired == 0) { return $langs->trans("ServiceStatusNotLate"); } + if ($statut == 4 && $expired == 1) { return $langs->trans("ServiceStatusLate"); } if ($statut == 5) { return $langs->trans("ServiceStatusClosed"); } } if ($mode == 1) { if ($statut == 0) { return $langs->trans("ServiceStatusInitial"); } - if ($statut == 4 && ! $expired) { return $langs->trans("ServiceStatusRunning"); } - if ($statut == 4 && $expired) { return $langs->trans("ServiceStatusLateShort"); } + if ($statut == 4 && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } + if ($statut == 4 && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort"); } + if ($statut == 4 && $expired == 1) { return $langs->trans("ServiceStatusLateShort"); } if ($statut == 5) { return $langs->trans("ServiceStatusClosed"); } } if ($mode == 2) { if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); } - if ($statut == 4 && ! $expired) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } - if ($statut == 4 && $expired) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLateShort"); } + if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } + if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLateShort"); } + if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLateShort"); } if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } } if ($mode == 3) { if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0'); } - if ($statut == 4 && ! $expired) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4'); } - if ($statut == 4 && $expired) { return img_picto($langs->trans('ServiceStatusLate'),'statut3'); } + if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4'); } + if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4'); } + if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3'); } if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6'); } } if ($mode == 4) { if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); } - if ($statut == 4 && ! $expired) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } - if ($statut == 4 && $expired) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLate"); } + if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } + if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLate"); } + if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLate"); } if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } } if ($mode == 5) { if ($statut == 0) { return $langs->trans("ServiceStatusInitial").' '.img_picto($langs->trans('ServiceStatusInitial'),'statut0'); } - if ($statut == 4 && ! $expired) { return $langs->trans("ServiceStatusRunning").' '.img_picto($langs->trans('ServiceStatusRunning'),'statut4'); } - if ($statut == 4 && $expired) { return $langs->trans("ServiceStatusLateShort").' '.img_picto($langs->trans('ServiceStatusLate'),'statut3'); } + if ($statut == 4 && $expired == -1) { return $langs->trans("ServiceStatusRunning").' '.img_picto($langs->trans('ServiceStatusRunning'),'statut4'); } + if ($statut == 4 && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort").' '.img_picto($langs->trans('ServiceStatusNotLateShort'),'statut4'); } + if ($statut == 4 && $expired == 1) { return $langs->trans("ServiceStatusLateShort").' '.img_picto($langs->trans('ServiceStatusLate'),'statut3'); } if ($statut == 5) { return $langs->trans("ServiceStatusClosed").' '.img_picto($langs->trans('ServiceStatusClosed'),'statut6'); } } } diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 93a9a1b9ed8..ca80c2e3634 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -367,6 +367,7 @@ if ($_REQUEST["action"] == 'confirm_valid' && $_REQUEST["confirm"] == 'yes' && $ $result = $contrat->validate($user,$langs,$conf); } +// Close all lines if ($_REQUEST["action"] == 'confirm_close' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->creer) { $contrat = new Contrat($db); @@ -751,7 +752,7 @@ else echo '
'; $servicepos=(isset($_REQUEST["servicepos"])?$_REQUEST["servicepos"]:1); - $colorb='333333'; + $colorb='666666'; $arrayothercontracts=$contrat->getListOfContracts('others'); @@ -760,7 +761,7 @@ else */ // Title line for service - print '
'.$langs->trans("OnProcessOrders").' ('.$num.')
'.$langs->trans("OnProcessOrders").' ('.$num.')
'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,5).'
'; // Array with (n*2)+1 lines + print '
'; // Array with (n*2)+1 lines $cursorline=1; while ($cursorline <= $nbofservices) { @@ -771,7 +772,7 @@ else print '
'; // Area with common detail of line - print ''; + print '
'; $sql = "SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.description, cd.price_ht, cd.qty,"; $sql.= " cd.tva_tx, cd.remise_percent, cd.info_bits, cd.subprice,"; @@ -959,7 +960,7 @@ else if ($_REQUEST["action"] == 'deleteline' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $contrat->lignes[$cursorline-1]->id == $_GET["rowid"]) { $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 '
'; + if ($ret == 'html') print '
'; } /* @@ -980,7 +981,7 @@ else array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid)); $html->form_confirm($_SERVER["PHP_SELF"]."?id=".$contrat->id."&lineid=".$_GET["rowid"],$langs->trans("MoveToAnotherContract"),$langs->trans("ConfirmMoveToAnotherContract"),"confirm_move",$formquestion); - print '
'; + print '
'; } /* @@ -993,7 +994,7 @@ else $dateactend = dol_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); $comment = $_POST["comment"]; $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 '
'; + print '
'; } /* @@ -1006,14 +1007,14 @@ else $dateactend = dol_mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); $comment = $_POST["comment"]; $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 '
'; + print '
'; } // Area with status and activation info of line if ($contrat->statut > 0) { - print ''; + print '
'; print ''; print ''; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 1a90c8532f8..8a2622d80b6 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -63,23 +63,10 @@ print '
'.$langs->trans("ServiceStatus").': '.$contrat->lignes[$cursorline-1]->getLibStatut(4).'
'; print '
'; -// Legend -$var=false; -print ''; -print ''; -print ''; -print '
'.$langs->trans("ServicesLegend").'
'; -print $staticcontratligne->LibStatut(0,4).'
'; -print $staticcontratligne->LibStatut(4,4,false).'
'; -print $staticcontratligne->LibStatut(4,4,true).'
'; -print $staticcontratligne->LibStatut(5,4).'
'; -print '
'; -print "
"; - // Search contract if ($conf->contrat->enabled) { - $var=false; + $var=false; print '
'; print ''; print ''; @@ -93,6 +80,86 @@ if ($conf->contrat->enabled) print "
"; } +/* + * Legends / Status + */ +$nb=array(); +// Search by status (except expired) +$sql = "SELECT count(cd.rowid), cd.statut"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid"; +$sql.= " AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= ".$db->idate(dol_now('tzref')).')))'; +$sql.= " AND s.entity = ".$conf->entity; +if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql.= " GROUP BY cd.statut"; +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) + { + $row = $db->fetch_row($resql); + $nb[$row[1]]=$row[0]; + $i++; + } + $db->free($resql); +} +else +{ + dol_print_error($db); +} +// Search by status (only expired) +$sql = "SELECT count(cd.rowid), cd.statut"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid"; +$sql.= " AND (cd.statut = 4 AND cd.date_fin_validite < ".$db->idate(dol_now('tzref')).')'; +$sql.= " AND s.entity = ".$conf->entity; +if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql.= " GROUP BY cd.statut"; +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) + { + $row = $db->fetch_row($resql); + $nb[$row[1].true]=$row[0]; + $i++; + } + $db->free($resql); +} +else +{ + dol_print_error($db); +} +print '
'; +print ''; +print ''; +print "\n"; +$var=true; +$listofstatus=array(0,4,4,5); $bool=false; +foreach($listofstatus as $status) +{ + $var=!$var; + print ""; + print ''; + print ''; + if ($status==4 && $bool==false) $bool=true; + else $bool=false; +} +print "\n"; +print "
'.$langs->trans("Status").''.$langs->trans("Nb").'
'.$staticcontratligne->LibStatut($status,0,($bool?1:0)).''.($nb[$status.$bool]?$nb[$status.$bool]:0).' '.$staticcontratligne->LibStatut($status,3,($bool?1:0)).'

"; + /** * Draft contratcs */ @@ -186,52 +253,52 @@ dol_syslog("contrat/index.php sql=".$sql, LOG_DEBUG); $result=$db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; + $num = $db->num_rows($result); + $i = 0; - print ''; + print '
'; - print ''; - print ''; - //print ''; - print ''; - print "\n"; + print ''; + print ''; + //print ''; + print ''; + print "\n"; - $var=True; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $var=!$var; + $var=True; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var=!$var; - print ""; - print '"; + print ''; - print ''; + print ''; - print ''; - //print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $i++; - } - $db->free($result); + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $i++; + } + $db->free($result); - print "
'.$langs->trans("LastContracts",5).''.$langs->trans("DateModification").''.$langs->trans("Status").''.$langs->trans("Services").'
'.$langs->trans("LastContracts",5).''.$langs->trans("DateModification").''.$langs->trans("Status").''.$langs->trans("Services").'
'; + print "
'; $staticcontrat->ref=($obj->ref?$obj->ref:$obj->cid); $staticcontrat->id=$obj->cid; print $staticcontrat->getNomUrl(1,16); - if ($obj->nb_late) print img_warning($langs->trans("Late")); - print ''; + if ($obj->nb_late) print img_warning($langs->trans("Late")); + print ''; $staticcompany->id=$obj->socid; $staticcompany->nom=$obj->nom; print $staticcompany->getNomUrl(1,'',20); print ''.dol_print_date($obj->tms,'dayhour').''.$staticcontrat->LibStatut($obj->statut,2).''.($obj->nb_initial>0 ? $obj->nb_initial.$staticcontratligne->LibStatut(0,3):'').''.($obj->nb_running>0 ? $obj->nb_running.$staticcontratligne->LibStatut(4,3,false):'').''.($obj->nb_expired>0 ? $obj->nb_expired.$staticcontratligne->LibStatut(4,3,true):'').''.($obj->nb_closed>0 ? $obj->nb_closed.$staticcontratligne->LibStatut(5,3):'').'
'.dol_print_date($obj->tms,'dayhour').''.$staticcontrat->LibStatut($obj->statut,2).''.($obj->nb_initial>0 ? $obj->nb_initial.$staticcontratligne->LibStatut(0,3):'').''.($obj->nb_running>0 ? $obj->nb_running.$staticcontratligne->LibStatut(4,3,0):'').''.($obj->nb_expired>0 ? $obj->nb_expired.$staticcontratligne->LibStatut(4,3,1):'').''.($obj->nb_closed>0 ? $obj->nb_closed.$staticcontratligne->LibStatut(5,3):'').'
"; + print "
"; } else { - dol_print_error($db); + dol_print_error($db); } print '
'; @@ -254,49 +321,49 @@ $sql.= " ORDER BY cd.tms DESC"; if ( $db->query($sql) ) { - $num = $db->num_rows(); - $i = 0; + $num = $db->num_rows(); + $i = 0; - print ''; + print '
'; - print ''; - print "\n"; + print ''; + print "\n"; - $var=True; - while ($i < $num) - { - $obj = $db->fetch_object(); - $var=!$var; - print ""; + $var=True; + while ($i < $num) + { + $obj = $db->fetch_object(); + $var=!$var; + print ""; - print ''; - print ''; - else print ' '.dol_trunc($obj->note,20).''; - print ''; + else print ' '.dol_trunc($obj->note,20).''; + print ''; - print ''; - print "\n"; - $i++; - } - $db->free(); + print ''; + print "\n"; + $i++; + } + $db->free(); - print "
'.$langs->trans("NotActivatedServices").'
'.$langs->trans("NotActivatedServices").'
'; + print ''; $staticcontrat->ref=($obj->ref?$obj->ref:$obj->fk_contrat); $staticcontrat->id=$obj->fk_contrat; print $staticcontrat->getNomUrl(1,16); print ''; + print ''; print ''.img_object($langs->trans("ShowService"),"service"); - if ($obj->label) print ' '.dol_trunc($obj->label,20).''; + if ($obj->label) print ' '.dol_trunc($obj->label,20).''; $staticcompany->id=$obj->fk_soc; $staticcompany->nom=$obj->nom; print $staticcompany->getNomUrl(1,'',20); print ''; - print $staticcontratligne->LibStatut($obj->statut,3); - print '
'; + print $staticcontratligne->LibStatut($obj->statut,3); + print '
"; + print "
"; } else { - dol_print_error($db); + dol_print_error($db); } print '
'; @@ -321,49 +388,49 @@ $sql.= " ORDER BY cd.tms DESC"; $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - print ''; + print '
'; - print ''; - print "\n"; + print ''; + print "\n"; - $var=True; - while ($i < min($num,$max)) - { - $obj = $db->fetch_object($resql); - $var=!$var; - print ""; - print '"; + print ''; - print ''; - else print ' '.dol_trunc($obj->note,20).''; - print ''; + print ''; + else print ' '.dol_trunc($obj->note,20).''; + print ''; - print ''; - print "\n"; - $i++; - } - $db->free(); + print ''; + print "\n"; + $i++; + } + $db->free(); - print "
'.$langs->trans("LastModifiedServices",min($num,$max)).'
'.$langs->trans("LastModifiedServices",min($num,$max)).'
'; + $var=True; + while ($i < min($num,$max)) + { + $obj = $db->fetch_object($resql); + $var=!$var; + print "
'; $staticcontrat->ref=($obj->ref?$obj->ref:$obj->fk_contrat); $staticcontrat->id=$obj->fk_contrat; print $staticcontrat->getNomUrl(1,16); - //if (1 == 1) print img_warning($langs->trans("Late")); - print ''.img_object($langs->trans("ShowService"),"service"); - if ($obj->label) print ' '.dol_trunc($obj->label,20).''; + //if (1 == 1) print img_warning($langs->trans("Late")); + print ''.img_object($langs->trans("ShowService"),"service"); + if ($obj->label) print ' '.dol_trunc($obj->label,20).''; $staticcompany->id=$obj->fk_soc; $staticcompany->nom=$obj->nom; print $staticcompany->getNomUrl(1,'',20); print ''; - $dateend=$db->jdate($obj->date_fin_validite); - print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now)); - print '
'; + $dateend=$db->jdate($obj->date_fin_validite); + print $staticcontratligne->LibStatut($obj->statut, 3, ($dateend && $dateend < $now)?1:0); + print '
"; + print "
"; } else { - dol_print_error($db); + dol_print_error($db); } print ''; diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index 8da71fa6591..926de196648 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -107,8 +107,8 @@ if ($resql) print_liste_field_titre($langs->trans("DateContract"), $_SERVER["PHP_SELF"], "c.date_contrat","","$param",'align="center"',$sortfield,$sortorder); //print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "c.statut","","$param",'align="center"',$sortfield,$sortorder); print ''.$staticcontratligne->LibStatut(0,3).''; - print ''.$staticcontratligne->LibStatut(4,3,false).''; - print ''.$staticcontratligne->LibStatut(4,3,true).''; + print ''.$staticcontratligne->LibStatut(4,3,0).''; + print ''.$staticcontratligne->LibStatut(4,3,1).''; print ''.$staticcontratligne->LibStatut(5,3).''; print "\n"; diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 33681479fa6..80433ee9339 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -19,11 +19,11 @@ */ /** - \file htdocs/contrat/services.php - \ingroup contrat - \brief Page liste des contrats en service - \version $Id$ -*/ + * \file htdocs/contrat/services.php + * \ingroup contrat + * \brief Page liste des contrats en service + * \version $Id$ + */ require("./pre.inc.php"); require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); @@ -64,7 +64,7 @@ $companystatic=new Societe($db); * View */ -$now=gmmktime(); +$now=dol_now('tzref'); $form=new Form($db); @@ -91,7 +91,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc if ($mode == "0") $sql.= " AND cd.statut = 0"; if ($mode == "4") $sql.= " AND cd.statut = 4"; if ($mode == "5") $sql.= " AND cd.statut = 5"; -if ($filter == "expired") $sql.= " AND date_fin_validite < ".$db->idate(mktime()); +if ($filter == "expired") $sql.= " AND date_fin_validite < ".$now; if ($search_nom) $sql.= " AND s.nom like '%".addslashes($search_nom)."%'"; if ($search_contract) $sql.= " AND c.rowid = '".addslashes($search_contract)."'"; if ($search_service) $sql.= " AND (p.ref like '%".addslashes($search_service)."%' OR p.description like '%".addslashes($search_service)."%')"; @@ -108,143 +108,143 @@ dol_syslog("contrat/services.php sql=".$sql); $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $param=''; - if ($search_contract) $param.='&search_contract='.urlencode($search_contract); - if ($search_nom) $param.='&search_nom='.urlencode($search_nom); - if ($search_service) $param.='&search_service='.urlencode($search_service); - if ($mode) $param.='&mode='.$mode; - if ($filter) $param.='&filter='.$filter; - if (! empty($_REQUEST['filter_op1']) && $_REQUEST['filter_op1'] != -1) $param.='&filter_op1='.urlencode($_REQUEST['filter_op1']); - if (! empty($_REQUEST['filter_op2']) && $_REQUEST['filter_op2'] != -1) $param.='&filter_op2='.urlencode($_REQUEST['filter_op2']); - if ($filter_date1 != '') $param.='&op1day='.$_REQUEST['op1day'].'&op1month='.$_REQUEST['op1month'].'&op1year='.$_REQUEST['op1year']; - if ($filter_date2 != '') $param.='&op2day='.$_REQUEST['op2day'].'&op2month='.$_REQUEST['op2month'].'&op2year='.$_REQUEST['op2year']; + $param=''; + if ($search_contract) $param.='&search_contract='.urlencode($search_contract); + if ($search_nom) $param.='&search_nom='.urlencode($search_nom); + if ($search_service) $param.='&search_service='.urlencode($search_service); + if ($mode) $param.='&mode='.$mode; + if ($filter) $param.='&filter='.$filter; + if (! empty($_REQUEST['filter_op1']) && $_REQUEST['filter_op1'] != -1) $param.='&filter_op1='.urlencode($_REQUEST['filter_op1']); + if (! empty($_REQUEST['filter_op2']) && $_REQUEST['filter_op2'] != -1) $param.='&filter_op2='.urlencode($_REQUEST['filter_op2']); + if ($filter_date1 != '') $param.='&op1day='.$_REQUEST['op1day'].'&op1month='.$_REQUEST['op1month'].'&op1year='.$_REQUEST['op1year']; + if ($filter_date2 != '') $param.='&op2day='.$_REQUEST['op2day'].'&op2month='.$_REQUEST['op2month'].'&op2year='.$_REQUEST['op2year']; - print_barre_liste($langs->trans("ListOfServices"), $page, "services.php", $param, $sortfield, $sortorder,'',$num); + print_barre_liste($langs->trans("ListOfServices"), $page, "services.php", $param, $sortfield, $sortorder,'',$num); - print ''; + print '
'; - print ''; - print_liste_field_titre($langs->trans("Contract"),"services.php", "c.rowid",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Service"),"services.php", "p.description",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Company"),"services.php", "s.nom",$param,"","",$sortfield,$sortorder); - // Date debut - if ($mode == "0") print_liste_field_titre($langs->trans("DateStartPlannedShort"),"services.php", "cd.date_ouverture_prevue",$param,'',' align="center"',$sortfield,$sortorder); - if ($mode == "" || $mode > 0) print_liste_field_titre($langs->trans("DateStartRealShort"),"services.php", "cd.date_ouverture",$param,'',' align="center"',$sortfield,$sortorder); - // Date fin - if ($mode == "" || $mode < 5) print_liste_field_titre($langs->trans("DateEndPlannedShort"),"services.php", "cd.date_fin_validite",$param,'',' align="center"',$sortfield,$sortorder); - else print_liste_field_titre($langs->trans("DateEndRealShort"),"services.php", "cd.date_cloture",$param,'',' align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),"services.php", "cd.statut,c.statut",$param,"","align=\"right\"",$sortfield,$sortorder); - print "\n"; + print ''; + print_liste_field_titre($langs->trans("Contract"),"services.php", "c.rowid",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Service"),"services.php", "p.description",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),"services.php", "s.nom",$param,"","",$sortfield,$sortorder); + // Date debut + if ($mode == "0") print_liste_field_titre($langs->trans("DateStartPlannedShort"),"services.php", "cd.date_ouverture_prevue",$param,'',' align="center"',$sortfield,$sortorder); + if ($mode == "" || $mode > 0) print_liste_field_titre($langs->trans("DateStartRealShort"),"services.php", "cd.date_ouverture",$param,'',' align="center"',$sortfield,$sortorder); + // Date fin + if ($mode == "" || $mode < 5) print_liste_field_titre($langs->trans("DateEndPlannedShort"),"services.php", "cd.date_fin_validite",$param,'',' align="center"',$sortfield,$sortorder); + else print_liste_field_titre($langs->trans("DateEndRealShort"),"services.php", "cd.date_cloture",$param,'',' align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),"services.php", "cd.statut,c.statut",$param,"","align=\"right\"",$sortfield,$sortorder); + print "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print '"; - print "\n"; - print ''; + print ' '; + $filter_date1=dol_mktime(0,0,0,$_REQUEST['op1month'],$_REQUEST['op1day'],$_REQUEST['"op1year']); + print $form->select_date($filter_date1,'op1',0,0,1); + print ''; + print ''; + print '"; + print "\n"; + print ''; - $var=True; - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); - $var=!$var; - print ""; - print ''; + $var=True; + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); + $var=!$var; + print ""; + print ''; - // Service - print ''; + // Service + print ''; - // Third party - print ''; - // Start date - if ($mode == "0") { - print ''; - } - if ($mode == "" || $mode > 0) print ''; - // Date fin - if ($mode == "" || $mode < 5) print ''; - print ''; - print "\n"; - $i++; - } - $db->free($resql); + // Start date + if ($mode == "0") { + print ''; + } + if ($mode == "" || $mode > 0) print ''; + // Date fin + if ($mode == "" || $mode < 5) print ''; + print ''; + print "\n"; + $i++; + } + $db->free($resql); - print "
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $arrayofoperators=array('<'=>'<','>'=>'>'); + print ''; + print ''; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $arrayofoperators=array('<'=>'<','>'=>'>'); print $form->select_array('filter_op1',$arrayofoperators,$_REQUEST['filter_op1'],1); - print ' '; - $filter_date1=dol_mktime(0,0,0,$_REQUEST['op1month'],$_REQUEST['op1day'],$_REQUEST['"op1year']); - print $form->select_date($filter_date1,'op1',0,0,1); - print ''; - $arrayofoperators=array('<'=>'<','>'=>'>'); - print $form->select_array('filter_op2',$arrayofoperators,$_REQUEST['filter_op2'],1); - print ' '; - $filter_date2=dol_mktime(0,0,0,$_REQUEST['op2month'],$_REQUEST['op2day'],$_REQUEST['op2year']); - print $form->select_date($filter_date2,'op2',0,0,1); - print ''; - print "
'; + $arrayofoperators=array('<'=>'<','>'=>'>'); + print $form->select_array('filter_op2',$arrayofoperators,$_REQUEST['filter_op2'],1); + print ' '; + $filter_date2=dol_mktime(0,0,0,$_REQUEST['op2month'],$_REQUEST['op2day'],$_REQUEST['op2year']); + print $form->select_date($filter_date2,'op2',0,0,1); + print ''; + print "
'; - $contractstatic=new Contrat($db); - $contractstatic->id=$obj->cid; - $contractstatic->ref=$obj->ref?$obj->ref:$obj->cid; - print $contractstatic->getNomUrl(1); - print '
'; + $contractstatic=new Contrat($db); + $contractstatic->id=$obj->cid; + $contractstatic->ref=$obj->ref?$obj->ref:$obj->cid; + print $contractstatic->getNomUrl(1); + print ''; - if ($obj->pid) - { - print ''.img_object($langs->trans("ShowService"),"service").' '.dol_trunc($obj->label,20).''; - } - else - { - print dol_trunc($obj->description,20); - } - print ''; + if ($obj->pid) + { + print ''.img_object($langs->trans("ShowService"),"service").' '.dol_trunc($obj->label,20).''; + } + else + { + print dol_trunc($obj->description,20); + } + print ''; - $companystatic->id=$obj->socid; - $companystatic->nom=$obj->nom; - $companystatic->client=1; + // Third party + print ''; + $companystatic->id=$obj->socid; + $companystatic->nom=$obj->nom; + $companystatic->client=1; print $companystatic->getNomUrl(1,'customer',32); print ''; - print ($obj->date_ouverture_prevue?dol_print_date($obj->date_ouverture_prevue):' '); - if ($obj->date_ouverture_prevue && ($obj->date_ouverture_prevue < ($now - $conf->contrat->services->inactifs->warning_delay))) - print img_picto($langs->trans("Late"),"warning"); - else print '    '; - print ''.($obj->date_ouverture?dol_print_date($obj->date_ouverture):' ').''.($obj->date_fin_validite?dol_print_date($obj->date_fin_validite):' '); - else print ''.dol_print_date($obj->date_cloture); - // Icone warning - if ($obj->date_fin_validite && $obj->date_fin_validite < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) print img_warning($langs->trans("Late")); - else print '    '; - print ''; - if ($obj->cstatut == 0) - { - print $contractstatic->LibStatut(0,5,($obj->date_fin_validite && $obj->date_fin_validite < $now)); - } - else - { - print ''; - print $staticcontratligne->LibStatut($obj->statut,5,($obj->date_fin_validite && $obj->date_fin_validite < $now)); - print ''; - } - print '
'; + print ($obj->date_ouverture_prevue?dol_print_date($obj->date_ouverture_prevue):' '); + if ($obj->date_ouverture_prevue && ($obj->date_ouverture_prevue < ($now - $conf->contrat->services->inactifs->warning_delay))) + print img_picto($langs->trans("Late"),"warning"); + else print '    '; + print ''.($obj->date_ouverture?dol_print_date($obj->date_ouverture):' ').''.($obj->date_fin_validite?dol_print_date($obj->date_fin_validite):' '); + else print ''.dol_print_date($obj->date_cloture); + // Icone warning + if ($obj->date_fin_validite && $obj->date_fin_validite < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) print img_warning($langs->trans("Late")); + else print '    '; + print ''; + if ($obj->cstatut == 0) + { + print $contractstatic->LibStatut(0,5,($obj->date_fin_validite && $obj->date_fin_validite < $now)); + } + else + { + print ''; + print $staticcontratligne->LibStatut($obj->statut,5,($obj->date_fin_validite && $obj->date_fin_validite < $now)?1:0); + print ''; + } + print '
"; + print ""; } else { - dol_print_error($db); + dol_print_error($db); } diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 1f31c3c5f04..cba756eb8c1 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -48,6 +48,26 @@ print_barre_liste($langs->trans("SuppliersOrdersArea"), $page, "index.php", "", print ''; print '
'; + +/* + * Search form + */ +$var=false; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "
'.$langs->trans("SearchOrder").'
'; +print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; + + +/* + * Legends / Status + */ + $sql = "SELECT count(cf.rowid), fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; @@ -63,9 +83,9 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - + print ''; - + print ''; print ''; print "\n"; @@ -83,14 +103,55 @@ if ($resql) print "\n"; $i++; } - print "
'.$langs->trans("Status").''.$langs->trans("Nb").'
"; + print "

"; $db->free($resql); } -else +else { dol_print_error($db); } +/* + * Commandes brouillons + */ +if ($conf->fournisseur->enabled) +{ + $sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 0"; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + + if ( $db->query($sql) ) + { + print ''; + print ''; + print ''; + $langs->load("orders"); + $num = $db->num_rows(); + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object(); + print ""; + print '"; + print ''; + $i++; + } + } + print "
'.$langs->trans("DraftOrders").'
'; + print "rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).'

"; + } +} + print ''; @@ -112,7 +173,7 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - + print ''; print ''; print "\n"; @@ -136,7 +197,7 @@ if ($resql) print "
'.$langs->trans("UserWithApproveOrderGrant").'
"; $db->free($resql); } -else +else { dol_print_error($db); } diff --git a/htdocs/fourn/commande/liste.php b/htdocs/fourn/commande/liste.php index 9e679d41043..b0584fc8b0d 100644 --- a/htdocs/fourn/commande/liste.php +++ b/htdocs/fourn/commande/liste.php @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** +/** \file htdocs/fourn/commande/liste.php \ingroup fournisseur \brief Liste des commandes fournisseurs @@ -29,6 +29,10 @@ require("./pre.inc.php"); $langs->load("orders"); +$sref=isset($_GET['search_ref'])?$_GET['search_ref']:$_POST['search_ref']; +$snom=isset($_GET['search_nom'])?$_GET['search_nom']:$_POST['search_nom']; +$sall=isset($_GET['search_all'])?$_GET['search_all']:$_POST['search_all']; + $page = ( is_numeric($_GET["page"]) ? $_GET["page"] : 0 ); $socid = ( is_numeric($_GET["socid"]) ? $_GET["socid"] : 0 ); $sortorder = $_GET["sortorder"]; @@ -74,6 +78,18 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX $sql.= " WHERE cf.fk_soc = s.rowid "; $sql.= " AND s.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +if ($sref) +{ + $sql.= " AND cf.ref like '%".addslashes($sref)."%'"; +} +if ($snom) +{ + $sql.= " AND s.nom like '%".addslashes($snom)."%'"; +} +if ($sall) +{ + $sql.= " AND (cf.ref like '%".addslashes($sall)."%' OR cf.note like '%".addslashes($sall)."%')"; +} if ($socid) $sql.= " AND s.rowid = ".$socid; if (strlen($_GET["statut"])) @@ -81,22 +97,12 @@ if (strlen($_GET["statut"])) $sql .= " AND fk_statut =".$_GET["statut"]; } -if (strlen($_GET["search_ref"])) -{ - $sql .= " AND cf.ref LIKE '%".$_GET["search_ref"]."%'"; -} - -if (strlen($_GET["search_nom"])) -{ - $sql .= " AND s.nom LIKE '%".$_GET["search_nom"]."%'"; -} - $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); if ($resql) { - + $num = $db->num_rows($resql); $i = 0; @@ -113,8 +119,8 @@ if ($resql) print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -132,7 +138,7 @@ if ($resql) // Ref print ''.img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref.''."\n"; - // Société + // Soci�t� print ''.img_object($langs->trans("ShowCompany"),"company").' '; print $obj->nom.''."\n"; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index b0145ceebef..823714061ed 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -1568,7 +1568,7 @@ class Form if ($formquestion) { $more.=''; - $more.=''; + $more.='
'; $more.=''; foreach ($formquestion as $key => $input) { @@ -1691,7 +1691,7 @@ class Form print ''; print ''; print ''; - print '
'.$formquestion['text'].'
'; + print '
'; print ''; @@ -1726,7 +1726,7 @@ class Form print ''; print ''; print ''; - print '
'; select_projects($socid,$selected,$htmlname); print '
'; + print '
'; print ''; @@ -1761,7 +1761,7 @@ class Form print ''; print ''; print ''; - print '
'; $this->select_conditions_paiements($selected,$htmlname,-1,$addempty); print '
'; + print '
'; print ''; @@ -1795,7 +1795,7 @@ class Form print ''; print ''; print ''; - print '
'; print $this->select_date($selected,$htmlname,0,0,1,'form'.$htmlname); print '
'; + print '
'; print ''; @@ -1881,7 +1881,7 @@ class Form print ''; print ''; print ''; - print '
'; $this->select_types_paiements($selected,$htmlname); print '
'; + print '
'; print '
'; $num=$this->select_contacts($societe->id, $selected, $htmlname); if ($num==0) @@ -1925,7 +1925,7 @@ class Form print ''; print ''; print ''; - print ''; + print '
'; print ''; diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index c22eebd8427..0df890becd2 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -13,6 +13,8 @@ ContractStatusValidated=Validated ContractStatusClosed=Closed ServiceStatusInitial=Not running ServiceStatusRunning=Running +ServiceStatusNotLate=Running, not expired +ServiceStatusNotLateShort=Not expired ServiceStatusLate=Running, expired ServiceStatusLateShort=Expired ServiceStatusClosed=Closed diff --git a/htdocs/langs/fr_FR/contracts.lang b/htdocs/langs/fr_FR/contracts.lang index 253141676e4..1c1e9819d22 100644 --- a/htdocs/langs/fr_FR/contracts.lang +++ b/htdocs/langs/fr_FR/contracts.lang @@ -13,6 +13,8 @@ ContractStatusValidated=Validé ContractStatusClosed=Clôturé ServiceStatusInitial=Inactif ServiceStatusRunning=En service +ServiceStatusNotLate=En service, non expiré +ServiceStatusNotLateShort=Non expiré ServiceStatusLate=En service, expiré ServiceStatusLateShort=Expiré ServiceStatusClosed=Fermé
'; $this->select_adresse_livraison($selected, $socid, $htmlname, 1); print '