From 6957c804337ca47ece5649d8f9f1044157a39dff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 Apr 2006 19:21:19 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20bug=20#16281=20:=20cr=E9ation=20action?= =?UTF-8?q?=20impossible=20dans=20une=20fiche=20fournisseur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/fiche.php | 33 --- htdocs/fourn/fiche.php | 636 +++++++++++++++++++++++++++------------- 2 files changed, 426 insertions(+), 243 deletions(-) diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php index f248e9e80de..f2af6812b76 100644 --- a/htdocs/compta/fiche.php +++ b/htdocs/compta/fiche.php @@ -64,39 +64,6 @@ if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0 } -/* TODO RODO -if ($action == 'stcomm') -{ - if ($stcommid <> 'null' && $stcommid <> $oldstcomm) - { - $sql = "INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) "; - $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $user->login . "')"; - $result = @$db->query($sql); - - if ($result) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE idp=$socid"; - $result = $db->query($sql); - } - else - { - $errmesg = "ERREUR DE DATE !"; - } - } - - if ($actioncommid) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm (datea, fk_action, fk_soc, fk_user_author) VALUES ('$dateaction',$actioncommid,$socid,'" . $user->id . "')"; - $result = @$db->query($sql); - - if (!$result) - { - $errmesg = "ERREUR DE DATE !"; - } - } -} -*/ - /* * Recherche * diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index 35bda68a227..0f1cab6c2ec 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -29,6 +29,7 @@ */ require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); $langs->load('suppliers'); $langs->load('products'); @@ -36,19 +37,21 @@ $langs->load('bills'); $langs->load('orders'); $langs->load('companies'); +// Sécurité accés client $socid = isset($_GET["socid"])?$_GET["socid"]:''; - -if ($socid == '') accessforbidden(); - -/* - * Sécurité accés client - */ if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } +if ($socid == '') accessforbidden(); + + +/* + * Actions + */ + // Protection restriction commercial if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0) { @@ -70,89 +73,89 @@ $societe = new Fournisseur($db); if ( $societe->fetch($socid) ) { - $addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid; - $addons[0][1] = $societe->nom; - - llxHeader('',$langs->trans('SupplierCard').' : '.$societe->nom, $addons); - - /* - * Affichage onglets - */ - $h = 0; - - $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$socid; - $head[$h][1] = $langs->trans('Company'); - $h++; - - if ($societe->client==1) - { - $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid; - $head[$h][1] = $langs->trans('Customer'); - $h++; - } - if ($societe->client==2) - { - $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$socid; - $head[$h][1] = $langs->trans('Prospect'); - $h++; - } - if ($societe->fournisseur) - { - $hselected=$h; - $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid; - $head[$h][1] = $langs->trans('Supplier'); - $h++; - } - - if ($conf->compta->enabled || $conf->comptaexpert->enabled) - { - $langs->load('compta'); - $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$socid; - $head[$h][1] = $langs->trans('Accountancy'); - $h++; - } - - $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$societe->id; - $head[$h][1] = $langs->trans('Note'); - $h++; - - if ($user->societe_id == 0) - { - $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$societe->id; - $head[$h][1] = $langs->trans('Documents'); - $h++; - } - - $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$societe->id; - $head[$h][1] = $langs->trans('Notifications'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$societe->id; - $head[$h][1] = $langs->trans("Info"); - $h++; - - dolibarr_fiche_head($head, $hselected, $societe->nom); + $addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid; + $addons[0][1] = $societe->nom; + + llxHeader('',$langs->trans('SupplierCard').' : '.$societe->nom, $addons); + + /* + * Affichage onglets + */ + $h = 0; + + $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$socid; + $head[$h][1] = $langs->trans('Company'); + $h++; + + if ($societe->client==1) + { + $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid; + $head[$h][1] = $langs->trans('Customer'); + $h++; + } + if ($societe->client==2) + { + $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$socid; + $head[$h][1] = $langs->trans('Prospect'); + $h++; + } + if ($societe->fournisseur) + { + $hselected=$h; + $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid; + $head[$h][1] = $langs->trans('Supplier'); + $h++; + } + + if ($conf->compta->enabled || $conf->comptaexpert->enabled) + { + $langs->load('compta'); + $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$socid; + $head[$h][1] = $langs->trans('Accountancy'); + $h++; + } + + $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$societe->id; + $head[$h][1] = $langs->trans('Note'); + $h++; + + if ($user->societe_id == 0) + { + $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$societe->id; + $head[$h][1] = $langs->trans('Documents'); + $h++; + } + + $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$societe->id; + $head[$h][1] = $langs->trans('Notifications'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$societe->id; + $head[$h][1] = $langs->trans("Info"); + $h++; + + dolibarr_fiche_head($head, $hselected, $societe->nom); + - print ''; print ''; print '
'; - + print ''; print ''; - - print ''; - if ($societe->fournisseur) - { - print ''; - } - + print ''; + + if ($societe->fournisseur) + { + print ''; + } + print ''; - + print ''; print ''; print ''; @@ -170,79 +173,79 @@ if ( $societe->fetch($socid) ) print ''; + $i++; + } + $db->free($resql); + if ($num > 0) + { + print "
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; - print $langs->trans('SupplierCode').''; - print $societe->code_fournisseur; - if ($societe->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode"); - print '
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; + print $langs->trans('SupplierCode').''; + print $societe->code_fournisseur; + if ($societe->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode"); + print '
'.$langs->trans("Address").''.nl2br($societe->adresse).'
'.$langs->trans("Zip").''.$societe->cp.''.$langs->trans("Town").''.$societe->ville.'
'.$langs->trans("Country").''.$societe->pays.'
'; - $var=true; + $var=true; - $MAXLIST=4; - - // Lien recap - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
'.$langs->trans("Summary").''.$langs->trans("ShowSupplierPreview").'
'; - print '
'; + $MAXLIST=4; - /* - * Liste des commandes associées - */ + // Lien recap + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'.$langs->trans("Summary").''.$langs->trans("ShowSupplierPreview").'
'; + print '
'; + + /* + * Liste des commandes associées + */ $orderstatic = new CommandeFournisseur($db); - $sql = "SELECT p.rowid,p.ref,".$db->pdate("p.date_commande")." as dc, p.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; - $sql.= " WHERE p.fk_soc =".$societe->id; - $sql.= " ORDER BY p.rowid"; - $sql.= " ".$db->plimit($MAXLIST); - $resql=$db->query($sql); - if ($resql) - { - $i = 0 ; - $num = $db->num_rows($resql); - if ($num > 0) - { - print ''; - print ''; - print ''; - } - while ($i < $num && $i <= $MAXLIST) - { - $obj = $db->fetch_object($resql); - $var=!$var; - - print ""; - print ''; - print ''; + $sql = "SELECT p.rowid,p.ref,".$db->pdate("p.date_commande")." as dc, p.fk_statut"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; + $sql.= " WHERE p.fk_soc =".$societe->id; + $sql.= " ORDER BY p.rowid"; + $sql.= " ".$db->plimit($MAXLIST); + $resql=$db->query($sql); + if ($resql) + { + $i = 0 ; + $num = $db->num_rows($resql); + if ($num > 0) + { + print '
'; - print ''; - print '
'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' ('.$num.')
'; - print '
'.img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref.''; - if ($obj->dc) - { - print dolibarr_print_date($obj->dc); - } - else - { - print "-"; - } - print '
'; + print ''; + print ''; + } + while ($i < $num && $i <= $MAXLIST) + { + $obj = $db->fetch_object($resql); + $var=!$var; + + print ""; + print ''; + print ''; print ''; - print ''; - $i++; - } - $db->free($resql); - if ($num > 0) - { - print "
'; + print ''; + print '
'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' ('.$num.')
'; + print '
'.img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref.''; + if ($obj->dc) + { + print dolibarr_print_date($obj->dc); + } + else + { + print "-"; + } + print ''.$orderstatic->LibStatut($obj->fk_statut,5).'

"; - } - } - else - { - dolibarr_print_error($db); - } + print '

"; + } + } + else + { + dolibarr_print_error($db); + } - /* - * Liste des factures associées - */ + /* + * Liste des factures associées + */ $MAXLIST=5; $langs->load('bills'); @@ -293,15 +296,15 @@ if ( $societe->fetch($socid) ) /* * Liste des produits */ - if ($conf->produit->enabled || $conf->service->enabled) - { - $langs->load("products"); - print ''; - print ''; - print '
'.$langs->trans("ProductsAndServices").''; - print ''.$langs->trans("All").' ('.$societe->NbProduct().')'; - print '

'; - } + if ($conf->produit->enabled || $conf->service->enabled) + { + $langs->load("products"); + print ''; + print ''; + print '
'.$langs->trans("ProductsAndServices").''; + print ''.$langs->trans("All").' ('.$societe->NbProduct().')'; + print '

'; + } print '
' . "\n"; @@ -313,98 +316,311 @@ if ( $societe->fetch($socid) ) * Barre d'actions * */ - + print '
'; - + if ($user->rights->fournisseur->commande->creer) { $langs->load("orders"); print ''.$langs->trans("AddOrder").''; } - + if ($user->rights->fournisseur->facture->creer) { $langs->load("bills"); print ''.$langs->trans("AddBill").''; } - - print ''.$langs->trans("AddAction").''; + + print ''.$langs->trans("AddAction").''; if ($user->rights->societe->contact->creer) { print "".$langs->trans("AddContact").""; } - + print '
'; - /* - * - * Liste des contacts - * - */ + /* + * + * Liste des contacts + * + */ $langs->load("companies"); - + print '
'; - + print ''; print ''; print ""; print ""; print ''; print ""; - - $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p"; - $sql.= " WHERE p.fk_soc = ".$societe->id; - $sql.= " ORDER by p.datec"; - $result = $db->query($sql); + $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note"; + $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p"; + $sql.= " WHERE p.fk_soc = ".$societe->id; + $sql.= " ORDER by p.datec"; - $i = 0 ; - $num = $db->num_rows($result); - $var=true; - - while ($i < $num) - { - $obj = $db->fetch_object($result); - $var = !$var; + $result = $db->query($sql); - print ""; + $i = 0 ; + $num = $db->num_rows($result); + $var=true; - print '"; + + print '"; + print ""; + print ''; + print ''; + print ''; + + if ($user->rights->societe->contact->creer) + { + print ""; + } + + print ''; + + print "\n"; + $i++; + } + print '
'.$langs->trans("Firstname").' '.$langs->trans("Lastname").''.$langs->trans("Poste").''.$langs->trans("Tel").'".$langs->trans("Fax")."".$langs->trans("EMail")."  
'; - print ''; - print img_object($langs->trans("ShowContact"),"contact"); - print ' '.$obj->firstname.' '. $obj->name.' '; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var = !$var; - if ($obj->note) + print "
'; + print ''; + print img_object($langs->trans("ShowContact"),"contact"); + print ' '.$obj->firstname.' '. $obj->name.' '; + + if ($obj->note) + { + print "
".nl2br($obj->note); + } + print "
$obj->poste '.$obj->phone.' '.$obj->fax.' '.$obj->email.' idp\">".img_edit()."'; + print img_object($langs->trans("Rendez-Vous"),"action"); + print '
'; + print '
'; + + /* + * Listes des actions a faire + * + */ + print ''; + print ''; + + $sql = "SELECT a.id, a.label, ".$db->pdate("a.datea")." as da, c.code as acode, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid "; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u "; + $sql .= " WHERE a.fk_soc = ".$societe->id; + $sql .= " AND u.rowid = a.fk_user_author"; + $sql .= " AND c.id=a.fk_action AND a.percent < 100"; + $sql .= " ORDER BY a.datea DESC, a.id DESC"; + + $result=$db->query($sql); + if ($result) + { + $i = 0 ; + $num = $db->num_rows($result); + $var=true; + + while ($i < $num) + { + $var = !$var; + + $obj = $db->fetch_object($result); + print ""; + + if ($oldyear == strftime("%Y",$obj->da) ) { - print "
".nl2br($obj->note); + print ''; + } + else + { + print '\n"; + $oldyear = strftime("%Y",$obj->da); } - print ""; - print ""; - print ''; - print ''; - print ''; - - if ($user->rights->societe->contact->creer) - { - print ""; - } - - print ''; - print "\n"; - $i++; - } - print "
'.$langs->trans("ActionsToDo").' 
|'.strftime("%Y",$obj->da)."$obj->poste '.$obj->phone.' '.$obj->fax.' '.$obj->email.' idp\">".img_edit()."'; - print img_object($langs->trans("Rendez-Vous"),"action"); - print '
"; + if ($oldmonth == strftime("%Y%b",$obj->da) ) + { + print '|'; + } + else + { + print '' .strftime("%b",$obj->da)."\n"; + $oldmonth = strftime("%Y%b",$obj->da); + } + + print ''.strftime("%d",$obj->da)."\n"; + print ''.strftime("%H:%M",$obj->da).''; + + // Picto warning + print ''; + if (date("U",$obj->da) < time()) print ' '.img_warning("Late"); + else print ' '; + print ''; + + // Status/Percent + print ' '; + + if ($obj->propalrowid) + { + print ''.img_object($langs->trans("ShowAction"),"task"); + $transcode=$langs->trans("Action".$obj->acode); + $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); + print $libelle; + print ''; + } + else + { + print ''.img_object($langs->trans("ShowAction"),"task"); + $transcode=$langs->trans("Action".$obj->acode); + $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); + print $libelle; + print ''; + } + + print ''.$obj->label.''; + + // Contact pour cette action + if ($obj->fk_contact) + { + $contact = new Contact($db); + $contact->fetch($obj->fk_contact); + print ''.img_object($langs->trans("ShowContact"),"contact").' '.$contact->fullname.''; + } else { + print ' '; + } + + // Auteur + print ''.img_object($langs->trans("ShowUser"),"user").' '.$obj->code.''; + print "\n"; + $i++; + } + + $db->free($result); + } else { + dolibarr_print_error($db); + } + print "
"; + + /* + * Listes des actions effectuées + */ + print ''; + print ''; + + $sql = "SELECT a.id, a.label, ".$db->pdate("a.datea")." as da,"; + $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; + $sql.= " c.code as acode, c.libelle,"; + $sql.= " u.code, u.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u "; + $sql.= " WHERE a.fk_soc = ".$societe->id; + $sql.= " AND u.rowid = a.fk_user_author"; + $sql.= " AND c.id=a.fk_action AND a.percent = 100"; + $sql.= " ORDER BY a.datea DESC, a.id DESC"; + + $result=$db->query($sql); + if ($result) + { + $i = 0 ; + $num = $db->num_rows($result); + $var=true; + + while ($i < $num) + { + $var = !$var; + + $obj = $db->fetch_object($result); + print ""; + + if ($oldyear == strftime("%Y",$obj->da) ) + { + print ''; + } else { + print '\n"; + $oldyear = strftime("%Y",$obj->da); + } + + if ($oldmonth == strftime("%Y%b",$obj->da) ) + { + print ''; + } else { + print '\n"; + $oldmonth = strftime("%Y%b",$obj->da); + } + + print '\n"; + print '\n"; + + // Picto + print ''; + + // Espace + print ''; + + // Action + print ''; + + // Objet li + print ''; + + // Libell + print ""; + + // Contact pour cette action + if ($obj->fk_contact) + { + $contact = new Contact($db); + $contact->fetch($obj->fk_contact); + print ''; + } + else + { + print ''; + } + + // Auteur + print ''; + print "\n"; + $i++; + } + $db->free(); + } + else + { + dolibarr_print_error($db); + } + + + print "
'.$langs->trans("ActionsDone").'
|'.strftime("%Y",$obj->da)."|'.strftime("%b",$obj->da)."'.strftime("%d",$obj->da)."'.strftime("%H:%M",$obj->da)."  '; + print ''.img_object($langs->trans("ShowTask"),"task"); + $transcode=$langs->trans("Action".$obj->acode); + $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); + print $libelle; + print ''; + print ''; + if ($obj->propalrowid) + { + print ''.img_object($langs->trans("ShowPropal"),"propal"); + print $langs->trans("Propal"); + print ''; + } + if ($obj->fk_facture) + { + print ''.img_object($langs->trans("ShowBill"),"bill"); + print $langs->trans("Invoice"); + print ''; + } + else print ' '; + print '$obj->label'.img_object($langs->trans("ShowContact"),"contact").' '.$contact->fullname.' '.img_object($langs->trans("ShowUser"),'user').' '.$obj->code.'
"; } else { - dolibarr_print_error($db); + dolibarr_print_error($db); } $db->close();