diff --git a/htdocs/comm/clients.php b/htdocs/comm/clients.php index 3f3ffb185bb..646828ba3d1 100644 --- a/htdocs/comm/clients.php +++ b/htdocs/comm/clients.php @@ -30,9 +30,7 @@ require("./pre.inc.php"); -/* - * Sécurité accés client - */ +// Sécurité accés client if ($user->societe_id > 0) { $action = ''; @@ -44,35 +42,25 @@ $sortorder=$_GET["sortorder"]; $sortfield=$_GET["sortfield"]; if ($page == -1) { $page = 0 ; } - $offset = $conf->liste_limit * $_GET["page"] ; $pageprev = $_GET["page"] - 1; $pagenext = $_GET["page"] + 1; +$search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"]; +$search_ville=isset($_GET["search_ville"])?$_GET["search_ville"]:$_POST["search_ville"]; +$search_code=isset($_GET["search_code"])?$_GET["search_contract"]:$_POST["search_code"]; + $sql = "SELECT s.idp, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm, s.code_client "; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st "; $sql .= " WHERE s.fk_stcomm = st.id AND s.client=1"; -if ($socidp) -{ - $sql .= " AND s.idp = $socidp"; -} +if ($socidp) $sql .= " AND s.idp = $socidp"; +if ($user->societe_id) $sql .= " AND s.idp = " .$user->societe_id; -if ($_GET["search_nom"]) -{ - $sql .= " AND s.nom like '%".strtolower($_GET["search_nom"])."%'"; -} - -if ($_GET["search_code"]) -{ - $sql .= " AND s.code_client like '%".strtolower($_GET["search_code"])."%'"; -} - -if ($user->societe_id) -{ - $sql .= " AND s.idp = " .$user->societe_id; -} +if ($search_nom) $sql .= " AND s.nom like '%".strtolower($search_nom)."%'"; +if ($search_ville) $sql .= " AND s.ville like '%".strtolower($search_ville)."%'"; +if ($search_code) $sql .= " AND s.code_client like '%".strtolower($search_code)."%'"; if ($socname) { @@ -98,7 +86,7 @@ if ($result) $i = 0; - $addu = "&page=$page&begin=$begin&search_nom=".$_GET["search_nom"]; + $addu = "&search_nom=".$search_nom."&search_code=".$search_code."&search_ville=".$search_ville; print ''; print ''; print_liste_field_titre($langs->trans("Company"),"clients.php","s.nom",$addu,"","",$sortfield); @@ -111,15 +99,17 @@ if ($result) print ''; print ''; print ''; print '"; print "\n"; - + print ''; + $var=True; while ($i < min($num,$conf->liste_limit)) @@ -159,5 +149,5 @@ else $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index c16653b5f9f..e06583b6a76 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -32,6 +32,7 @@ require_once("./pre.inc.php"); require_once("../contact.class.php"); require_once("../actioncomm.class.php"); +require_once("../commande/commande.class.php"); require_once("../contrat/contrat.class.php"); $langs->load("companies"); @@ -245,8 +246,8 @@ if ($_socid > 0) print ''; - print ''; - print ''; + print ''; + print ''; print '"; @@ -264,18 +265,35 @@ if ($_socid > 0) print ''; print '"; - print ''; + print '
'; - print ''; - print ' '; + print ''; print ''; - print ''; + print ''; + print ''; + print ''; print ' '; print "
'.$langs->trans('Country').''.$objsoc->pays.'
'.$langs->trans('Phone').''.dolibarr_print_phone($objsoc->tel).''.$langs->trans('Fax').''.dolibarr_print_phone($objsoc->fax).'
'.$langs->trans('Phone').''.dolibarr_print_phone($objsoc->tel,$objsoc->pays_code).''.$langs->trans('Fax').''.dolibarr_print_phone($objsoc->fax,$objsoc->pays_code).'
'.$langs->trans("Web")."url\">".$objsoc->url." 
'.$langs->trans("Type").''.$objsoc->typent.''.$langs->trans("Staff").''.$objsoc->effectif.'
'; - print $langs->trans("CustomerDiscount").''.$objsoc->remise_client." %'; - print img_edit($langs->trans("Modify")); - print ""; - print '
'; + print $langs->trans("CustomerRelativeDiscount"); + print ''; + print ''.img_edit($langs->trans("Modify")).''; + print '
'; + print ''.$objsoc->remise_client." %"; - print 'Remise exceptionnelles'; + print ''; + + print '
'; + print $langs->trans("CustomerAbsoluteDiscount"); + print ''; + print ''.img_edit($langs->trans("Modify")).''; + print '
'; print ''; - print ''; - print img_edit($langs->trans("Modify")); - print ""; - print ''; + print ''; + $sql = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " WHERE rc.fk_soc =". $objsoc->id; + $sql .= " AND rc.fk_user = ".$user->id." AND fk_facture IS NULL"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj->amount_ht) print $obj->amount_ht.' '.$langs->trans("Currency".$conf->monnaie); + else print $langs->trans("None"); + } + print ''; + print ''; print ""; @@ -306,7 +324,7 @@ if ($_socid > 0) { $var=true; $num = $db->num_rows($resql); - if ($num >0 ) + if ($num > 0) { print ''; print '
'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' ('.$num.')
'; @@ -323,9 +341,9 @@ if ($_socid > 0) { print " > 15 jours"; } - print "".dolibarr_print_date($objp->dp)."\n"; - print ''.price($objp->price).''; - print ''.$objp->statut.''; + print ''.dolibarr_print_date($objp->dp)."\n"; + print ''.price($objp->price).''; + print ''.$objp->statut.''; $var=!$var; $i++; } @@ -342,13 +360,15 @@ if ($_socid > 0) */ if($conf->commande->enabled) { + $commande_static=new Commande($db); + print ''; - $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.total_ht, p.ref, ".$db->pdate("p.date_commande")." as dp"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as p"; - $sql .= " WHERE p.fk_soc = s.idp "; + $sql = "SELECT s.nom, s.idp, c.rowid as cid, c.total_ht, c.ref, c.fk_statut, ".$db->pdate("c.date_commande")." as dc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE c.fk_soc = s.idp "; $sql .= " AND s.idp = $objsoc->id"; - $sql .= " ORDER BY p.date_commande DESC"; + $sql .= " ORDER BY c.date_commande DESC"; $resql=$db->query($sql); if ($resql) @@ -367,14 +387,10 @@ if ($_socid > 0) $objp = $db->fetch_object($resql); $var=!$var; print ""; - print '\n"; + print '\n"; print ''; - print ''; + print ''; $i++; } $db->free($resql); @@ -408,7 +424,7 @@ if ($_socid > 0) if ($num >0 ) { print ''; - print '"; + print ''; + print ''; + print ''; + + $i++; + } + $db->free($resql); + print "
'.img_object($langs->trans("ShowOrder"),"order").' '.$objp->ref."\n"; - if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) - { - print " > 15 jours"; - } - print "".dolibarr_print_date($objp->dp)."'.img_object($langs->trans("ShowOrder"),"order").' '.$objp->ref."\n"; + print ''.dolibarr_print_date($objp->dc)."'.price($objp->total_ht).''.$objp->statut.'
'.$commande_static->status_label_short[$objp->fk_statut].'
'; + print ''; print ''; } @@ -419,8 +435,9 @@ if ($_socid > 0) $var=!$var; print ""; print '\n"; - print "\n"; - print "\n"; + print '\n"; + print ''; + print '\n"; print ''; $i++; } @@ -550,11 +567,6 @@ if ($_socid > 0) print ''.$langs->trans("AddIntervention").''; } - if ($conf->projet->enabled && $user->rights->projet->creer) - { - print ''.$langs->trans("AddProject").''; - } - print ''.$langs->trans("AddAction").''; print ''.$langs->trans("AddContact").''; @@ -626,10 +638,7 @@ if ($_socid > 0) print ''; print '\n"; print "\n"; + print '
'; + /* - * * Liste - * */ - $sql = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc, u.code, fk_facture"; + $sql = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc, u.code"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE rc.fk_soc =". $objsoc->id; $sql .= " AND u.rowid = rc.fk_user AND fk_facture IS NULL"; $sql .= " ORDER BY rc.datec DESC"; - if ( $db->query($sql) ) - { - print '
'.$langs->trans("LastContracts",($num<=$MAXLIST?"":$MAXLIST)).''; print '
'.$langs->trans("LastContracts",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllContracts").' ('.$num.')
'.img_object($langs->trans("ShowContract"),"contract").' '.$objp->ref."".dolibarr_print_date($objp->dc)."".$contratstatic->LibStatut($objp->statut)."'.dolibarr_print_date($objp->dc)." '.$contratstatic->LibStatut($objp->statut)."
'.$obj->poste.' '; - /* - * Lien click to dial - */ - + // Lien click to dial if (strlen($obj->phone) && $user->clicktodial_enabled == 1) { print ''; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index afa8c7b8905..a7e1348d305 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -41,6 +41,8 @@ $user->getrights('fichinter'); $user->getrights('commande'); $user->getrights('projet'); +// Securité accès client +$socidp=''; if ($user->societe_id > 0) { $socidp = $user->societe_id; @@ -55,7 +57,7 @@ llxHeader(); * Actions */ -if ($_GET["action"] == 'add_bookmark') +if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$_GET["socidp"]." AND fk_user=".$user->id; if (! $db->query($sql) ) @@ -69,7 +71,7 @@ if ($_GET["action"] == 'add_bookmark') } } -if ($_GET["action"] == 'del_bookmark') +if (isset($_GET["action"]) && $_GET["action"] == 'del_bookmark') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$_GET["bid"]; $result = $db->query($sql); @@ -80,11 +82,11 @@ if ($_GET["action"] == 'del_bookmark') * Affichage page */ -print_titre($langs->trans("CommercialArea")); +print_fiche_titre($langs->trans("CommercialArea")); -print ''; +print '
'; -print ''; print ''; - - $now = time(); - $lim = 3600 * 24 * 15 ; - if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) - { - print ""; - } - else - { - print ""; - } - + print ""; print "\n"; print "\n"; diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 7ba44633282..036a3d8c8fa 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -61,11 +61,11 @@ function valeur($sql) * */ -print_titre($langs->trans("ProspectionArea")); +print_fiche_titre($langs->trans("ProspectionArea")); -print '
'; +print '
'; /* @@ -118,35 +120,35 @@ if ($conf->contrat->enabled) { */ if ($conf->propal->enabled && $user->rights->propale->lire) { - $sql = "SELECT p.rowid, p.ref, p.price, s.nom"; + $sql = "SELECT p.rowid, p.ref, p.price, s.idp, s.nom"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE p.fk_statut = 0 and p.fk_soc = s.idp"; $resql=$db->query($sql); if ($resql) { - $var=true; - $total = 0; $num = $db->num_rows($resql); - $i = 0; if ($num > 0) { print ''; print ""; print ""; + $i = 0; + $var=true; while ($i < $num) { $obj = $db->fetch_object($resql); $var=!$var; - print '"; + print ''; + print ''; $i++; $total += $obj->price; } if ($total>0) { $var=!$var; - print '"; + print '"; } print "
".$langs->trans("ProposalsDraft")."
'."rowid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$obj->ref."".$obj->nom."".price($obj->price)."
'."rowid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$obj->ref.''.dolibarr_trunc($obj->nom,18).''.price($obj->price).'
'.$langs->trans("Total")."".price($total)."
'.$langs->trans("Total").''.price($total)."

"; } @@ -161,7 +163,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) if ($conf->commande->enabled) { $langs->load("orders"); - $sql = "SELECT c.rowid, c.ref, s.nom, s.idp FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; + $sql = "SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.idp FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0"; if ($socidp) { @@ -170,12 +172,14 @@ if ($conf->commande->enabled) if ( $db->query($sql) ) { + $total = 0; $num = $db->num_rows(); if ($num) { print ''; print ''; - print ''; + print ''; + $i = 0; $var = true; while ($i < $num) @@ -183,8 +187,14 @@ if ($conf->commande->enabled) $var=!$var; $obj = $db->fetch_object(); print ""; - print ''; + print ''; + print ''; $i++; + $total += $obj->total_ttc; + } + if ($total>0) { + $var=!$var; + print '"; } print "
'.$langs->trans("DraftOrders").'
'.$langs->trans("DraftOrders").'
rowid\">".img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref."'.dolibarr_trunc($obj->nom,24).'
'.dolibarr_trunc($obj->nom,18).''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($total)."

"; } @@ -235,7 +245,7 @@ if ( $db->query($sql) ) } } -print '
'; +print ''; /* @@ -289,7 +299,7 @@ if ($user->rights->societe->lire) * Dernières actions commerciales effectuées */ -$sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, a.fk_user_author, s.nom as sname, s.idp"; +$sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code, c.libelle, a.fk_user_author, s.nom as sname, s.idp"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE c.id=a.fk_action AND a.percent >= 100 AND s.idp = a.fk_soc"; if ($socidp) @@ -528,18 +538,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) { print ''.img_object($langs->trans("ShowPropal"),"propal").' '; print $objp->ref.''.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).' > 15 jours  "; print dolibarr_print_date($objp->dp)."".price($objp->price)."
'; +print '
'; -print '\n"; - - /* - * - * - */ print ""; print "
'; +print '
'; if ($conf->propal->enabled) { @@ -165,7 +165,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) * Actions commerciales a faire * */ -print ''; +print ''; $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code, c.libelle, a.fk_user_author, s.nom as sname, s.idp"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/comm/prospect/prospects.php b/htdocs/comm/prospect/prospects.php index 42fe61d2a95..5907704ad29 100644 --- a/htdocs/comm/prospect/prospects.php +++ b/htdocs/comm/prospect/prospects.php @@ -44,11 +44,7 @@ if ($_GET["action"] == 'cstc') $db->query($sql); } -dolibarr_user_page_param($db, $user, $_GET); - -/* - * Sécurité accés client - */ +// Sécurité accés client if ($user->societe_id > 0) { $action = ''; diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index e141fe32337..0b1401ae652 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 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 @@ -43,35 +43,31 @@ $langs->load("companies"); if ($_POST["action"] == 'setremise') { - $soc = New Societe($db); - $soc->fetch($_GET["id"]); - $soc->set_remise_client($_POST["remise"],$user); - - - Header("Location: remise.php?id=".$_GET["id"]); - + $soc = New Societe($db); + $soc->fetch($_GET["id"]); + $soc->set_remise_client($_POST["remise"],$user); + + Header("Location: remise.php?id=".$_GET["id"]); + exit; } llxHeader(); - -/* - * - */ $_socid = $_GET["id"]; -/* - * Sécurité si un client essaye d'accéder à une autre fiche que la sienne - */ + + +// Sécurité si un client essaye d'accéder à une autre fiche que la sienne if ($user->societe_id > 0) { - $_socid = $user->societe_id; + $_socid = $user->societe_id; } + + /********************************************************************************* * * Mode fiche * - * *********************************************************************************/ if ($_socid > 0) { @@ -156,52 +152,26 @@ if ($_socid > 0) print '
'; print ''; - print '"; + print '"; print ''; + print $langs->trans("NewValue").''; print ''; print "
'; - print $langs->trans("CustomerDiscount").''.$objsoc->remise_client." %
'; + print $langs->trans("CustomerRelativeDiscount").''.$objsoc->remise_client."%
'; - print $langs->trans("NewValue").' %
%
"; print ""; - print "
"; - - /* - * - */ print "
\n"; print '
'; - /* - * - * Notes sur la societe - * - */ - if ($objsoc->note) - { - print ''; - print ""; - print "
".nl2br($objsoc->note)."
"; - } - /* - * - */ /* - * * Liste de l'historique des remises - * */ $sql = "SELECT rc.rowid,rc.remise_client,".$db->pdate("rc.datec")." as dc, u.code"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index b484eaea3a9..03f40c58000 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 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 @@ -23,14 +23,11 @@ /** \file htdocs/comm/remx.php \ingroup commercial - \brief Onglet ??? + \brief Onglet de définition des avoirs \version $Revision$ */ require_once("./pre.inc.php"); -require_once("../contact.class.php"); -//require_once("../cactioncomm.class.php"); -//require_once("../actioncomm.class.php"); $user->getrights('propale'); $user->getrights('commande'); @@ -38,6 +35,7 @@ $user->getrights('projet'); $langs->load("orders"); +$langs->load("bills"); $langs->load("companies"); @@ -47,25 +45,21 @@ if ($_POST["action"] == 'setremise') $soc->fetch($_GET["id"]); $soc->set_remise_except($_POST["remise"],$user); - Header("Location: remx.php?id=".$_GET["id"]); } llxHeader(); - -/* - * - */ $_socid = $_GET["id"]; -/* - * Sécurité si un client essaye d'accéder à une autre fiche que la sienne - */ + +// 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 @@ -96,19 +90,53 @@ if ($_socid > 0) if ($objsoc->client==1) { - $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objsoc->id; - $head[$h][1] = 'Client'; - $h++; - } - - if ($objsoc->client==1) - { - $head[$h][0] = DOL_URL_ROOT.'/comm/remx.php?id='.$objsoc->id; - $head[$h][1] = 'Remises exceptionnelles'; $hselected=$h; + $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("Customer"); $h++; } + if ($objsoc->client==2) + { + $hselected=$h; + $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$obj->socid; + $head[$h][1] = $langs->trans("Prospect"); + $h++; + } + if ($objsoc->fournisseur) + { + $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("Supplier"); + $h++; + } + + if ($conf->compta->enabled) { + $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("Accountancy"); + $h++; + } + $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("Note"); + $h++; + + if ($user->societe_id == 0) + { + $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("Documents"); + $h++; + } + + $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("Notifications"); + $h++; + + if ($user->societe_id == 0) + { + $head[$h][0] = DOL_URL_ROOT."/comm/index.php?socidp=$objsoc->id&action=add_bookmark"; + $head[$h][1] = 'Bookmark'; + $head[$h][2] = 'image'; + } + dolibarr_fiche_head($head, $hselected, $objsoc->nom); /* @@ -118,114 +146,125 @@ if ($_socid > 0) print '
'; print ''; - print ''; + print '
'; - print ''; + $sql = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc, rc.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " WHERE rc.fk_soc =". $objsoc->id; + $sql .= " AND fk_facture IS NULL"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $remise_all+=$obj->amount_ht; + if ($obj->fk_user == $user->id) $remise_user+=$obj->amount_ht; + } - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print "
Remises exceptionnelles'; - print ' 
Montant HT'; - print ' 
'.$langs->trans("CustomerAbsoluteDiscountAllUsers").''.$remise_all.' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("CustomerAbsoluteDiscountMy").''.$remise_user.' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("NewValue").' '.$langs->trans("Currency".$conf->monnaie).'
 
"; - print "
"; - - /* - * - */ print "
'; - print ''; - print ''; - $tag = !$tag; - print ""; - $i = 0 ; - $num = $db->num_rows(); + $resql=$db->query($sql); + if ($resql) + { + print_titre($langs->trans("Ristournes restant dues")); + print '
DateMontant HTUtilisateur
'; + print ''; + print ''; - while ($i < $num ) - { - $obj = $db->fetch_object( $i); - $tag = !$tag; - print ""; - print ''; - print ''; - print ''; - - - $i++; - } - $db->free(); - print "
'.$langs->trans("Date").''.$langs->trans("AmountHT").''.$langs->trans("Accordée par").'
'.strftime("%d %B %Y",$obj->dc).''.price($obj->amount_ht).''.$obj->code.'
"; - } + $var = true; + $i = 0 ; + $num = $db->num_rows($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $var = !$var; + print "
'.dolibarr_print_date($obj->dc).''.price($obj->amount_ht).''.$obj->code.'
"; + } else - { - print $db->error(); - } + { + dolibarr_print_error($db); + } print '
'; /* - * * Liste Archives - * */ - $sql = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc, u.code, fk_facture"; + $sql = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc, u.code, rc.fk_facture, f.facnumber"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " , ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE rc.fk_soc =". $objsoc->id; + $sql .= " AND fk_facture = f.rowid"; $sql .= " AND u.rowid = rc.fk_user AND fk_facture IS NOT NULL"; $sql .= " ORDER BY rc.datec DESC"; - if ( $db->query($sql) ) - { - print ''; - print ''; - print ''; - $tag = !$tag; - print ""; - $i = 0 ; - $num = $db->num_rows(); + $resql=$db->query($sql); + if ($resql) + { + print_titre($langs->trans("Ristournes appliquées")); + print '
DateMontant HTFactureUtilisateur
'; + print ''; + print ''; - while ($i < $num ) - { - $obj = $db->fetch_object( $i); - $tag = !$tag; - print ""; - print ''; - print ''; - print ''; - print ''; - - - $i++; - } - $db->free(); - print "
'.$langs->trans("Date").''.$langs->trans("AmountHT").''.$langs->trans("Bill").''.$langs->trans("Author").'
'.strftime("%d %B %Y",$obj->dc).''.price($obj->amount_ht).''.$obj->fk_facture.''.$obj->code.'
"; - } + $var = true; + $i = 0 ; + $num = $db->num_rows($resql); + while ($i < $num ) + { + $obj = $db->fetch_object($resql); + $var = !$var; + print ""; + print ''.dolibarr_print_date($obj->dc).''; + print ''.price($obj->amount_ht).''; + print ''.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.''; + print ''.$obj->code.''; + + $i++; + } + $db->free($resql); + print ""; + } else - { - print $db->error(); - } + { + print dolibarr_print_error($db); + } } $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 163607a8d69..1836277eeb6 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -36,33 +36,45 @@ class Commande { - var $db ; - var $id ; - var $brouillon; - - /** \brief Constructeur - */ - function Commande($DB) + var $db ; + var $id ; + var $brouillon; + + // Pour board + var $nbtodo; + var $nbtodolate; + + /** + * \brief Constructeur + * \param DB Handler d'accès base + */ + function Commande($DB) { - global $langs; - $langs->load("orders"); - - $this->db = $DB; - - $this->sources[0] = "Proposition commerciale"; - $this->sources[1] = "Internet"; - $this->sources[2] = "Courrier"; - $this->sources[3] = "Téléphone"; - $this->sources[4] = "Fax"; - $this->sources[5] = "Commercial"; - - $this->statuts[-1] = $langs->trans("StatusOrderCanceled"); - $this->statuts[0] = $langs->trans("StatusOrderDraft"); - $this->statuts[1] = $langs->trans("StatusOrderValidated"); - $this->statuts[2] = $langs->trans("StatusOrderOnProcess"); - $this->statuts[3] = $langs->trans("StatusOrderProcessed"); - - $this->products = array(); + global $langs; + $langs->load("orders"); + + $this->db = $DB; + + $this->statuts[-1] = $langs->trans("StatusOrderCanceled"); + $this->statuts[0] = $langs->trans("StatusOrderDraft"); + $this->statuts[1] = $langs->trans("StatusOrderValidated"); + $this->statuts[2] = $langs->trans("StatusOrderOnProcess"); + $this->statuts[3] = $langs->trans("StatusOrderProcessed"); + + $this->status_label_short[-1] = $langs->trans("StatusOrderCanceled"); + $this->status_label_short[0] = $langs->trans("StatusOrderDraft"); + $this->status_label_short[1] = $langs->trans("StatusOrderValidated"); + $this->status_label_short[2] = $langs->trans("StatusOrderOnProcessShort"); + $this->status_label_short[3] = $langs->trans("StatusOrderProcessed"); + + $this->sources[0] = $langs->trans("OrderSource0"); + $this->sources[1] = $langs->trans("OrderSource1"); + $this->sources[2] = $langs->trans("OrderSource2"); + $this->sources[3] = $langs->trans("OrderSource3"); + $this->sources[4] = $langs->trans("OrderSource4"); + $this->sources[5] = $langs->trans("OrderSource5"); + + $this->products = array(); } /** \brief Créé la facture depuis une propale existante @@ -162,27 +174,31 @@ class Commande } /** - * Cloture la commande - * + * \brief Cloture la commande + * \param user Objet utilisateur qui cloture + * \return int <0 si ko, >0 si ok */ - function cloture($user) + function cloture($user) { - if ($user->rights->commande->valider) - { - - $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 3"; - $sql .= " WHERE rowid = $this->id AND fk_statut > 0 ;"; - - if ($this->db->query($sql) ) - { - return 1; - } - else - { - dolibarr_print_error($this->db); - } - } - } + if ($user->rights->commande->valider) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; + $sql.= " SET fk_statut = 3,"; + $sql.= " fk_user_cloture = ".$user->id.","; + $sql.= " date_cloture = now()"; + $sql.= " WHERE rowid = $this->id AND fk_statut > 0 ;"; + + if ($this->db->query($sql) ) + { + return 1; + } + else + { + dolibarr_print_error($this->db); + return -1; + } + } + } /** * Annule la commande @@ -845,7 +861,7 @@ class Commande while ($obj=$this->db->fetch_object($resql)) { $this->nbtodo++; - if ($obj->da < (time() - $conf->commande->traitement->warning_delay)) $this->nbtodolate++; + if ($obj->datec < (time() - $conf->commande->traitement->warning_delay)) $this->nbtodolate++; } return 1; } @@ -857,6 +873,60 @@ class Commande } } + /** + * \brief Charge les informations d'ordre info dans l'objet commande + * \param id Id de la commande a charger + */ + function info($id) + { + $sql = "SELECT c.rowid, ".$this->db->pdate("date_creation")." as datec,"; + $sql.= " ".$this->db->pdate("date_valid")." as datev,"; + $sql.= " ".$this->db->pdate("date_cloture")." as datecloture,"; + $sql.= " fk_user_author, fk_user_valid, fk_user_cloture"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql.= " WHERE c.rowid = ".$id; + + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + + $this->id = $obj->rowid; + + if ($obj->fk_user_author) { + $cuser = new User($this->db, $obj->fk_user_author); + $cuser->fetch(); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) { + $vuser = new User($this->db, $obj->fk_user_valid); + $vuser->fetch(); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) { + $cluser = new User($this->db, $obj->fk_user_cloture); + $cluser->fetch(); + $this->user_cloture = $cluser; + } + + $this->date_creation = $obj->datec; + $this->date_validation = $obj->datev; + $this->date_cloture = $obj->datecloture; + } + + $this->db->free($result); + + } + else + { + dolibarr_print_error($this->db); + } + } + } @@ -868,7 +938,7 @@ class Commande class CommandeLigne { - var $pu; + var $pu; } ?> diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index abc70b6dd3c..fb5ad9ce077 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -255,30 +255,29 @@ if ($_GET["action"] == 'create' && $user->rights->commande->creer) print ''; - print ''; + print ''; print ''; - print ''; - - print ''; - + $nbrow=3; + if ($conf->projet->enabled) $nbrow++; + print ''; + print '"; - print ''; - - + if ($conf->projet->enabled) + { + print '"; + } + print '"; - print '"; - if ($propalid > 0) { $amount = ($obj->price); @@ -296,43 +295,22 @@ if ($_GET["action"] == 'create' && $user->rights->commande->creer) } else { + /* + * Services/produits prédéfinis + */ + $NBLINES=8; + print ''; print '"; print ''; print ''; @@ -775,9 +775,9 @@ else print ""; print ''; print ''; @@ -810,9 +810,9 @@ else print ""; print ''; print ''; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 916a26e0b61..5aff0dcbeac 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -54,13 +54,12 @@ if ($user->societe_id > 0) $socid = $user->societe_id; } -print_barre_liste($langs->trans("ContractsArea"), $page, "index.php", "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num); +print_fiche_titre($langs->trans("ContractsArea")); -print '
'.$langs->trans("Customer").' :'.$soc->nom_url.'
'.$langs->trans("Ref").' :Provisoire'.$langs->trans("Comments").' :
'.$langs->trans("Author").' :'.$user->fullname.''; - print '
'.$langs->trans("Customer").' :'.$soc->nom_url.''; + print '
'.$langs->trans("Date").' :'; $html->select_date(); print "
'.$langs->trans("Ref").' :Provisoire
'.$langs->trans("Project").' :'; + $html->select_projects($soc->id,'','projetid'); + print "
'.$langs->trans("Source").' :'; $html->select_array("source_id",$new_commande->sources,2); print "
'.$langs->trans("Project").' :'; - $proj = new Project($db); - $html->select_array("projetid",$proj->liste_array($soc->id),0,1); - print "
'.$langs->trans("Services").'/'.$langs->trans("Products").'
'; - /* - * - * Liste des elements - * - */ - $sql = "SELECT p.rowid,p.label,p.ref,p.price FROM ".MAIN_DB_PREFIX."product as p "; - $sql .= " WHERE envente = 1"; - $sql .= " ORDER BY p.nbvente DESC LIMIT 20"; - if ( $db->query($sql) ) - { - $opt = ""; - if ($result) - { - $num = $db->num_rows(); $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object(); - $opt .= "\n"; - $i++; - } - } - $db->free(); - } - else - { - dolibarr_print_error($db); - } - - $NBLINES=8; + print ''; print ''; for ($i = 1 ; $i <= $NBLINES ; $i++) { - print ''; + print ''; print ''; print ''; } @@ -344,7 +322,7 @@ if ($_GET["action"] == 'create' && $user->rights->commande->creer) /* * */ - print ''; + print ''; print "\n"; print "
'.$langs->trans("ProductsAndServices").''.$langs->trans("Qty").''.$langs->trans("Discount").'
'; + print $html->select_produits('','idprod'); + print '%
\n"; @@ -458,7 +436,11 @@ else $h++; } - dolibarr_fiche_head($head, $hselected, $soc->nom." / ".$langs->trans("Order")." : $commande->ref"); + $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id; + $head[$h][1] = $langs->trans("Info"); + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref"); /* * Confirmation de la suppression de la commande @@ -501,36 +483,10 @@ else /* * Commande */ - print ''; - print '"; - print ''; - print ''; - print ''; - - print ""; - print ''; - - print '"; + print ''; + print '"; + + print ""; + print ''; + print ''; + print ''; + print "\n"; + $nbrow=6; + if ($conf->projet->enabled) $nbrow++; + print ''; + print ''; print "\n"; + print ''; - print ''; - - // Ligne de 3 colonnes + // Projet + if ($conf->projet->enabled) + { + $langs->load("projects"); + print '"; + } else { + print ''; + } + + // Lignes de 3 colonnes print ''; print ''; - print ''; - print ''; + print ''; + print '"; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print '' . "\n"; print "\n"; } $i++; } - $db->free(); + $db->free($result); } else { @@ -734,14 +724,14 @@ else print ''; print ''; - print ''; + print ''; $var=!$var; print ""; print ''; print ''; print ''; - print ''; + print ''; print "\n"; print ""; @@ -913,25 +903,6 @@ else print "
'.$langs->trans("Order")."'.$commande->ref.''.$commande->statuts[$commande->statut].''; - - if ($conf->projet->enabled) - { - $langs->load("projects"); - if ($commande->projet_id > 0) - { - print $langs->trans("Project").' : '; - $projet = New Project($db); - $projet->fetch($commande->projet_id); - print ''.$projet->title.''; - } - else - { - print $langs->trans("Project").' : '; - print ''.$langs->trans("ClassifyOrder").''; - } - } - print ' 
".$langs->trans("Customer")."'; - print ''.$soc->nom.''.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ; + print '
'.$langs->trans("Ref")."'.$commande->ref.''.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ; if ($commande->source == 0) { /* Propale */ @@ -539,30 +495,64 @@ else print ' -> '.$propal->ref.''; } print "
".$langs->trans("Customer")."'; + print ''.$soc->nom.'
'.$langs->trans("Status").'".$commande->statuts[$commande->statut]."'.$langs->trans("Note").' :
'; + if ($commande->brouillon == 1 && $user->rights->commande->creer) + { + print '
'; + print ''; + print '
'; + print '
'; + print '
'; + } + else + { + print nl2br($commande->note); + } + print '
'.$langs->trans("Date").'".dolibarr_print_date($commande->date,"%A %d %B %Y")."
'; - print $langs->trans("Author").' : '.$author->fullname.'
'; + print ''; + if ($_GET["action"] != "classer") print ''; + print '
'; + print $langs->trans("Project"); + print 'id.'">'.img_edit($langs->trans("SetProject")).'
'; + print '
'; + if ($_GET["action"] == "classer") + { + $html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"projetid"); + } + else + { + $html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"none"); + } + print "  
'.$langs->trans("AmountHT").''.price($commande->total_ht).''.$langs->trans("Currency".$conf->monnaie).''.$langs->trans("Note").' :
'; - if ($commande->brouillon == 1 && $user->rights->commande->creer) - { - print '
'; - print ''; - print '
'; - print '
'; - } - else - { - print nl2br($commande->note); - } - print '
'.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("GlobalDiscount").''; @@ -570,8 +560,8 @@ else { print '
'; print ''; - print '%'; - print '
'; + print '%'; + print ''; print ''; } else @@ -670,16 +660,16 @@ else print ''; print "
%%
%
% 
"; - - /* - * Classe la commande dans un projet - * TODO finir le look & feel très moche - */ - if ($_GET["action"] == 'classer') - { - print '
'; - print ''; - print ''; - print '"; - print '
'.$langs->trans("Project").''; - - $proj = new Project($db); - $html->select_array("projetid",$proj->liste_array($commande->soc_id)); - - print "
'; - } - } else { diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 0b15c74e7dd..5b16f87eab8 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -35,11 +35,11 @@ $langs->load("orders"); llxHeader("",$langs->trans("Orders"),"Commande"); -print_titre($langs->trans("OrdersArea")); +print_fiche_titre($langs->trans("OrdersArea")); -print ''; +print '
'; -print '\n"; - print ''; + print ''; print "\n"; $total = $total + $objp->price; @@ -174,5 +175,6 @@ else } $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); + +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index cb2402dd3cd..5ce078f2cec 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -83,6 +83,7 @@ class Contrat * Si la duree est renseignée, date_start=date_start et date_end=date_start+duree * sinon date_start=date_start et date_end=date_end */ +/* function mise_en_service($user, $date_start, $duree=0, $date_end) { if ($duree) { @@ -128,7 +129,7 @@ class Contrat return -1; } } - +*/ /** * \brief Active une ligne detail d'un contrat @@ -642,11 +643,11 @@ class Contrat } - /** - * \brief Récupère les lignes de detail du contrat - * \param statut Statut des lignes detail à récupérer - * \return array Tableau des lignes de details - */ + /** + * \brief Récupère les lignes de detail du contrat + * \param statut Statut des lignes detail à récupérer + * \return array Tableau des lignes de details + */ function array_detail($statut=-1) { $tab=array(); @@ -676,5 +677,52 @@ class Contrat } } + + /** + * \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord + * \param mode "inactive" pour services à activer, "expired" pour services expirés + * \return int <0 si ko, >0 si ok + */ + function load_board($mode) + { + global $conf; + + $this->nbtodo=$this->nbtodolate=0; + if ($mode == 'inactives') + { + $sql = "SELECT cd.rowid,".$this->db->pdate("cd.date_ouverture_prevue")." as datefin"; + $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd"; + $sql.= " WHERE c.statut = 1 AND c.rowid = cd.fk_contrat"; + $sql.= " AND cd.statut = 0"; + } + if ($mode == 'expired') + { + $sql = "SELECT cd.rowid,".$this->db->pdate("cd.date_fin_validite")." as datefin"; + $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd"; + $sql.= " WHERE c.statut = 1 AND c.rowid = cd.fk_contrat"; + $sql.= " AND cd.statut = 4"; + $sql.= " AND cd.date_fin_validite < '".$this->db->idate(time())."'"; + } + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nbtodo++; + if ($mode == 'inactives') + if ($obj->datefin && $obj->datefin < (time() - $conf->contrat->services->inactifs->warning_delay)) $this->nbtodolate++; + if ($mode == 'expired') + if ($obj->datefin && $obj->datefin < (time() - $conf->contrat->services->expires->warning_delay)) $this->nbtodolate++; + } + return 1; + } + else + { + dolibarr_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } + } ?> diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 87305059b3f..78caa2ab608 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -29,9 +29,9 @@ */ require("./pre.inc.php"); -require("../project.class.php"); -require("../propal.class.php"); -require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); +if ($conf->projet->enabled) require_once("../project.class.php"); +if ($conf->propal->enabled) require_once("../propal.class.php"); +if ($conf->contrat->enabled) require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); $langs->load("contracts"); $langs->load("orders"); @@ -472,7 +472,7 @@ else /* - * Confirmation de la suppression de la contrat + * Confirmation de la suppression du contrat */ if ($_GET["action"] == 'delete') { @@ -542,7 +542,7 @@ else print '
'; +print '
'; /* * Zone recherche @@ -116,7 +116,7 @@ if ( $db->query($sql) ) } -print ''; +print ''; /* @@ -153,15 +153,16 @@ if ( $db->query($sql) ) } /* - * Commandes à traiter + * Dernières commandes traitées */ $max=5; -$sql = "SELECT c.rowid, c.ref, s.nom, s.idp"; +$sql = "SELECT c.rowid, c.ref, s.nom, s.idp,"; +$sql.= " ".$db->pdate("date_cloture")." as datec"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; -$sql.= " WHERE c.fk_soc = s.idp AND c.fk_statut > 2"; +$sql.= " WHERE c.fk_soc = s.idp and c.fk_statut > 2"; if ($socidp) $sql .= " AND c.fk_soc = $socidp"; -$sql.= " ORDER BY c.rowid DESC"; +$sql.= " ORDER BY c.tms DESC"; $sql.= $db->plimit($max, 0); $resql=$db->query($sql); @@ -173,7 +174,7 @@ if ($resql) $i = 0; print ''; print ''; - print ''; + print ''; $var = True; while ($i < $num) { @@ -181,7 +182,9 @@ if ($resql) $obj = $db->fetch_object($resql); print "'; - print ''; + print ''; + print ''; + print ''; $i++; } print "
'.$langs->trans("LastOrders",$max).'
'.$langs->trans("LastClosedOrders",$max).'
rowid\">".img_object($langs->trans("ShowOrders"),"order").' '; print $obj->ref.''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'
'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''.dolibarr_print_date($obj->datec).'

"; diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php index 7f9bad75b0d..fcc3c332f55 100644 --- a/htdocs/commande/liste.php +++ b/htdocs/commande/liste.php @@ -21,10 +21,11 @@ * */ -/** \file htdocs/commande/liste.php - \ingroup commande - \brief Page liste des commandes - \version $Revision$ +/** + \file htdocs/commande/liste.php + \ingroup commande + \brief Page liste des commandes + \version $Revision$ */ @@ -156,7 +157,7 @@ if ($resql) print " "; print strftime("%Y",$objp->date_commande)."
'.$generic_commande->statuts[$objp->fk_statut].''.$generic_commande->status_label_short[$objp->fk_statut].'
'; - if ($_GET["action"] != "classer") print ''; + if ($_GET["action"] != "classer") print ''; print '
'; print $langs->trans("Project"); print ''.img_edit($langs->trans("SetProject")).''.img_edit($langs->trans("SetProject")).'
'; print '
'; if ($_GET["action"] == "classer") @@ -722,9 +722,9 @@ else // Ligne dates prévues print "
'; - print 'Date prévue mise en service '; + print $langs->trans("DateStartPlanned").' '; $html->select_date($objp->date_debut,"date_start_update",0,0,($objp->date_debut>0?0:1)); - print '   Date prévue fin de service '; + print '   '.$langs->trans("DateEndPlanned").' '; $html->select_date($objp->date_fin,"date_end_update",0,0,($objp->date_fin>0?0:1)); print '
'; - print 'Date prévue mise en service '; + print $langs->trans("DateStartPlanned").' '; $html->select_date('',"date_start",0,0,1); - print '   Date prévue fin de service '; + print '   '.$langs->trans("DateEndPlanned").' '; $html->select_date('',"date_end",0,0,1); print '
'; - print 'Date prévue mise en service '; + print $langs->trans("DateStartPlanned").' '; $html->select_date('',"date_start",0,0,1); - print '   Date prévue fin de service '; + print '   '.$langs->trans("DateEndPlanned").' '; $html->select_date('',"date_end",0,0,1); print '
'; +print '
'; - -print ''; print '
'; +print '
'; /* * Recherche Contrat @@ -89,7 +88,7 @@ print '
'; -print ''; +print ''; // Last contracts diff --git a/htdocs/contrat/ligne.php b/htdocs/contrat/ligne.php index 8c856bed1a9..348ca7e1ad4 100644 --- a/htdocs/contrat/ligne.php +++ b/htdocs/contrat/ligne.php @@ -28,6 +28,9 @@ */ require("./pre.inc.php"); +if ($conf->projet->enabled) require_once("../project.class.php"); +if ($conf->propal->enabled) require_once("../propal.class.php"); +if ($conf->contrat->enabled) require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); $langs->load("contracts"); $langs->load("orders"); @@ -38,9 +41,7 @@ $user->getrights('contrat'); if (!$user->rights->contrat->lire) accessforbidden(); -require("../project.class.php"); -require("../propal.class.php"); -require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); + /* * Sécurité accés client @@ -91,7 +92,8 @@ if ($_POST["action"] == 'confirm_close' && $_POST["confirm"] == 'yes' && $user-> -llxHeader('',$langs->trans("Contract"),"Contrat"); + +llxHeader('',$langs->trans("ContractCard"),"Contrat"); $html = new Form($db); @@ -154,27 +156,38 @@ if ($id > 0) print ''; print ''.$contrat->societe->nom.''; - // Status + // Statut contrat print ''.$langs->trans("Status").''; print $contrat->statuts[$contrat->statut]; print ""; // Date print ''.$langs->trans("Date").''; - print ''.strftime("%A %d %B %Y",$contrat->date_contrat)."\n"; + print ''.dolibarr_print_date($contrat->date_contrat,"%A %d %B %Y")."\n"; + // Factures associées + /* + TODO + */ + + // Projet if ($conf->projet->enabled) { - print ''.$langs->trans("Project").''; - if ($contrat->projet_id > 0) + $langs->load("projects"); + print ''; + print ''; + if ($_GET["action"] != "classer") print ''; + print '
'; + print $langs->trans("Project"); + print ''.img_edit($langs->trans("SetProject")).'
'; + print ''; + if ($_GET["action"] == "classer") { - $projet = New Project($db); - $projet->fetch($contrat->projet_id); - print ''.$projet->title.''; + $html->form_project($_SERVER["PHP_SELF"]."?id=$id&ligne=".$_GET["ligne"],$contrat->fk_soc,$contrat->fk_projet,"projetid"); } else { - print 'Classer le contrat'; + $html->form_project($_SERVER["PHP_SELF"]."?id=$id&ligne=".$_GET["ligne"],$contrat->fk_soc,$contrat->fk_projet,"none"); } print ""; } @@ -291,13 +304,13 @@ if ($id > 0) // Dates mise en service print ''; print ''; - // Si pas encore activ + // Si pas encore activé if (! $objp->date_debut_reelle) { print $langs->trans("DateStartPlanned").': '; if ($objp->date_debut) print dolibarr_print_date($objp->date_debut); else print $langs->trans("Unknown"); } - // Si activ + // Si activé if ($objp->date_debut_reelle) { print $langs->trans("DateStartReal").': '; if ($objp->date_debut_reelle) print dolibarr_print_date($objp->date_debut_reelle); @@ -433,7 +446,7 @@ if ($id > 0) } else { - /* Contrat non trouvée */ + // Contrat non trouvé print "Contrat inexistant ou accés refusé"; } } diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index 4ed6f3a9abb..c924df80909 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -44,6 +44,8 @@ if ($page == -1) { $page = 0 ; } $limit = $conf->liste_limit; $offset = $limit * $page ; +$search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"]; +$search_contract=isset($_GET["search_contract"])?$_GET["search_contract"]:$_POST["search_contract"]; $statut=isset($_GET["statut"])?$_GET["statut"]:1; $socid=$_GET["socid"]; @@ -68,13 +70,9 @@ $sql.= " c.rowid as cid, c.datec, c.statut, s.nom, s.idp as sidp"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; $sql.= " WHERE c.fk_soc = s.idp "; -if ($_POST["search_contract"]) { - $sql .= " AND c.rowid = '".$_POST["search_contract"]."'"; -} -if ($socid > 0) -{ - $sql .= " AND s.idp = $socid"; -} +if ($search_nom) $sql.= " AND s.nom like '%".$search_nom."%'"; +if ($search_contract) $sql.= " AND c.rowid = '".$search_contract."'"; +if ($socid > 0) $sql.= " AND s.idp = $socid"; $sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.idp"; $sql.= " ORDER BY $sortfield $sortorder"; $sql.= $db->plimit($limit + 1 ,$offset); @@ -90,15 +88,31 @@ if ($resql) print ''; print ''; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","",'width="50"',$sortfield); - print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"], "s.nom","","","",$sortfield); - print_liste_field_titre($langs->trans("DateCreation"), $_SERVER["PHP_SELF"], "c.datec","","",'align="center"',$sortfield); - print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "c.statut","","",'align="center"',$sortfield); + $param='&search_contract='.$search_contract; + $param.='&search_nom='.$search_nom; + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'width="50"',$sortfield); + print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"], "s.nom","","$param","",$sortfield); + print_liste_field_titre($langs->trans("DateCreation"), $_SERVER["PHP_SELF"], "c.datec","","$param",'align="center"',$sortfield); + print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "c.statut","","$param",'align="center"',$sortfield); print ''; print ''; print ''; print "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '"; + print "\n"; + print ''; $contratstatic=new Contrat($db); $now=mktime(); diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 6c4b6eb9e2d..2d0f121f0a9 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -69,13 +69,14 @@ $sql.= " ".$db->pdate("cd.date_cloture")." as date_cloture"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; $sql.= " , ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product as p"; $sql.= " , ".MAIN_DB_PREFIX."contratdet as cd"; -$sql.= " WHERE c.fk_soc = s.idp AND cd.fk_product = p.rowid"; +$sql.= " WHERE c.statut > 0"; +$sql.= " AND c.rowid = cd.fk_contrat"; +$sql.= " AND c.fk_soc = s.idp AND cd.fk_product = p.rowid"; if ($mode == "0") $sql.= " AND cd.statut = 0"; if ($mode == "4") $sql.= " AND cd.statut = 4"; if ($mode == "5") $sql.= " AND cd.statut = 5"; // \todo filtre sur services expirés //if ($mode == "expired") $sql.= " AND cd.statut = 1"; -$sql.= " AND cd.fk_contrat = c.rowid"; if ($socid > 0) { $sql .= " AND s.idp = $socid"; @@ -99,7 +100,7 @@ if ($resql) print_liste_field_titre($langs->trans("Company"),"services.php", "s.nom","&mode=$mode","","",$sortfield); // Date debut if ($mode == "0") print_liste_field_titre($langs->trans("DateStartPlannedShort"),"services.php", "cd.date_ouverture_prevue","&mode=$mode",'',' align="center"',$sortfield); - if ($mode =="" || $mode > 0) print_liste_field_titre($langs->trans("DateStartRealShort"),"services.php", "cd.date_ouverture","&mode=$mode",'',' align="center"',$sortfield); + if ($mode == "" || $mode > 0) print_liste_field_titre($langs->trans("DateStartRealShort"),"services.php", "cd.date_ouverture","&mode=$mode",'',' align="center"',$sortfield); // Date fin if ($mode == "" || $mode < 5) print_liste_field_titre($langs->trans("DateEndPlannedShort"),"services.php", "cd.date_fin_validite","&mode=$mode",'',' align="center"',$sortfield); else print_liste_field_titre($langs->trans("DateEndRealShort"),"services.php", "cd.date_cloture","&mode=$mode",'',' align="center"',$sortfield); @@ -117,13 +118,20 @@ if ($resql) print ''; print ''; // Date debut - if ($mode == "0") print ''; + if ($mode == "0") { + print ''; + } if ($mode == "" || $mode > 0) print ''; // Date fin if ($mode == "" || $mode < 5) print ''; print ''; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 3fa8216d26a..6b803372b5b 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -586,7 +586,7 @@ else { $resteapayer = abs($fac->total_ttc - $total); print ""; - print '".$conf->monnaie.""; + print '".$langs->trans("Currency".$conf->monnaie).""; print "\n"; } diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index e239a23fe06..93a1c0d7c3a 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -33,13 +33,10 @@ require("./pre.inc.php"); if (!$user->rights->fournisseur->facture->lire) accessforbidden(); -llxHeader(); $socid = $_GET["socid"]; -/* - * Sécurité accés client - */ +// Sécurité accés client if ($user->societe_id > 0) { $_GET["action"] = ''; @@ -90,6 +87,10 @@ if ($_POST["mode"] == 'search') } } + +llxHeader(); + + /* * Mode Liste * @@ -98,7 +99,6 @@ if ($_POST["mode"] == 'search') $sql = "SELECT s.idp as socid, s.nom, ".$db->pdate("fac.date_lim_reglement")." as date_echeance, fac.total_ht, fac.total_ttc, fac.paye as paye, fac.fk_statut as fk_statut, fac.libelle, fac.rowid as facid, fac.facnumber"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as fac "; $sql .= " WHERE fac.fk_soc = s.idp"; - if ($socid) { $sql .= " AND s.idp = $socid"; diff --git a/htdocs/includes/boxes/box_factures_imp.php b/htdocs/includes/boxes/box_factures_imp.php index 0097f12c677..c49baab468d 100644 --- a/htdocs/includes/boxes/box_factures_imp.php +++ b/htdocs/includes/boxes/box_factures_imp.php @@ -99,6 +99,7 @@ class box_factures_imp extends ModeleBoxes { $this->info_box_contents[$i][1] = array('align' => 'left', 'text' => $objp->nom, + 'maxlength'=>44, 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp); $i++; diff --git a/htdocs/includes/boxes/modules_boxes.php b/htdocs/includes/boxes/modules_boxes.php index ed3e46907a9..7aea254b122 100644 --- a/htdocs/includes/boxes/modules_boxes.php +++ b/htdocs/includes/boxes/modules_boxes.php @@ -64,7 +64,8 @@ class ModeleBoxes $var = true; $nbcol=sizeof($contents[0])+1; - + $nblines=sizeof($contents); + print '
'.img_statut(0,$langs->trans("ServiceStatusInitial")).''.img_statut(4,$langs->trans("ServiceStatusRunning")).''.img_statut(5,$langs->trans("ServiceStatusClosed")).'
'; + print ''; + print ''; + print ''; + print '  '; + print "
'.img_object($langs->trans("ShowService"),"service").' '.dolibarr_trunc($obj->label,20).''.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,44).''.($obj->date_ouverture_prevue?dolibarr_print_date($obj->date_ouverture_prevue):' ').''; + print ($obj->date_ouverture_prevue?dolibarr_print_date($obj->date_ouverture_prevue):' '); + if ($obj->date_ouverture_prevue && ($obj->date_ouverture_prevue < (time() - $conf->contrat->services->inactifs->warning_delay))) + print img_picto($langs->trans("Late"),"warning"); + else print '    '; + print ''.($obj->date_ouverture?dolibarr_print_date($obj->date_ouverture):' ').''.($obj->date_fin_validite?dolibarr_print_date($obj->date_fin_validite):' '); else print ''.dolibarr_print_date($obj->date_cloture); // Icone warning - if ($obj->date_fin_validite && $obj->date_fin_validite < mktime() && $obj->statut < 5) print img_warning($langs->trans("Late")); + if ($obj->date_fin_validite && $obj->date_fin_validite < (time() - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) print img_warning($langs->trans("Late")); else print '    '; print 'statut
".$langs->trans("RemainderToPay")." :'.price($resteapayer)."'.price($resteapayer)."
'; // Affiche titre de la boite @@ -73,55 +74,58 @@ class ModeleBoxes print '>'.$head['text'].""; // Affiche chaque ligne de la boite - for ($i=0, $n=sizeof($contents); $i < $n; $i++) + for ($i=0, $n=$nblines; $i < $n; $i++) { - $var=!$var; - if (sizeof($contents[$i])) print ''; - - // Affiche chaque cellule - for ($j=0, $m=sizeof($contents[$i]); $j < $m; $j++) + if (isset($contents[$i])) { - $tdparam=""; - if (isset($contents[$i][$j]['align'])) $tdparam.=' align="'. $contents[$i][$j]['align'].'"'; - if (isset($contents[$i][$j]['width'])) $tdparam.=' width="'. $contents[$i][$j]['width'].'"'; + $var=!$var; + if (sizeof($contents[$i])) print ''; + + // Affiche chaque cellule + for ($j=0, $m=sizeof($contents[$i]); $j < $m; $j++) + { + $tdparam=""; + if (isset($contents[$i][$j]['align'])) $tdparam.=' align="'. $contents[$i][$j]['align'].'"'; + if (isset($contents[$i][$j]['width'])) $tdparam.=' width="'. $contents[$i][$j]['width'].'"'; + + if ($contents[$i][$j]['text']) { + $texte=isset($contents[$i][$j]['text'])?$contents[$i][$j]['text']:''; + $textewithnotags=eregi_replace('<[^>]+>','',$texte); + $texte2=isset($contents[$i][$j]['text2'])?$contents[$i][$j]['text2']:''; + $texte2withnotags=eregi_replace('<[^>]+>','',$texte2); + //print "xxx $textewithnotags y"; - if ($contents[$i][$j]['text']) { - $texte=$contents[$i][$j]['text']; - $textewithnotags=eregi_replace('<[^>]+>','',$texte); - $texte2=$contents[$i][$j]['text2']; - $texte2withnotags=eregi_replace('<[^>]+>','',$texte2); - //print "xxx $textewithnotags y"; - - if (isset($contents[$i][$j]['logo']) && $contents[$i][$j]['logo']) print '"; } - $maxlength=$this->MAXLENGTHBOX; - if (isset($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength']; - - if ($maxlength && strlen($textewithnotags) > $maxlength) - { - $texte=substr($texte,0,$maxlength)."..."; - } - if ($maxlength && strlen($texte2withnotags) > $maxlength) - { - $texte2=substr($texte2,0,$maxlength)."..."; - } - print $texte; - if ($contents[$i][$j]['url']) print ''; - print $texte2; - - print ""; } + + if (sizeof($contents[$i])) print ''; } - - if (sizeof($contents[$i])) print ''; } print "
'; - else print ''; - - if (isset($contents[$i][$j]['url'])) print ''; - if (isset($contents[$i][$j]['logo']) && $contents[$i][$j]['logo']) - { - $logo=eregi_replace("^object_","",$contents[$i][$j]['logo']); - print img_object($langs->trans("Show"),$logo); - print ''; + if (isset($contents[$i][$j]['logo']) && $contents[$i][$j]['logo']) print ''; + else print ''; + + if (isset($contents[$i][$j]['url'])) print ''; + if (isset($contents[$i][$j]['logo']) && $contents[$i][$j]['logo']) + { + $logo=eregi_replace("^object_","",$contents[$i][$j]['logo']); + print img_object($langs->trans("Show"),$logo); + print ''; + } + $maxlength=$this->MAXLENGTHBOX; + if (isset($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength']; + + if ($maxlength && strlen($textewithnotags) > $maxlength) + { + $texte=substr($texte,0,$maxlength)."..."; + } + if ($maxlength && strlen($texte2withnotags) > $maxlength) + { + $texte2=substr($texte2,0,$maxlength)."..."; + } + print $texte; + if ($contents[$i][$j]['url']) print ''; + print $texte2; + + print "
";