* * $Id$ * $Source$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ require("./pre.inc.php3"); require("../contact.class.php3"); llxHeader(); $db = new Db(); if ($sortorder == "") { $sortorder="ASC"; } if ($sortfield == "") { $sortfield="nom"; } $bc[0]="bgcolor=\"#c0f0c0\""; $bc[1]="bgcolor=\"#b0e0b0\""; $bc2[0]="bgcolor=\"#c9f000\""; $bc2[1]="bgcolor=\"#b9e000\""; $yn["t"] = "oui"; $yn["f"] = "non"; $yn["1"] = "oui"; $yn["0"] = "non"; $deacmeth["b"] = "robots"; $deacmeth["m"] = "manuelle"; if ($action == 'attribute_prefix') { $prefix_attrib = soc_attribute_prefix($db, $socid); } if ($action == 'recontact') { $dr = mktime(0, 0, 0, $remonth, $reday, $reyear); $sql = "INSERT INTO llx_soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $GLOBALS["REMOTE_USER"]."')"; $result = $db->query($sql); } if ($action == 'note') { $sql = "UPDATE societe SET note='$note' WHERE idp=$socid"; $result = $db->query($sql); } if ($action == 'stcomm') { if ($stcommid <> 'null' && $stcommid <> $oldstcomm) { $sql = "INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) "; $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $GLOBALS["REMOTE_USER"] . "')"; $result = @$db->query($sql); if ($result) { $sql = "UPDATE societe SET fk_stcomm=$stcommid WHERE idp=$socid"; $result = $db->query($sql); } else { $errmesg = "ERREUR DE DATE !"; } } if ($actioncommid) { $sql = "INSERT INTO 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 !"; } } } if ($page == -1) { $page = 0 ; } $limit = 26; $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; print "
"; print "<- Prev\n| "; print "*\n| "; for ($i = 65 ; $i < 91; $i++) { print ""; if ($begin == chr($i) ) { print "->" . chr($i) . "<-" ; } else { print chr($i) ; } print " | "; } print " Next ->\n"; print "

"; /* * Recherche * * */ if ($mode == 'search') { if ($mode-search == 'soc') { $sql = "SELECT s.idp FROM societe as s, c_stcomm as st "; $sql .= " WHERE s.fk_stcomm = st.id AND s.datea IS NOT NULL"; if ($socname) { $sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'"; $sortfield = "lower(s.nom)"; $sortorder = "ASC"; } $result = $db->query($sql); if ($result) { if ( $db->num_rows() == 1) { $obj = $db->fetch_object(0); $socid = $obj->idp; } $db->free(); } } else { } } /* * Mode fiche * * */ if ($socid > 0) { $sql = "SELECT s.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 societe as s, c_stcomm as st, c_typent as t, c_effectif as e "; $sql .= " WHERE s.fk_stcomm=st.id AND s.fk_typent = t.id AND s.fk_effectif = e.id"; if ($to == 'next') { $sql .= " AND s.idp > $socid ORDER BY idp ASC LIMIT 1"; } 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); $dac = strftime("%Y-%m-%d %H:%M", time()); if ($errmesg) { print "$errmesg
"; } print "

idp\" method=\"post\">"; print ""; print "fk_stcomm\">"; $sql = "SELECT st.id, st.libelle FROM c_stcomm as st ORDER BY id"; $result = $db->query($sql); print "\n"; $sql = "SELECT st.id, st.libelle FROM c_actioncomm as st ORDER BY id"; $result = $db->query($sql); print "\n"; print ""; print ""; print "
\n"; /* * */ print "\n"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
N° $objsoc->idp - $objsoc->nom - [$objsoc->stcomm]idp&action=add\">[Bookmark]idp&action=create\">[Projet]idp&action=create\">[Propal]idp\">Notesidp\">Contactsidp\">Fiche Technique[idp&action=edit\">Editer]
"; /* * * */ print "
"; print "\n"; print "\n"; print ''; /* * */ print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
Type $objsoc->typentEffectif$objsoc->effectif
Tel $objsoc->tel fax$objsoc->fax 
Ville".nl2br($objsoc->address)."
$objsoc->cp $objsoc->ville
sirensiren\">$objsoc->siren prefix"; if ($objsoc->prefix_comm) { print $objsoc->prefix_comm; } else { print "[idp&action=attribute_prefix\">Attribuer]"; } print "
Siteurl\">$objsoc->url 
"; /* * */ print "
'; print ''; print ""; print ''; print ''; /* * */ print '
Créée le" . strftime("%d %b %Y %H:%M", $objsoc->dc) . "

Statut commercial
'; /* * * Liste des statuts commerciaux * */ $limliste = 5 ; print "\n"; $sql = "SELECT a.id, ".$db->pdate("a.datel")." as da, c.libelle, a.author "; $sql .= " FROM socstatutlog as a, c_stcomm as c WHERE a.fk_soc = $objsoc->idp AND c.id=a.fk_statut ORDER by a.datel DESC"; if ( $db->query($sql) ) { $i = 0 ; $num = $db->num_rows(); $tag = True; while ($i < $num && $i < $limliste) { $obj = $db->fetch_object( $i); if ($tag) { print ""; } else { print ""; } print ""; print ""; print ""; print "\n"; $i++; $tag = !$tag; } $db->free(); if ($num > $limliste) { print ""; } } else { print $db->error(); } print "
". strftime("%d %b %Y %H:%M", $obj->da) ."$obj->libelle$obj->author
suite ...
"; print '
'; print '
"; /* * Propales */ $var=!$var; print ""; $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.remise, ".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid"; $sql .= " FROM societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; $sql .= " AND s.idp = $objsoc->idp ORDER BY p.datep DESC"; if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num >0 ) { print ""; } $i = 0; $now = time(); $lim = 3600 * 24 * 15 ; while ($i < $num && $i < 2) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; $i++; } $db->free(); } /* * Factures */ $sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, ".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid "; $sql .= " FROM societe as s,llx_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 < 2) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; if ($objp->df > 0 ) { print "\n"; } else { print "\n"; } print "\n"; $paye[1] = "payée"; $paye[0] = "non payée"; print "\n"; print "\n"; $i++; } $db->free(); } else { print $db->error(); } print "
idp\">liste des propales ($num)
propalid\">$objp->ref\n"; if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) { print " > 15 jours"; } print "".strftime("%d %B %Y",$objp->dp)."".price($objp->price - $objp->remise)."$objp->statut
idp\">liste des factures ($num)
facid\">$objp->facnumber".strftime("%d %B %Y",$objp->df)."!!!".number_format($objp->amount, 2, ',', ' ')."".$paye[$objp->paye]."
"; print "
"; /* * * Ventes * */ $sql = "SELECT p.rowid,p.label,p.ref,".$db->pdate("v.dated")." as dd,".$db->pdate("v.datef")." as df"; $sql .= " FROM llx_product as p, llx_ventes as v WHERE p.rowid = v.fk_product AND v.fk_soc = $objsoc->idp ORDER BY dated DESC"; 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 ""; $nw = time(); if ($nw <= $obj->df && $nw >= $obj->dd) { print ""; } else { print ""; } print ""; $i++; } $db->free(); print "
idp\">liste des ventes ($num)
$obj->label$obj->label".strftime("%d %b %Y", $obj->dd) ."".strftime("%d %b %Y", $obj->df) ."
"; } else { print $db->error(); } /* * * Liste des projets associés * */ $sql = "SELECT p.rowid,p.title,p.ref,".$db->pdate("p.dateo")." as do"; $sql .= " FROM llx_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 ""; $i++; } $db->free(); print "
idp\">liste des projets ($num)
'.$obj->title.'".strftime("%d %b %Y", $obj->do) ."
"; } else { print $db->error(); } /* * * */ print "
\n"; /* * * * */ if ($action == 'changevalue') { print "
"; print "
idp\" method=\"post\">"; print ""; print "Cette société est un cabinet de recrutement : "; print ""; print ""; print "
\n"; } else { /* * * 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 socpeople as p WHERE p.fk_soc = $objsoc->idp ORDER by p.datec"; $result = $db->query($sql); $i = 0 ; $num = $db->num_rows(); $tag = True; while ($i < $num) { $obj = $db->fetch_object( $i); if ($tag) { print ""; } else { print ""; } print ""; print ""; print ''; print ""; print ''; print ""; print "\n"; $i++; $tag = !$tag; } print "
Prénom NomPosteTélFaxEmailidp&action=addcontact\">Ajouter
$obj->firstname $obj->name"; if ($obj->note) { print "
".nl2br($obj->note); } print "
$obj->poste '.$obj->phone.' $obj->fax '.$obj->email.' idp&action=editcontact&contactid=$obj->idp\">Modifier
"; print "\n
\n"; /* * */ print ''; print ''; 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 actioncomm as a, c_actioncomm as c, llx_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"; if ( $db->query($sql) ) { print "\n"; print ''; $i = 0 ; $num = $db->num_rows(); $tag = True; while ($i < $num) { $obj = $db->fetch_object( $i); if ($tag) { print ""; } else { print ""; } print ""; 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++; $tag = !$tag; } print "
Actions
". strftime("%d %b %Y %H:%M", $obj->da) ."propalrowid\">$obj->libelle$obj->libelle'.$contact->fullname.' '.$obj->code.'
"; $db->free(); } else { print $db->error(); } print "
"; /* * * Notes sur la societe * */ print ''; print ""; print "
".nl2br($objsoc->note)."
"; /* * * * */ print "
"; print "
idp\" method=\"post\">"; print ""; $strmonth[1] = "Janvier"; $strmonth[2] = "Février"; $strmonth[3] = "Mars"; $strmonth[4] = "Avril"; $strmonth[5] = "Mai"; $strmonth[6] = "Juin"; $strmonth[7] = "Juillet"; $strmonth[8] = "Août"; $strmonth[9] = "Septembre"; $strmonth[10] = "Octobre"; $strmonth[11] = "Novembre"; $strmonth[12] = "Décembre"; $smonth = 1; $syear = date("Y", time()); print "A recontacter : "; print ""; $cmonth = date("n", time()); print ""; print ""; print ""; print "
\n"; /* * */ } } else { print $db->error() . "
" . $sql; } } else { /* * Mode Liste * * * */ $bc[1]="bgcolor=\"#90c090\""; $bc[0]="bgcolor=\"#b0e0b0\""; $sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm FROM societe as s, c_stcomm as st WHERE s.fk_stcomm = st.id AND s.client=1"; if (strlen($stcomm)) { $sql .= " AND s.fk_stcomm=$stcomm"; } if (strlen($begin)) { $sql .= " AND upper(s.nom) like '$begin%'"; } if ($socname) { $sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'"; $sortfield = "lower(s.nom)"; $sortorder = "ASC"; } $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; if ($sortorder == "DESC") { $sortorder="ASC"; } else { $sortorder="DESC"; } print "

"; print ""; print ""; print ""; print ""; print ""; print ""; print "\n"; $var=True; while ($i < $num) { $obj = $db->fetch_object( $i); $var=!$var; print ""; print ""; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $i++; } print "
IdSocieteContactemailStatut  
$obj->idpidp\">$obj->nom  $obj->stcomm$obj->prefix_comm idp&action=create\">[Propal]
"; $db->free(); } else { print $db->error(); } } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>