diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php index 38e678bbbb6..8e7a471f84c 100644 --- a/htdocs/compta/fiche.php +++ b/htdocs/compta/fiche.php @@ -32,8 +32,8 @@ require("../facture.class.php"); */ if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } $user->getrights('facture'); @@ -44,66 +44,66 @@ llxHeader(); if ($action=='add_action') { - /* - * Vient de actioncomm.php - * - */ - $actioncomm = new ActionComm($db); - $actioncomm->date = $date; - $actioncomm->type = $actionid; - $actioncomm->contact = $contactid; + /* + * Vient de actioncomm.php + * + */ + $actioncomm = new ActionComm($db); + $actioncomm->date = $date; + $actioncomm->type = $actionid; + $actioncomm->contact = $contactid; - $actioncomm->societe = $socid; - $actioncomm->note = $note; + $actioncomm->societe = $socid; + $actioncomm->note = $note; - $actioncomm->add($user); + $actioncomm->add($user); - $societe = new Societe($db); - $societe->fetch($socid); + $societe = new Societe($db); + $societe->fetch($socid); } if ($action == 'attribute_prefix') { - $societe = new Societe($db, $socid); - $societe->attribute_prefix($db, $socid); + $societe = new Societe($db, $socid); + $societe->attribute_prefix($db, $socid); } if ($action == 'recontact') { - $dr = mktime(0, 0, 0, $remonth, $reday, $reyear); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $user->login ."')"; - $result = $db->query($sql); + $dr = mktime(0, 0, 0, $remonth, $reday, $reyear); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $user->login ."')"; + $result = $db->query($sql); } if ($action == 'stcomm') { - if ($stcommid <> 'null' && $stcommid <> $oldstcomm) + 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 !"; - } + $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) + + 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 !"; - } + $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 !"; + } } } @@ -111,29 +111,28 @@ if ($action == 'stcomm') /* * Recherche * - * */ if ($mode == 'search') { - if ($mode-search == 'soc') + if ($mode-search == 'soc') { - $sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s "; - $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; - } - - if ( $db->query($sql) ) - { - if ( $db->num_rows() == 1) - { - $obj = $db->fetch_object(0); - $socid = $obj->idp; - } - $db->free(); + $sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s "; + $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; } - if ($user->societe_id > 0) + if ( $db->query($sql) ) { - $socid = $user->societe_id; + if ( $db->num_rows() == 1) + { + $obj = $db->fetch_object(0); + $socid = $obj->idp; + } + $db->free(); + } + + if ($user->societe_id > 0) + { + $socid = $user->societe_id; } } @@ -144,82 +143,94 @@ if ($mode == 'search') * * Mode fiche * - * - */ + */ if ($socid > 0) { - $societe = new Societe($db, $socid); - - $sql = "SELECT s.idp as idp, s.nom, ".$db->pdate("s.datec")." as dc, s.tel, s.fax, st.libelle as stcomm, s.fk_stcomm, s.url,s.address,s.cp,s.ville, s.note, t.libelle as typent, e.libelle as effectif, s.siren, s.prefix_comm, s.services,s.parent, s.description FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."c_typent as t, ".MAIN_DB_PREFIX."c_effectif as e "; - $sql .= " WHERE s.fk_stcomm=st.id AND s.fk_typent = t.id AND s.fk_effectif = e.id"; + $objsoc = new Societe($db); + $objsoc->id = $socid; + $objsoc->idp = $socid; + $objsoc->fetch($socid, $to); // si $to='next' ajouter " AND s.idp > $socid ORDER BY idp ASC LIMIT 1"; - if ($to == 'next') + + /* + * Affichage onglets + */ + $h = 0; + + $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$socid; + $head[$h][1] = "Fiche société"; + $h++; + + if ($objsoc->client==1) { - $sql .= " AND s.idp > $socid ORDER BY idp ASC LIMIT 1"; + $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid; + $head[$h][1] = 'Fiche client'; + $h++; } - elseif ($to == 'prev') { - $sql .= " AND s.idp < $socid ORDER BY idp DESC LIMIT 1"; - } else { - $sql .= " AND s.idp = $socid"; - } - - $result = $db->query($sql); - - if ($result) { - $objsoc = $db->fetch_object(0); - - if (! $objsoc->idp) { - print("Cette societe n'existe pas ou plus"); - $db->close(); - - llxFooter("Dernière modification $Date$ révision $Revision$"); - exit; - } - - $dac = strftime("%Y-%m-%d %H:%M", time()); - if ($errmesg) { - print "$errmesg
"; + if ($objsoc->client==2) + { + $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$socid; + $head[$h][1] = 'Fiche prospect'; + $h++; } + if ($objsoc->fournisseur) + { + $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid; + $head[$h][1] = 'Fiche fournisseur'; + $h++; + } + + if ($conf->compta->enabled) { + $hselected=$h; + $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$socid; + $head[$h][1] = 'Fiche compta'; + $h++; + } + + $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$socid; + $head[$h][1] = 'Note'; + $h++; + + if ($user->societe_id == 0) + { + $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$socid; + $head[$h][1] = 'Documents'; + $h++; + } + + $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$socid; + $head[$h][1] = 'Notifications'; + + dolibarr_fiche_head($head, $hselected); + /* * */ print "\n"; - print ""; - - if ($user->societe_id == 0) - { - print ''; - print ""; - print ""; - if ($user->rights->facture->creer) - print ""; - print ""; - print ""; - } - print "
Fiche client : $objsoc->nom
Commercial[idp\">Documents][idp&action=add\">Bookmark][idp\">".translate("Facturer")."][idp\">Notes][idp&action=create\">Déplacement]
"; /* - * - * - */ + * + * + */ print ''; print '"; + print ""; + } + + while ($i < $num && $i < 5) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + if ($objp->df > 0 ) + { + print "\n"; + } + else + { + print "\n"; + } + print "\n"; + + $fac = new Facture($db); + print "\n"; + print "\n"; + $i++; + } + $db->free(); + } + else + { + print $db->error(); + } + print "
'; print ''; + print ''; print ''; - print '"; + print '"; - print ''; + print ''; print ""; @@ -227,6 +238,12 @@ if ($socid > 0) print "
Nom'.$objsoc->nom.'
Tel'.$objsoc->tel.' Fax'.$objsoc->fax.' 
Ville'.nl2br($objsoc->address)."
$objsoc->cp $objsoc->ville
Ville'.nl2br($objsoc->adresse)."
$objsoc->cp $objsoc->ville
siren'.$objsoc->siren.' 
Siren'.$objsoc->siren.' prefix"; if ($objsoc->prefix_comm) - { - print $objsoc->prefix_comm; - } + { + print $objsoc->prefix_comm; + } else - { - print "[idp&action=attribute_prefix\">Attribuer]"; - } + { + print "[idp&action=attribute_prefix\">Attribuer]"; + } print "
"; + if ($user->societe_id == 0) + { + print "[id&action=add_bookmark\">Bookmark fiche]
"; + } + print "
"; + /* * */ @@ -237,50 +254,50 @@ if ($socid > 0) * Factures */ if ($user->rights->facture->lire) - { - print ''; - $var=!$var; - $sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, ".$db->pdate("f.datef")." as df, f.paye as paye, f.fk_statut as statut, f.rowid as facid "; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp AND s.idp = ".$objsoc->idp." ORDER BY f.datef DESC"; - - if ( $db->query($sql) ) - { - $num = $db->num_rows(); $i = 0; - if ($num > 0) - { - print ""; - print ""; - } - - while ($i < $num && $i < 5) - { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - if ($objp->df > 0 ) - { - print "\n"; - } - else - { - print "\n"; - } - print "\n"; + { + print '
idp\">Liste des factures ($num)
facid\">$objp->facnumber".strftime("%d %B %Y",$objp->df)."!!!".number_format($objp->amount, 2, ',', ' ')."
'; + $var=!$var; + $sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, ".$db->pdate("f.datef")." as df, f.paye as paye, f.fk_statut as statut, f.rowid as facid "; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp AND s.idp = ".$objsoc->idp." ORDER BY f.datef DESC"; - $fac = new Facture($db); - print "\n"; - print "\n"; - $i++; - } - $db->free(); - } - else - { - print $db->error(); - } - print "
".($fac->LibStatut($objp->paye,$objp->statut))."
"; - } + if ( $db->query($sql) ) + { + $num = $db->num_rows(); $i = 0; + if ($num > 0) + { + print "
idp\">Liste des factures ($num)
facid\">$objp->facnumber".strftime("%d %B %Y",$objp->df)."!!!".number_format($objp->amount, 2, ',', ' ')."".($fac->LibStatut($objp->paye,$objp->statut))."
"; + } /* @@ -291,26 +308,26 @@ if ($socid > 0) $sql = "SELECT p.rowid,p.title,p.ref,".$db->pdate("p.dateo")." as do"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p WHERE p.fk_soc = $objsoc->idp"; if ( $db->query($sql) ) { - print ""; - $i = 0 ; - $num = $db->num_rows(); - if ($num > 0) { - $tag = !$tag; print ""; - print ""; - } - while ($i < $num && $i < 5) { - $obj = $db->fetch_object( $i); - $tag = !$tag; - print ""; - print ''; + print "
idp\">liste des projets ($num)
'.$obj->title.'
"; + $i = 0 ; + $num = $db->num_rows(); + if ($num > 0) { + $tag = !$tag; print ""; + print ""; + } + while ($i < $num && $i < 5) { + $obj = $db->fetch_object( $i); + $tag = !$tag; + print ""; + print ''; - print ""; - $i++; - } - $db->free(); - print "
idp\">liste des projets ($num)
'.$obj->title.'".strftime("%d %b %Y", $obj->do) ."
"; + print "".strftime("%d %b %Y", $obj->do) .""; + $i++; + } + $db->free(); + print ""; } else { - print $db->error(); + print $db->error(); } /* @@ -318,167 +335,188 @@ if ($socid > 0) * */ print ""; - print "\n"; + print "\n"; + /* + * Barre d'actions * + */ + print '
'; + + if ($user->societe_id == 0) + { + if ($user->rights->facture->creer) + print "idp\">".translate("Facturer").""; + print "idp&action=create\">Créer Déplacement"; + } + + print 'Ajouter un contact'; + + print 'Notifications'; + + print '
'; + print '
'; + + /* * * */ if ($action == 'changevalue') { - print "
"; - print "
idp\" method=\"post\">"; - print ""; - print "Cette société est un cabinet de recrutement : "; - print ""; - print ""; - print "
\n"; + print "
"; + print "
idp\" method=\"post\">"; + print ""; + print "Cette société est un cabinet de recrutement : "; + print ""; + print ""; + print "
\n"; + } else { - /* - * - * Liste des contacts - * - */ - print ''; + /* + * + * Liste des contacts + * + */ + print '
'; - print ''; - print ''; - print ""; - print ""; - - $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note FROM ".MAIN_DB_PREFIX."socpeople as p WHERE p.fk_soc = $objsoc->idp ORDER by p.datec"; - $result = $db->query($sql); - $i = 0 ; $num = $db->num_rows(); + print ''; + print ''; + print ""; + print ""; - while ($i < $num) - { - $obj = $db->fetch_object( $i); - $var = !$var; + $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note FROM ".MAIN_DB_PREFIX."socpeople as p WHERE p.fk_soc = $objsoc->idp ORDER by p.datec"; + $result = $db->query($sql); + $i = 0 ; $num = $db->num_rows(); + $var=1; + while ($i < $num) + { + $obj = $db->fetch_object( $i); + $var = !$var; - print ""; + print ""; - print ''; - - if ($obj->note) - { - print "
".nl2br($obj->note); - } - print ""; - print ""; - print ''; - print ''; - print ''; - print ""; - print "\n"; - $i++; - $tag = !$tag; - } - print "
Prénom NomPosteTélFaxEmailidp&action=addcontact\">Ajouter
Prénom NomPosteTélFaxEmailAjouter
'; - //print ''; - //print ' '; - print ''.$obj->firstname.' '. $obj->name.' $obj->poste '.$obj->phone.' '.$obj->fax.' '.$obj->email.' idp&action=editcontact&contactid=$obj->idp\">Modifier
"; - - print "\n
\n"; - /* - * - */ - print ''; - print ''; - print ''; - if ( $db->query($sql) ) { - print "
'; - /* - * - * Listes des actions - * - */ - $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, 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 = $objsoc->idp "; - $sql .= " AND u.rowid = a.fk_user_author"; - $sql .= " AND c.id=a.fk_action "; - $sql .= " ORDER BY a.datea DESC, a.id DESC"; + print ''; + //print ''; + //print ' '; + print ''.$obj->firstname.' '. $obj->name.' 
\n"; + if ($obj->note) + { + print "
".nl2br($obj->note); + } + print ""; + print ""; + print ''; + print ''; + print ''; + print ""; + print "\n"; + $i++; + $tag = !$tag; + } + print "
$obj->poste '.$obj->phone.' '.$obj->fax.' '.$obj->email.' idp&action=editcontact&contactid=$obj->idp\">".img_edit()."
"; - $i = 0 ; $num = $db->num_rows(); - while ($i < $num) { - $var = !$var; + print "\n
\n"; + /* + * + */ + print ''; + print ''; + print '"; + if ( $db->query($sql) ) { + print "
'; + /* + * + * Listes des actions + * + */ + $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, 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 = $objsoc->idp "; + $sql .= " AND u.rowid = a.fk_user_author"; + $sql .= " AND c.id=a.fk_action "; + $sql .= " ORDER BY a.datea DESC, a.id DESC"; - $obj = $db->fetch_object( $i); - print "
\n"; - if ($oldyear == strftime("%Y",$obj->da) ) { - print ''; - } else { - print "\n"; - $oldyear = strftime("%Y",$obj->da); - } + $i = 0 ; $num = $db->num_rows(); + while ($i < $num) { + $var = !$var; - if ($oldmonth == strftime("%Y%b",$obj->da) ) { - print ''; - } else { - print "\n"; - $oldmonth = strftime("%Y%b",$obj->da); - } - - print "\n"; - print "\n"; + $obj = $db->fetch_object( $i); + print ""; - print ''; + if ($oldyear == strftime("%Y",$obj->da) ) { + print ''; + } else { + print "\n"; + $oldyear = strftime("%Y",$obj->da); + } - if ($obj->propalrowid) { - print ''; - } else { - print ''; - } - /* - * Contact pour cette action - * - */ - if ($obj->fk_contact) { - $contact = new Contact($db); - $contact->fetch($obj->fk_contact); - print ''; - } else { - print ''; - } - /* - */ - print ''; - print "\n"; - $i++; - } - print "
|" .strftime("%Y",$obj->da)."|" .strftime("%b",$obj->da)."" .strftime("%d",$obj->da)."" .strftime("%H:%M",$obj->da)."
 |" .strftime("%Y",$obj->da)."'.$obj->libelle.''.$obj->libelle.''.$contact->fullname.' '.$obj->code.'
"; + if ($oldmonth == strftime("%Y%b",$obj->da) ) { + print '|'; + } else { + print "" .strftime("%b",$obj->da)."\n"; + $oldmonth = strftime("%Y%b",$obj->da); + } - $db->free(); - } else { - print $db->error(); - } - print ""; - /* - * - * Notes sur la societe - * - */ - print ''; - print ""; - print "
".nl2br($objsoc->note)."
"; - /* - * - * - * - */ + print "" .strftime("%d",$obj->da)."\n"; + print "" .strftime("%H:%M",$obj->da)."\n"; + + print ' '; + + if ($obj->propalrowid) { + print ''.$obj->libelle.''; + } else { + print ''.$obj->libelle.''; + } + /* + * Contact pour cette action + * + */ + if ($obj->fk_contact) { + $contact = new Contact($db); + $contact->fetch($obj->fk_contact); + print ''.$contact->fullname.''; + } else { + print ' '; + } + /* + */ + print ''.$obj->code.''; + print "\n"; + $i++; + } + print ""; + + $db->free(); + } else { + print $db->error(); + } + print ""; + /* + * + * Notes sur la societe + * + */ + if ($objsoc->note) { + print ''; + print ""; + print "
".nl2br($objsoc->note)."
"; + } + /* + * + * + * + */ } - } else { - print $db->error() . "
" . $sql; - } + } else { - print "Erreur"; + print "Erreur"; } $db->close();