* Copyright (C) 2006 Rodolphe Quiedeville * Copyright (C) 2007 Patrick Raguin * * 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. * or see http://www.gnu.org/ */ /** \file htdocs/lib/company.lib.php \brief Ensemble de fonctions de base pour le module societe \ingroup societe \version $Id$ */ function societe_prepare_head($objsoc) { global $langs, $conf, $user; $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'company'; $h++; if ($objsoc->client==1) { $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Customer");; $head[$h][2] = 'customer'; $h++; } if ($objsoc->client==2) { $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Prospect"); $head[$h][2] = 'prospect'; $h++; } if ($objsoc->fournisseur) { $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Supplier"); $head[$h][2] = 'supplier'; $h++; } if ($conf->facture->enabled || $conf->compta->enabled || $conf->comptaexpert->enabled) { $langs->load("compta"); $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Accountancy"); $head[$h][2] = 'compta'; $h++; } //show categorie tab if ($conf->categorie->enabled) { $head[$h][0] = DOL_URL_ROOT.'/categories/categorie.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans('Categories'); $head[$h][2] = 'category'; $h++; } if ($user->societe_id == 0) { $head[$h][0] = DOL_URL_ROOT.'/societe/socnote.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; $h++; } if ($user->societe_id == 0) { $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Documents"); $head[$h][2] = 'document'; $h++; } if ($conf->notification->enabled && $user->societe_id == 0) { $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Notifications"); $head[$h][2] = 'notify'; $h++; } if ($objsoc->fournisseur) { $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche-stats.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Statistics"); $head[$h][2] = 'supplierstat'; $h++; } if ($user->societe_id == 0) { $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; } if ($conf->bookmark->enabled && $user->rights->bookmark->creer) { $head[$h][0] = DOL_URL_ROOT."/bookmarks/fiche.php?action=add&socid=".$objsoc->id."&urlsource=".$_SERVER["PHP_SELF"]."?socid=".$objsoc->id; $head[$h][1] = img_object($langs->trans("BookmarkThisPage"),'bookmark'); $head[$h][2] = 'image'; $h++; } return $head; } function societe_prepare_head2($objsoc) { global $langs, $conf, $user; $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'company'; $h++; $head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("BankAccount")." $account->number"; $head[$h][2] = 'rib'; $h++; $head[$h][0] = 'lien.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Links"); $head[$h][2] = 'links'; $h++; $head[$h][0] = 'commerciaux.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("SalesRepresentative"); $head[$h][2] = 'salesrepresentative'; $h++; return $head; } /** * \brief Retourne le nom traduit ou code+nom d'un pays * \param id id du pays * \param withcode 1=affiche code + nom * \return string Nom traduit du pays */ function getCountryLabel($id,$withcode=0) { global $db,$langs; $sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays"; $sql.= " WHERE rowid=".$id; dolibarr_syslog("Company.lib::getCountryLabel sql=".$sql); $resql=$db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) { $label=$obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:''); if ($withcode) return $label==$obj->code?"$obj->code":"$obj->code - $label"; else return $label; } else { return $langs->trans("NotDefined"); } $db->free($resql); } } /** * \brief Retourne le nom traduit de la forme juridique * \param code Code de la forme juridique * \return string Nom traduit du pays */ function getFormeJuridiqueLabel($code) { global $db,$langs; if (! $code) return ''; $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; $sql.= " WHERE code='$code'"; dolibarr_syslog("Company.lib::getFormeJuridiqueLabel sql=".$sql); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { $obj = $db->fetch_object($resql); $label=($obj->libelle!='-' ? $obj->libelle : ''); return $label; } else { return $langs->trans("NotDefined"); } } } /** * \brief Show html area with actions to do */ function show_actions_todo($conf,$langs,$db,$objsoc) { global $bc; if ($conf->agenda->enabled) { require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); $actionstatic=new ActionComm($db); $userstatic=new User($db); $contactstatic = new Contact($db); print_titre($langs->trans("ActionsOnCompany")); print ''; print ''; print ''; print ''; $sql = "SELECT a.id, a.label,"; $sql.= " ".$db->pdate("a.datep")." as dp,"; $sql.= " ".$db->pdate("a.datea")." as da,"; $sql.= " a.percent,"; $sql.= " c.code as acode, c.libelle, a.propalrowid, a.fk_user_author, a.fk_contact,"; $sql.= " u.login, u.rowid,"; $sql.= " sp.name, sp.firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; $sql.= " WHERE a.fk_soc = ".$objsoc->id; $sql.= " AND u.rowid = a.fk_user_author"; $sql.= " AND c.id=a.fk_action AND a.percent < 100"; $sql.= " ORDER BY a.datep DESC, a.id DESC"; dolibarr_syslog("company.lib::show_actions_todo sql=".$sql); $result=$db->query($sql); if ($result) { $i = 0 ; $num = $db->num_rows($result); $var=true; if ($num) { while ($i < $num) { $var = !$var; $obj = $db->fetch_object($result); print ""; print '\n"; $oldyear = strftime("%Y",$obj->dp); print '\n"; $oldmonth = strftime("%Y%b",$obj->dp); print '\n"; print ''; // Picto warning print ''; // Status/Percent print ''; if ($obj->propalrowid) { print ''; } else { $actionstatic->code=$obj->acode; $actionstatic->libelle=$obj->libelle; $actionstatic->id=$obj->id; print ''; } print ''; // Contact pour cette action if ($obj->fk_contact > 0) { $contactstatic->name=$obj->name; $contactstatic->firstname=$obj->firstname; $contactstatic->id=$obj->fk_contact; print ''; } else { print ''; } print ''; // Statut print ''; print "\n"; $i++; } } else { // Aucun action a faire } $db->free($result); } else { dolibarr_print_error($db); } print "
'.$langs->trans("ActionsToDoShort").' 
'.strftime("%Y",$obj->dp)."' .strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp).''; if (date("U",$obj->dp) < time()) print ' '.img_warning("Late"); else print ' '; print ' '.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; print ''.$actionstatic->getNomUrl(1,16).''.$obj->label.''.$contactstatic->getNomUrl(1).' '; $userstatic->id=$obj->fk_user_author; $userstatic->login=$obj->login; print $userstatic->getLoginUrl(1); print ''.$actionstatic->LibStatut($obj->percent,3).'
"; print "
"; } } /** * \brief Show html area with actions done */ function show_actions_done($conf,$langs,$db,$objsoc) { global $bc; if ($conf->agenda->enabled) { require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); $actionstatic=new ActionComm($db); $userstatic=new User($db); $contactstatic = new Contact($db); $facturestatic=new Facture($db); print ''; print ''; print ''; print ''; $sql = "SELECT a.id, a.label,"; $sql.= " ".$db->pdate("a.datep")." as dp,"; $sql.= " ".$db->pdate("a.datea")." as da,"; $sql.= " a.percent,"; $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; $sql.= " c.code as acode, c.libelle,"; $sql.= " u.login, u.rowid,"; $sql.= " sp.name, sp.firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; $sql.= " WHERE a.fk_soc = ".$objsoc->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"; dolibarr_syslog("comm/fiche.php sql=".$sql); $result=$db->query($sql); if ($result) { $i = 0 ; $num = $db->num_rows($result); $oldyear=''; $oldmonth=''; $var=true; while ($i < $num) { $var = !$var; $obj = $db->fetch_object($result); print ""; // Champ date print '\n"; $oldyear = strftime("%Y",$obj->dp); print '\n"; $oldmonth = strftime("%Y%b",$obj->dp); print '\n"; print '\n"; // Picto print ''; // Espace print ''; // Action print ''; // Objet lie print ''; // Libelle print ''; // Contact pour cette action if ($obj->fk_contact > 0) { $contactstatic->name=$obj->name; $contactstatic->firstname=$obj->firstname; $contactstatic->id=$obj->fk_contact; print ''; } else { print ''; } // Auteur print ''; // Statut print ''; print "\n"; $i++; } $db->free($result); } else { dolibarr_print_error($db); } print "
'.$langs->trans("ActionsDoneShort").'
'.strftime("%Y",$obj->dp)."'.strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp)."  '; $actionstatic->code=$obj->acode; $actionstatic->libelle=$obj->libelle; $actionstatic->id=$obj->id; print $actionstatic->getNomUrl(1,16); print ''; if ($obj->propalrowid) { print ''.img_object($langs->trans("ShowPropal"),"propal"); print $langs->trans("Propal"); print ''; } if ($obj->fk_facture) { $facturestatic->ref=$langs->trans("Invoice"); $facturestatic->id=$obj->fk_facture; $facturestatic->type=$obj->type; print $facturestatic->getNomUrl(1,'compta'); } else print ' '; print ''.$obj->label.''.$contactstatic->getNomUrl(1).' '; $userstatic->id=$obj->rowid; $userstatic->login=$obj->login; print $userstatic->getLoginUrl(1); print ''.$actionstatic->LibStatut($obj->percent,3).'

"; } } ?>