diff --git a/htdocs/categories/liste.php b/htdocs/categories/liste.php deleted file mode 100644 index a4527a56188..00000000000 --- a/htdocs/categories/liste.php +++ /dev/null @@ -1,79 +0,0 @@ - - * Copyright (C) 2006-2007 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 - * the Free Software Foundation; either version 3 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, see . - */ - -/** - * \file htdocs/categories/liste.php - * \ingroup category - * \brief Page liste des categories - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - -if (!$user->rights->categorie->lire) accessforbidden(); - - -llxHeader("","",$langs->trans("Categories")); - -print_fiche_titre($langs->trans("CatList")); - -print ''; - -print '
'; - -$c = new Categorie($db); -$cats = $c->get_all_categories(); - - -if ($cats != -1) -{ - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $var=true; - foreach ($cats as $cat) - { - $var = ! $var; - print "\t\n"; - print "\t\t\n"; - print "\t\t\n"; - print '\n"; - print "\t\n"; - } - print "
'.$langs->trans("Ref").''.$langs->trans("Description").''.$langs->trans("Type").'
".$cat->label."".dol_trunc($cat->description,36)."'; - if ($cat->type == 0) print $langs->trans("Product"); - elseif ($cat->type == 1) print $langs->trans("Supplier"); - elseif ($cat->type == 2) print $langs->trans("Customer"); - else print $cat->type; - print "
"; -} -else -{ - dol_print_error(); -} - -print '
'; - -$db->close(); - -llxFooter(); -?> diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 782d7444429..af09519cfef 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -183,7 +183,7 @@ if ($action == 'add_action') if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $actioncomm->use_phenix=1; // Check parameters - if ($actioncomm->type_code == 'AC_RDV' && ($datep == '' || $datef == '')) + if ($actioncomm->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent)))) { $error++; $action = 'create'; @@ -559,7 +559,7 @@ if ($action == 'create') } else { print $form->select_company('','socid','',1,1); } - + } print ''; diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 114fc6398e0..98f12489fea 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -55,16 +55,11 @@ $result = restrictedArea($user, 'societe',$socid,''); llxHeader('','Contacts'); -if ($type == "c") +if ($type == "c" || $type == "p") { $label = $langs->trans("Customers"); $urlfiche="fiche.php"; } -if ($type == "p") -{ - $label = $langs->trans("Prospects"); - $urlfiche="prospect/fiche.php"; -} if ($type == "f") { $label = $langs->trans("Suppliers"); diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 84987129be3..397fb9da835 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -31,6 +31,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -109,6 +110,24 @@ if ($action == 'setassujtva' && $user->rights->societe->creer) if (! $result) dol_print_error($result); } +// set prospect level +if ($action == 'setprospectlevel' && $user->rights->societe->creer) +{ + $object->fetch($id); + $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); + $result=$object->set_prospect_level($user); + if ($result < 0) setEventMessage($object->error,'errors'); +} + +// Update communication level +if ($action == 'cstc') +{ + $object->fetch($id); + $object->stcomm_id=GETPOST('stcomm','int'); + $result=$object->set_commnucation_level($user); + if ($result < 0) setEventMessage($object->error,'errors'); +} + /* @@ -121,6 +140,7 @@ llxHeader('',$langs->trans('CustomerCard')); $contactstatic = new Contact($db); $userstatic=new User($db); $form = new Form($db); +$formcompany=new FormCompany($db); if ($mode == 'search') @@ -176,6 +196,11 @@ if ($id > 0) $object->next_prev_filter="te.client in (1,3)"; print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print ''; + + // Prospect/Customer + print ''.$langs->trans('ProspectCustomer').''; + print $object->getLibCustProspStatut(); + print ''; // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field @@ -359,6 +384,31 @@ if ($id > 0) print ''.$object->price_level.""; print ''; } + + // Level of prospect + print ''; + print ''; + print '
'; + print $langs->trans('ProspectLevelShort'); + print ''; + if ($action != 'editlevel' && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('Modify'),1).'
'; + print ''; + if ($action == 'editlevel') + $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1); + else + print $object->getLibProspLevel(); + print ""; + print ''; + + // Status + print ''.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4).''; + print ''; + if ($object->stcomm_id != -1) print ''.img_action(0,-1).''; + if ($object->stcomm_id != 0) print ''.img_action(0,0).''; + if ($object->stcomm_id != 1) print ''.img_action(0,1).''; + if ($object->stcomm_id != 2) print ''.img_action(0,2).''; + if ($object->stcomm_id != 3) print ''.img_action(0,3).''; + print ''; // Sales representative include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index cc420c48d15..cfcd8ee121c 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -315,9 +315,7 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) print ''; print ''.$companystatic->getNomUrl(1,'customer',48).''; print ''; - if ($objp->client == 2 || $objp->client == 3) print $langs->trans("Prospect"); - if ($objp->client == 3) print ' / '; - if ($objp->client == 1 || $objp->client == 3) print $langs->trans("Customer"); + print $companystatic->getLibCustProspStatut(); print ""; print ''.dol_print_date($db->jdate($objp->tms),'day').""; print ''; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index cd2f44878ed..cc34443a622 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (! empty($conf->projet->enabled)) +if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; @@ -260,7 +260,7 @@ else if ($action == 'add' && $user->rights->propal->creer) $action='create'; $error++; } - + if ($socid<1) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors'); @@ -1174,7 +1174,7 @@ $now=dol_now(); if ($action == 'create') { print_fiche_titre($langs->trans("NewProp")); - + $soc = new Societe($db); if ($socid>0) $res=$soc->fetch($socid); @@ -1214,7 +1214,7 @@ if ($action == 'create') print '
'; print ''; print ''; - + if ($origin != 'project' && $originid) { print ''; @@ -1459,20 +1459,20 @@ if ($action == 'create') print "
"; } -else +else { /* * Show object in view mode */ - + $soc = new Societe($db); $soc->fetch($object->socid); - + $head = propal_prepare_head($object); dol_fiche_head($head, 'comm', $langs->trans('Proposal'), 0, 'propal'); - + $formconfirm=''; - + // Clone confirmation if ($action == 'clone') { @@ -1486,30 +1486,30 @@ else // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1); } - + // Confirm delete else if ($action == 'delete') { $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp',$object->ref), 'confirm_delete','',0,1); } - + // Confirm reopen else if ($action == 'reopen') { $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp',$object->ref), 'confirm_reopen','',0,1); } - + // Confirmation delete product/service line else if ($action == 'ask_deleteline') { $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1); } - + // Confirm validate proposal else if ($action == 'validate') { $error=0; - + // on verifie si l'objet est en numerotation provisoire $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') @@ -1525,7 +1525,7 @@ else { $numref = $object->ref; } - + $text=$langs->trans('ConfirmValidateProp',$numref); if (! empty($conf->notification->enabled)) { @@ -1534,29 +1534,29 @@ else $text.='
'; $text.=$notify->confirmMessage('NOTIFY_VAL_PROPAL',$object->socid); } - + if (! $error) $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1); } - + if (! $formconfirm) { $parameters=array('lineid'=>$lineid); $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } - + // Print form confirm print $formconfirm; - - + + print ''; - + $linkback = ''.$langs->trans("BackToList").''; - + // Ref print ''; - + // Ref client print '\n"; } @@ -462,23 +451,11 @@ class FormMail else { $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) + if (! empty($this->withtoccc) && is_array($this->withtoccc)) { $out.= " ".$langs->trans("or")." "; $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); } - if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); - } } //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); $out.= "\n"; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 87695a771b3..4fb851ce4d3 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -42,16 +42,7 @@ function societe_prepare_head($object) $head[$h][2] = 'card'; $h++; - // TODO Remove tests on object->object. Functions must be called with a company object directly - if (($object->client==2 || $object->client==3 - || (isset($object->object) && $object->object->client==2) || (isset($object->object) && $object->object->client==3)) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) - { - $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$object->id; - $head[$h][1] = $langs->trans("Prospect"); - $head[$h][2] = 'prospect'; - $h++; - } - if ($object->client==1 || $object->client==3 || (isset($object->object) && $object->object->client==1) || (isset($object->object) && $object->object->client==3)) + if ($object->client==1 || $object->client==2 || $object->client==3 || (isset($object->object) && $object->object->client==1) || (isset($object->object) && $object->object->client==3)) { $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$object->id; $head[$h][1] = $langs->trans("Customer"); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index dcf5d97ea56..60e8f79274c 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -110,7 +110,7 @@ $(document).ready(function () { fromname = $user->getFullName($langs); $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=GETPOST('sendto','int')?GETPOST('sendto','int'):1; - $formmail->withtosocid=$soc->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; + $liste=array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; + $formmail->withto=GETPOST("sendto")?GETOST("sendto"):$liste; + $formmail->withtocc=$liste; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans('SendShippingRef','__SHIPPINGREF__'); $formmail->withfile=2; $formmail->withbody=1; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 11e1eabd782..b2db591eefc 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1487,12 +1487,11 @@ else if ($id > 0 || ! empty($ref)) $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=(!GETPOST('sendto','alpha'))?1:GETPOST('sendto','alpha'); - $formmail->withtosocid=$societe->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; + $liste=array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; + $formmail->withto=GETPOST("sendto")?GETOST("sendto"):$liste; + $formmail->withtocc=$liste; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans('SendInterventionRef','__FICHINTERREF__'); $formmail->withfile=2; $formmail->withbody=1; diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index d5efaa8f22f..77df6da4f8f 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -106,6 +106,7 @@ if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users=0; if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb=0; if (empty($dolibarr_strict_mode)) $dolibarr_strict_mode=0; // For debug in php strict mode +// TODO Multicompany Remove this. Useless. if (empty($multicompany_transverse_mode)) $multicompany_transverse_mode=0; if (empty($multicompany_force_entity)) $multicompany_force_entity=0; // To force entity in login page diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index e8be8c28323..ffc123fe2de 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -344,6 +344,7 @@ class FactureFournisseur extends CommonInvoice $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; $this->import_key = $obj->import_key; $this->extraparams = (array) json_decode($obj->extraparams, true); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index ee802c3dc0f..24ecd0690b0 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1819,12 +1819,11 @@ if (! empty($object->id)) $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$object->thirdparty->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; + $liste=array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; + $formmail->withto=GETPOST("sendto")?GETOST("sendto"):$liste; + $formmail->withtocc=$liste; $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false); - $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans('SendOrderRef','__ORDERREF__'); $formmail->withfile=2; $formmail->withbody=1; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index fd6ffc2efe2..571742a977d 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -2008,7 +2008,7 @@ else $urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id; $genallowed=$user->rights->fournisseur->facture->creer; $delallowed=$user->rights->fournisseur->facture->supprimer; - $modelpdf=(! empty($object->modelpdf)?$object->modelpdf:''); + $modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)?'':$conf->global->INVOICE_SUPPLIER_ADDON_PDF)); print '
'; print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,0,0,'','','',$societe->default_lang); @@ -2075,12 +2075,11 @@ else $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$societe->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; + $liste=array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; + $formmail->withto=GETPOST("sendto")?GETOST("sendto"):$liste; + $formmail->withtocc=$liste; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans('SendBillRef','__FACREF__'); $formmail->withfile=2; $formmail->withbody=1; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 3974a93641a..9c20caed835 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -32,14 +32,14 @@ class Holiday extends CommonObject { public $element='holiday'; public $table_element='holiday'; - + var $db; var $error; var $errors=array(); var $rowid; var $ref; - + var $fk_user; var $date_create=''; var $description; @@ -72,16 +72,24 @@ class Holiday extends CommonObject function __construct($db) { $this->db = $db; - - // Mets à jour les congés payés en début de mois - $this->updateSoldeCP(); - - // Vérifie le nombre d'utilisateur et mets à jour si besoin - $this->verifNbUsers($this->countActiveUsers(),$this->getConfCP('nbUser')); - return 1; } + /** + * updateSold + * + * @return int Return 1 + */ + function updateSold() + { + // Mets à jour les congés payés en début de mois + $this->updateSoldeCP(); + + // Vérifie le nombre d'utilisateur et mets à jour si besoin + $this->verifNbUsers($this->countActiveUsers(),$this->getConfCP('nbUser')); + return 1; + } + /** * Créer un congés payés dans la base de données * @@ -358,10 +366,10 @@ class Holiday extends CommonObject $sql.= " uu.name as user_lastname,"; $sql.= " uu.firstname as user_firstname,"; - + $sql.= " ua.name as validator_lastname,"; $sql.= " ua.firstname as validator_firstname"; - + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; $sql.= " WHERE cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau @@ -415,10 +423,10 @@ class Holiday extends CommonObject $tab_result[$i]['user_firstname'] = $obj->user_firstname; $tab_result[$i]['user_lastname'] = $obj->user_lastname; - + $tab_result[$i]['validator_firstname'] = $obj->validator_firstname; $tab_result[$i]['validator_lastname'] = $obj->validator_lastname; - + $i++; } // Retourne 1 et ajoute le tableau à la variable @@ -601,13 +609,13 @@ class Holiday extends CommonObject { $this->fetchByUser($fk_user,'',''); - foreach($this->holiday as $infos_CP) + foreach($this->holiday as $infos_CP) { if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays - + // TODO Also use halfday for the check - if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) + if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) { return false; } @@ -627,23 +635,24 @@ class Holiday extends CommonObject function getNomUrl($withpicto=0) { global $langs; - + $result=''; - + $lien = ''; $lienfin=''; - + $picto='holiday'; - + $label=$langs->trans("Show").': '.$this->ref; - + if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; return $result; + } - + /** * Returns the label status * @@ -654,7 +663,7 @@ class Holiday extends CommonObject { return $this->LibStatut($this->statut, $mode, $this->date_debut); } - + /** * Returns the label of a statut * @@ -678,7 +687,7 @@ class Holiday extends CommonObject if ($mode == 2) { $pictoapproved='statut6'; - if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; + if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; if ($statut == 1) return img_picto($langs->trans('DraftCP'),'statut0').' '.$langs->trans('DraftCP'); // Draft if ($statut == 2) return img_picto($langs->trans('ToValidateCP'),'statut1').' '.$langs->trans('ToValidateCP'); // Waiting approval if ($statut == 3) return img_picto($langs->trans('ValidateCP'),$pictoapproved).' '.$langs->trans('ValidateCP'); @@ -688,18 +697,18 @@ class Holiday extends CommonObject if ($mode == 5) { $pictoapproved='statut6'; - if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; + if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; if ($statut == 1) return $langs->trans('DraftCP').' '.img_picto($langs->trans('DraftCP'),'statut0'); // Draft if ($statut == 2) return $langs->trans('ToValidateCP').' '.img_picto($langs->trans('ToValidateCP'),'statut1'); // Waiting approval if ($statut == 3) return $langs->trans('ValidateCP').' '.img_picto($langs->trans('ValidateCP'),$pictoapproved); if ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'),'statut5'); if ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'),'statut5'); } - + return $statut; } - + /** * Affiche un select HTML des statuts de congés payés * @@ -857,19 +866,21 @@ class Holiday extends CommonObject { // Si mise à jour pour tout le monde en début de mois $now=dol_now(); - + // Mois actuel $month = date('m',$now); $lastUpdate = $this->getConfCP('lastUpdate'); - $monthLastUpdate = date('m', $lastUpdate); + $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; + //print 'month: '.$month.' '.$lastUpdate.' '.$monthLastUpdate; // Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp if ($month != $monthLastUpdate) { $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".$this->db->idate($now)."'"; + $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; $sql.= " WHERE name = 'lastUpdate'"; + dol_syslog(get_class($this).'::updateSoldeCP sql='.$sql); $result = $this->db->query($sql); // On ajoute x jours à chaque utilisateurs diff --git a/htdocs/holiday/common.inc.php b/htdocs/holiday/common.inc.php index 8953352973b..133177df614 100644 --- a/htdocs/holiday/common.inc.php +++ b/htdocs/holiday/common.inc.php @@ -50,7 +50,7 @@ $sql.= " WHERE name = 'userGroup'"; $result = $db->query($sql); $obj = $db->fetch_object($result); -if ($obj->value == null) +if ($obj->value == null || $obj->value < 0) { llxHeader('',$langs->trans('CPTitreMenu')); diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php index c9f77a3f63e..19944b16ae8 100644 --- a/htdocs/holiday/index.php +++ b/htdocs/holiday/index.php @@ -73,6 +73,9 @@ $search_statut = GETPOST('select_statut'); $holiday = new Holiday($db); $holidaystatic=new Holiday($db); +// Update sold +$holiday->updateSold(); + $max_year = 5; $min_year = 10; $filter=''; diff --git a/htdocs/install/mysql/migration/2.0.0-2.1.0.sql b/htdocs/install/mysql/migration/2.0.0-2.1.0.sql index 94572f0378e..e2205b29953 100644 --- a/htdocs/install/mysql/migration/2.0.0-2.1.0.sql +++ b/htdocs/install/mysql/migration/2.0.0-2.1.0.sql @@ -75,8 +75,8 @@ insert into llx_cond_reglement(rowid, code, sortorder, active, libelle, libelle_ alter table llx_cond_reglement add (decalage smallint(6) default 0); -alter table llx_commande add fk_cond_reglement int(11) DEFAULT NULL; -alter table llx_commande add fk_mode_reglement int(11) DEFAULT NULL; +alter table llx_commande add fk_cond_reglement integer DEFAULT NULL; +alter table llx_commande add fk_mode_reglement integer DEFAULT NULL; alter table llx_categorie drop column fk_statut; diff --git a/htdocs/install/mysql/migration/2.1.0-2.2.0.sql b/htdocs/install/mysql/migration/2.1.0-2.2.0.sql index cfaa7ce105e..070682d3c50 100644 --- a/htdocs/install/mysql/migration/2.1.0-2.2.0.sql +++ b/htdocs/install/mysql/migration/2.1.0-2.2.0.sql @@ -143,8 +143,8 @@ alter table llx_categorie ADD type int not null default '0'; -- V4 ALTER TABLE llx_categorie DROP INDEX uk_categorie_ref; create table `llx_categorie_societe` ( - `fk_categorie` int(11) not null, - `fk_societe` int(11) not null, + `fk_categorie` integer not null, + `fk_societe` integer not null, UNIQUE KEY `fk_categorie` (`fk_categorie`,`fk_societe`), KEY `fk_societe` (`fk_societe`) ) ENGINE=innodb; @@ -154,8 +154,8 @@ alter table `llx_categorie_societe` add constraint `fk_categorie_societe_categor alter table `llx_categorie_societe` add constraint `fk_categorie_societe_fk_soc` foreign key(`fk_societe`) REFERENCES `llx_societe` (`rowid`); create table `llx_categorie_product` ( - `fk_categorie` int(11) not null, - `fk_product` int(11) not null, + `fk_categorie` integer not null, + `fk_product` integer not null, PRIMARY KEY (`fk_categorie`,`fk_product`), KEY `idx_categorie_product_fk_categorie` (`fk_categorie`), KEY `idx_categorie_product_fk_product` (`fk_product`) @@ -169,24 +169,24 @@ alter table `llx_categorie_product` -- Ajout gestion du droit de pret drop table if exists `llx_droitpret_rapport`; create table `llx_droitpret_rapport` ( - `rowid` int(11) NOT NULL auto_increment, + `rowid` integer NOT NULL auto_increment, `date_envoie` datetime NOT NULL, `format` varchar(10) NOT NULL, `date_debut` datetime NOT NULL, `date_fin` datetime NOT NULL, `fichier` varchar(255) NOT NULL, - `nbfact` int(11) NOT NULL, + `nbfact` integer NOT NULL, PRIMARY KEY (`rowid`) ) ENGINE=innodb; -- Gestion des menu CREATE TABLE `llx_menu` ( - `rowid` int(11) NOT NULL, + `rowid` integer NOT NULL, `menu_handler` varchar(16) NOT NULL default 'auguria', `type` enum('top','left') NOT NULL default 'left', `mainmenu` varchar(100) NOT NULL, - `fk_menu` int(11) NOT NULL, + `fk_menu` integer NOT NULL, `order` tinyint(4) NOT NULL, `url` varchar(255) NOT NULL, `target` varchar(100) NULL, @@ -200,15 +200,15 @@ CREATE TABLE `llx_menu` ( ) ENGINE=innodb; create table `llx_menu_constraint` ( - `rowid` int(11) NOT NULL, + `rowid` integer NOT NULL, `action` varchar(255) NOT NULL, PRIMARY KEY (`rowid`) ) ENGINE=innodb; create table `llx_menu_const` ( - `rowid` int(11) NOT NULL auto_increment, - `fk_menu` int(11) NOT NULL, - `fk_constraint` int(11) NOT NULL, + `rowid` integer NOT NULL auto_increment, + `fk_menu` integer NOT NULL, + `fk_constraint` integer NOT NULL, `user` tinyint(4) NOT NULL default '2', PRIMARY KEY (`rowid`) ) ENGINE=innodb; diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index 0a5a4a94642..093265e217c 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -33,3 +33,6 @@ UPDATE llx_const set value='smartphone_menu.php' where value='smartphone_frontof ALTER TABLE llx_user add COLUMN fk_user integer; +-- margin on contracts +alter table llx_contratdet add column fk_product_fournisseur_price integer after info_bits; +alter table llx_contratdet add column buy_price_ht double(24,8) DEFAULT 0 after fk_product_fournisseur_price; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_contratdet.sql b/htdocs/install/mysql/tables/llx_contratdet.sql index e7dc0354aba..ac4eea1de83 100644 --- a/htdocs/install/mysql/tables/llx_contratdet.sql +++ b/htdocs/install/mysql/tables/llx_contratdet.sql @@ -52,7 +52,9 @@ create table llx_contratdet total_localtax1 double(24,8) DEFAULT 0, -- Total Local tax 1 de la ligne total_localtax2 double(24,8) DEFAULT 0, -- Total Local tax 2 de la ligne total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale - info_bits integer DEFAULT 0, -- TVA NPR ou non + info_bits integer DEFAULT 0, -- TVA NPR ou non + fk_product_fournisseur_price integer DEFAULT NULL, -- supplier price id + buy_price_ht double(24,8) DEFAULT NULL, -- buying price fk_user_author integer NOT NULL DEFAULT 0, fk_user_ouverture integer, diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0fafedaf2b0..42924eb253f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -50,6 +50,7 @@ DisableJavascript=Disable JavaScript and Ajax functions ConfirmAjax=Use Ajax confirmation popups UseSearchToSelectCompany=Use autocompletion fields to choose third parties (instead of using a list box).

Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant SOCIETE_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. ActivityStateToSelectCompany= Add a filter option to show/hide thirdparties which are currently in activity or has ceased it +UseSearchToSelectContact=Use autocompletion fields to choose contact (instead of using a list box).

Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant CONTACT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. SearchFilter=Search filters options NumberOfKeyToSearch=Nbr of characters to trigger search: %s ViewFullDateActions=Show full dates events in the third sheet diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 3d180e7b747..2355c112194 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -15,7 +15,7 @@ MyEvents=My events OtherEvents=Other events ListOfActions=List of events Location=Location -EventOnFullDay=Event on full day +EventOnFullDay=Event on all day(s) SearchAnAction= Search an event/task MenuToDoActions= All incomplete events MenuDoneActions= All terminated events diff --git a/htdocs/langs/es_ES/dict.lang b/htdocs/langs/es_ES/dict.lang index bf0b59e3ef1..c0cd7042334 100644 --- a/htdocs/langs/es_ES/dict.lang +++ b/htdocs/langs/es_ES/dict.lang @@ -85,7 +85,7 @@ CountryDM=Dominica CountryDO=República Dominicana CountryEC=Ecuador CountryEG=Egipto -CountrySV=Salvador +CountrySV=El Salvador CountryGQ=Guinea Ecuatorial CountryER=Eritrea CountryEE=Estonia diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index f9ffd05c060..802bbb28191 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -49,6 +49,7 @@ DisableJavascript= Désactiver les fonctions Javascript et Ajax ConfirmAjax= Utiliser les popups de confirmation Ajax UseSearchToSelectCompany= Utiliser un champ avec autocomplétion pour choisir un tiers (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. ActivityStateToSelectCompany= Ajouter une option de filtrage lors des recherches pour afficher/masquer les tiers en exercice ou ayant cessés d'exercer +UseSearchToSelectContact= Utiliser un champ avec autocomplétion pour choisir un contact (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante CONTACT_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. SearchFilter=Options des filtres de recherche NumberOfKeyToSearch=Nb carac. déclenchant recherche: %s ViewFullDateActions= Visualiser les dates des actions en entier dans la fiche tiers @@ -313,7 +314,7 @@ FirstnameNamePosition=Ordre affichage prénom/nom DescWeather=Les graphiques suivant seront affichées sur le tableau de bord si le nombre d'éléments en retard atteints ces valeurs: KeyForWebServicesAccess=Clé pour utiliser les Web Services (paramètre "dolibarrkey" dans les webservices) TestSubmitForm=Formulaire de test de saisie -ThisForceAlsoTheme=Utiliser ce gestionnaire de menu force aussi le theme quelquesoit le choix de theme de l'utilisateur. De plus, ce gestionnaire de menu, spécialisé pour smartphone, ne fonctionne que sur certains téléphones. Utiliser un autre gestionnaire si vous constatez des problèmes. +ThisForceAlsoTheme=Utiliser ce gestionnaire de menu force aussi le thème quelque soit le choix de thème de l'utilisateur. De plus, ce gestionnaire de menu, spécialisé pour smartphone, ne fonctionne que sur certains téléphones. Utilisez un autre gestionnaire si vous constatez des problèmes. ThemeDir=Répertoire des thèmes ConnectionTimeout=Timeout de connexion ResponseTimeout=Timeout de réponse @@ -445,7 +446,7 @@ Module1200Desc= Interface avec le bug tracking Mantis Module1400Name= Comptabilité Module1400Desc= Gestion de la comptabilité (doubles parties) Module1780Name= Catégories -Module1780Desc= Gestion des catégories (produits, fournisseurs et clients) +Module1780Desc= Gestion des catégories (produits, fournisseurs, clients et adhérents) Module2000Name= Editeur WYSIWYG Module2000Desc= Permet la saisie de certaines zones de textes grace à un éditeur avancé Module2200Name= Droit de prêts @@ -458,6 +459,8 @@ Module2500Name= Gestion Electronique de Documents Module2500Desc= Permet de stocker et administrer une base de documents Module2600Name= WebServices Module2600Desc= Active le serveur de Web Services de Dolibarr +Module2650Name= Ultimatepdf +Module2650Desc= Gestion de la présentation des modèles de pdf (propales, factures, commandes etc...) Module2700Name= Gravatar Module2700Desc= Utilise le service en ligne Gravatar (www.gravatar.com) pour afficher les photos d'utilisateurs/membres (qui se trouvent avec leurs e-mails). Besoin d'un accès Internet Module2900Name= GeoIPMaxmind @@ -943,7 +946,7 @@ TranslationSetup=Translation setup TranslationDesc=Le choix de la langue affichée à l'écran se modifie:
* Soit de manière globale depuis le menu Accueil - Configuration - Affichage
* Soit de manière spécifique à l'utilisateur depuis l'onglet Interface utilisateur de sa fiche utilisateur (cliquer sur le login en haut de l'écran). ClassNotFoundIntoPathWarning=La class %s n'a pas été trouvée dans le path PHP YesInSummer=Oui en été -OnlyFollowingModulesAreOpenedToExternalUsers=Remarque, seuls les modules suivants sont ouverts aux utilisateurs externes (quelquesoit les permissions de ces utilisateurs): +OnlyFollowingModulesAreOpenedToExternalUsers=Remarque, seuls les modules suivants sont ouverts aux utilisateurs externes (quelque soit les permissions de ces utilisateurs): ##### Module password generation= undefined PasswordGenerationStandard= Renvoie un mot de passe généré selon algorithme interne Dolibarr: 8 caractères, chiffres et caractères en minuscules mélangés. diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index d91f836d9b9..33555be6951 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -14,7 +14,7 @@ EventsNb=Nombre d'événements MyEvents=Mes événements OtherEvents=Autres événements ListOfActions=Liste des événements -EventOnFullDay=Événement sur la journée +EventOnFullDay=Événement sur la(les) journée(s) Location=Lieu SearchAnAction=Rechercher un événement/tâche MenuToDoActions=Les événem. incomplets diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f7081340f8a..202a7c0dfb1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -584,6 +584,7 @@ if (! defined('NOLOGIN')) } // Create entity cookie, just used for login page + // TODO Multicompany Move this into hook if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_COOKIE_ENABLED) && isset($_POST["entity"])) { include_once DOL_DOCUMENT_ROOT.'/core/class/cookie.class.php'; @@ -754,6 +755,7 @@ else $heightforframes=52; // Switch to another entity +// TODO Multicompany Remove this if (! empty($conf->multicompany->enabled) && GETPOST('action') == 'switchentity') { if ($mc->switchEntity(GETPOST('entity','int')) > 0) diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 41bfa6d3a91..b62ee1c9371 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -75,6 +75,7 @@ if (! empty($dolibarr_main_document_root_alt)) } // Set properties specific to multicompany +// TODO Multicompany Remove this. Useless. Var should be read when required. $conf->multicompany->transverse_mode = empty($multicompany_transverse_mode)?'':$multicompany_transverse_mode; // Force Multi-Company transverse mode $conf->multicompany->force_entity = empty($multicompany_force_entity)?'':(int) $multicompany_force_entity; // Force entity in login page @@ -141,6 +142,7 @@ if (! defined('NOREQUIREDB')) { $conf->entity = DOLENTITY; } + // TODO Multicompany Remove this. else if (! empty($conf->multicompany->force_entity) && is_int($conf->multicompany->force_entity)) // To force entity in login page { $conf->entity = $conf->multicompany->force_entity; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 8f91e30b257..8724671c20d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2186,7 +2186,7 @@ class Product extends CommonObject } // Recursive call - if (is_array($desc_pere)) + if (is_array($desc_pere)>2) { $this ->fetch_prod_arbo($desc_pere, $nom_pere." -> ", $desc_pere[1]*$multiply, $level+1); } @@ -2340,12 +2340,13 @@ class Product extends CommonObject $prods = array(); while ($rec = $this->db->fetch_array($res)) { + $prods[$rec['rowid']]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type'],3=>$this->db->escape($rec['label'])); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); - $prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); + //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); $listofchilds=$this->getChildsArbo($rec['id']); foreach($listofchilds as $keyChild => $valueChild) { - $prods[$this->db->escape($rec['label'])][$keyChild] = $valueChild; + $prods[$rec['rowid']][$keyChild] = $valueChild; } } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 3bb95dd10ee..1b0efa2c4b2 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -82,6 +82,21 @@ if ($action == 'COMPANY_USE_SEARCH_TO_SELECT') } } +if ($action == 'CONTACT_USE_SEARCH_TO_SELECT') +{ + $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT','alpha'); + $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } +} + // Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) if ($action == 'setModuleOptions') { @@ -647,9 +662,37 @@ else print ''; print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ""; +print ''; +if (! $conf->use_javascript_ajax) +{ + print '"; +} +else +{ + print '"; +} +print ''; print '
'.$langs->trans('Ref').''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print '
'; print ''; print ''; - + // Company print ''; print ''; - + // Ligne info remises tiers print ''; - + // Date of proposal print ''; print ''; - + // Date end proposal print ''; print ''; print ''; - + // Payment term print ''; print ''; print ''; + if ($conf->margin->enabled) + print ''; print ''; print "\n"; @@ -932,6 +958,10 @@ else { print ''; } + + if ($conf->margin->enabled) + print ''; + // Icon move, update et delete (statut contrat 0=brouillon,1=valide,2=ferme) print ''; - print '"; print ''; print ''; print ''; + if ($conf->margin->enabled) { + print ''; + } print ''; // Ligne dates prevues print ""; - print ''; - print ''; + print ''; print "\n"; } @@ -1213,7 +1251,7 @@ else print ''; - print ''; + print ''; print '
'; @@ -1580,11 +1580,11 @@ else } print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Discounts').''; if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); @@ -1614,7 +1614,7 @@ else } if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; print '
'; @@ -1645,7 +1645,7 @@ else } } print '
'; @@ -1678,7 +1678,7 @@ else } print '
'; print ''; print ''; - + // Delivery date $langs->load('deliveries'); print ''; print ''; - + // Delivery delay print '
'; @@ -1697,7 +1697,7 @@ else } print '
'; @@ -1722,7 +1722,7 @@ else } print '
'; print ''; print ''; - + // Origin of demand print ''; $form_close.= '
'; @@ -1740,10 +1740,10 @@ else { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'none',1); } - + print '
'; print ''; print ''; - + // Payment mode print ''; print ''; - + // Project if (! empty($conf->projet->enabled)) { @@ -1825,7 +1825,7 @@ else } print ''; } - + // Other attributes $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1841,12 +1841,12 @@ else print ''."\n"; } } - + // Amount HT print ''; print ''; print ''; - + // Margin Infos if (! empty($conf->margin->enabled)) { print ''; } print ''; - + // Amount VAT print ''; print ''; print ''; - + // Amount Local Taxes if ($mysoc->localtax1_assuj=="1") //Localtax1 { @@ -1873,55 +1873,55 @@ else print ''; print ''; } - - + + // Amount TTC print ''; print ''; print ''; - + // Statut print ''; - + print '
'; @@ -1761,10 +1761,10 @@ else { $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'none'); } - + print '
'; @@ -1783,7 +1783,7 @@ else $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); } print '
'.$langs->trans('AmountHT').''.price($object->total_ht).''.$langs->trans("Currency".$conf->currency).''; @@ -1854,12 +1854,12 @@ else print '
'.$langs->trans('AmountVAT').''.price($object->total_tva).''.$langs->trans("Currency".$conf->currency).'
'.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('Status').''.$object->getLibStatut(4).'

'; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - + /* * Lines */ - + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } - + print ''; - + // Show object lines $result = $object->getLinesArray(); if (! empty($object->lines)) $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid); - + // Form to add new line if ($object->statut == 0 && $user->rights->propal->creer) { if ($action != 'editline') { $var=true; - + if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services @@ -1931,7 +1931,7 @@ else { // Add free products/services $object->formAddFreeProduct(0,$mysoc,$soc); - + // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { @@ -1939,17 +1939,17 @@ else $object->formAddPredefinedProduct(0,$mysoc,$soc); } } - + $parameters=array(); $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } } - + print '
'; - + print ''; print "\n"; - + if ($action == 'statut') { /* @@ -1975,18 +1975,18 @@ else $form_close.= ' '; $form_close.= '
'; - + print $form_close; } - - + + /* * Boutons Actions */ if ($action != 'presend') { print '
'; - + if ($action != 'statut' && $action <> 'editline') { // Validate @@ -1995,20 +1995,20 @@ else if (count($object->lines) > 0) print ''.$langs->trans('Validate').''; else print ''.$langs->trans('Validate').''; } - + // Edit if ($object->statut == 1 && $user->rights->propal->creer) { print ''.$langs->trans('Modify').''; } - + // ReOpen if (($object->statut == 2 || $object->statut == 3) && $user->rights->propal->cloturer) { print 'global->MAIN_JUMP_TAG)?'':'#reopen').'"'; print '>'.$langs->trans('ReOpen').''; } - + // Send if ($object->statut == 1 || $object->statut == 2) { @@ -2018,7 +2018,7 @@ else } else print ''.$langs->trans('SendByMail').''; } - + // Create an order if (! empty($conf->commande->enabled) && $object->statut == 2 && $user->societe_id == 0) { @@ -2027,7 +2027,7 @@ else print ''.$langs->trans("AddOrder").''; } } - + // Create an invoice and classify billed if ($object->statut == 2 && $user->societe_id == 0) { @@ -2035,46 +2035,46 @@ else { print ''.$langs->trans("AddBill").''; } - + $arraypropal=$object->getInvoiceArrayList(); if (is_array($arraypropal) && count($arraypropal) > 0) { print 'socid.'">'.$langs->trans("ClassifyBilled").''; } } - + // Close if ($object->statut == 1 && $user->rights->propal->cloturer) { print 'global->MAIN_JUMP_TAG)?'':'#close').'"'; print '>'.$langs->trans('Close').''; } - + // Clone if ($user->rights->propal->creer) { print ''.$langs->trans("ToClone").''; } - + // Delete if ($user->rights->propal->supprimer) { print ''.$langs->trans('Delete').''; } - + } - + print '
'; print "
\n"; } - + if ($action != 'presend') { print '
'; print ''; // ancre - - + + /* * Documents generes */ @@ -2083,28 +2083,28 @@ else $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed=$user->rights->propal->creer; $delallowed=$user->rights->propal->supprimer; - + $var=true; - + $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang); - - + + /* * Linked object block */ $somethingshown=$object->showLinkedObjectBlock(); - + print ''; - + // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); $somethingshown=$formactions->showactions($object,'propal',$socid); - + print '
'; } - - + + /* * Action presend * @@ -2115,7 +2115,7 @@ else include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); $file=$fileparams['fullname']; - + // Build document if it not exists if (! $file || ! is_readable($file)) { @@ -2129,7 +2129,7 @@ else $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - + $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { @@ -2139,10 +2139,10 @@ else $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); $file=$fileparams['fullname']; } - + print '
'; print_titre($langs->trans('SendPropalByMail')); - + // Create form object include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -2151,18 +2151,17 @@ else $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$soc->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; + $liste=array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; + $formmail->withto=GETPOST("sendto")?GETPOST("sendto"):$liste; + $formmail->withtocc=$liste; $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false); - $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); $formmail->withfile=2; $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; - + // Tableau des substitutions $formmail->substit['__PROPREF__']=$object->ref; $formmail->substit['__SIGNATURE__']=$user->signature; @@ -2172,16 +2171,16 @@ else $formmail->param['models']='propal_send'; $formmail->param['id']=$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - + // Init list of files if (GETPOST("mode")=='init') { $formmail->clear_attached_files(); $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); } - + $formmail->show_form(); - + print '
'; } } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index b2f1f8dcc44..4063802ffa4 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -322,14 +322,7 @@ if ($result) print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '
'; - if ($objp->client == 1) - { - $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->rowid; - } - else - { - $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objp->rowid; - } + $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->rowid; // Company $companystatic->id=$objp->rowid; diff --git a/htdocs/comm/prospect/class/prospect.class.php b/htdocs/comm/prospect/class/prospect.class.php index 68440aa0b84..ec0454c4847 100644 --- a/htdocs/comm/prospect/class/prospect.class.php +++ b/htdocs/comm/prospect/class/prospect.class.php @@ -148,9 +148,9 @@ class Prospect extends Societe * * @return string Libelle */ - function getLibLevel() + function getLibProspLevel() { - return $this->LibLevel($this->fk_prospectlevel); + return $this->LibProspLevel($this->fk_prospectlevel); } /** @@ -159,7 +159,7 @@ class Prospect extends Societe * @param int $fk_prospectlevel Prospect level * @return string Libelle du niveau */ - function LibLevel($fk_prospectlevel) + function LibProspLevel($fk_prospectlevel) { global $langs; diff --git a/htdocs/comm/prospect/fiche.php b/htdocs/comm/prospect/fiche.php deleted file mode 100644 index dc447122561..00000000000 --- a/htdocs/comm/prospect/fiche.php +++ /dev/null @@ -1,343 +0,0 @@ - - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * - * 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 3 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, see . - */ - -/** - * \file htdocs/comm/prospect/fiche.php - * \ingroup prospect - * \brief Page de la fiche prospect - */ - -require_once '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/prospect/class/prospect.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - -$langs->load('companies'); -$langs->load('projects'); -$langs->load('propal'); - -$action=GETPOST('action', 'alpha'); - -// Security check -$socid = GETPOST('socid','int'); -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'societe', $socid, '&societe'); - -$object = new Prospect($db); - - -/* - * Actions - */ - -if ($action == 'cstc') -{ - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["stcomm"]; - $sql .= " WHERE rowid = ".$socid; - $db->query($sql); -} -// set prospect level -if ($action == 'setprospectlevel' && $user->rights->societe->creer) -{ - $object->fetch($socid); - $object->fk_prospectlevel=$_POST['prospect_level_id']; - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_prospectlevel='".$_POST['prospect_level_id']; - $sql.= " WHERE rowid = ".$socid; - $result = $db->query($sql); - if (! $result) dol_print_error($result); -} - - -/********************************************************************************* - * - * Mode fiche - * - *********************************************************************************/ - -llxHeader(); - -$now = dol_now(); - -$form=new Form($db); -$formcompany=new FormCompany($db); - -if ($socid > 0) -{ - $actionstatic=new ActionComm($db); - $result = $object->fetch($socid); - if ($result < 0) - { - dol_print_error($db); - exit; - } - - /* - * Affichage onglets - */ - $head = societe_prepare_head($object); - - dol_fiche_head($head, 'prospect', $langs->trans("ThirdParty"),0,'company'); - - print ''; - print '\n"; - print '"; - print "
'; - - print ''; - print ''; - - // Address - print '"; - - // Zip / Town - print ''; - print ''; - - // Country - print ''; - - // Phone - print ''; - print ''; - - // EMail - print ''; - - // Web - print '"; - - // Level of prospect - print '"; - print ''; - - // Multiprice level - if (! empty($conf->global->PRODUIT_MULTIPRICES)) - { - print '"; - print ''; - } - - // Status - print ''; - print ''; - - // Sales representative - include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; - - // Module Adherent - if (! empty($conf->adherent->enabled)) - { - $langs->load("members"); - $langs->load("users"); - print ''; - print ''; - print "\n"; - } - - print '
'.$langs->trans("ThirdPartyName").''; - $object->next_prev_filter="te.client in (2,3)"; - print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','',''); - print '
'.$langs->trans("Address").''; - dol_print_address($object->address,'gmap','thirdparty',$object->id); - print "
'.$langs->trans('Zip').' / '.$langs->trans("Town").''.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'
'.$langs->trans("Country").''; - $img=picto_from_langcode($object->country_code); - if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0); - else print ($img?$img.' ':'').$object->country; - print '
'.$langs->trans("Phone").''.dol_print_phone($object->tel,$object->country_code,0,$object->id,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($object->fax,$object->country_code).'
'.$langs->trans('EMail').''.dol_print_email($object->email,0,$object->id,'AC_EMAIL').'
'.$langs->trans("Web")."url\">$object->url
'; - print ''; - print '
'; - print $langs->trans('ProspectLevelShort'); - print ''; - if ($action != 'editlevel' && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('Modify'),1).'
'; - print '
'; - if ($action == 'editlevel') - $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1); - else - print $object->getLibLevel(); - print "
'; - print '
'; - print $langs->trans("PriceLevel"); - print ''; - if ($user->rights->societe->creer) - { - print ''.img_edit($langs->trans("Modify")).''; - } - print '
'; - print '
'.$object->price_level."
'.$langs->trans("StatusProsp").''.$object->getLibProspStatut(4).''; - if ($object->stcomm_id != -1) print ''.img_action(0,-1).''; - if ($object->stcomm_id != 0) print ''.img_action(0,0).''; - if ($object->stcomm_id != 1) print ''.img_action(0,1).''; - if ($object->stcomm_id != 2) print ''.img_action(0,2).''; - if ($object->stcomm_id != 3) print ''.img_action(0,3).''; - print '
'.$langs->trans("LinkedToDolibarrMember").''; - $adh=new Adherent($db); - $result=$adh->fetch('','',$object->id); - if ($result > 0) - { - $adh->ref=$adh->getFullName($langs); - print $adh->getNomUrl(1); - } - else - { - print $langs->trans("UserNotLinkedToMember"); - } - print '
'; - - - print "
'; - - // Nbre max d'elements des petites listes - $MAXLIST=5; - $tableaushown=0; - - // Lien recap - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
'.$langs->trans("Summary").''.$langs->trans("ShowProspectPreview").'
'; - print '
'; - - - /* - * Last proposals - */ - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) - { - $propal_static=new Propal($db); - - $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; - $sql.= " p.datep as dp, p.fin_validite as datelimite,"; - $sql.= " c.label as statut, c.id as statutid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."c_propalst as c"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.fk_statut = c.id"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND s.rowid = ".$object->id; - $sql.= " ORDER BY p.datep DESC"; - - $resql=$db->query($sql); - if ($resql) - { - $var=true; - $i = 0; - $num = $db->num_rows($resql); - - if ($num > 0) - { - print ''; - print ''; - print ''; - print ''; - } - - while ($i < $num && $i < $MAXLIST) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - $i++; - } - $db->free(); - - if ($num > 0) print "
'; - print ''; - print '
'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' ('.$num.')'.img_picto($langs->trans("Statistics"),'stats').'
propalid\">"; - print img_object($langs->trans("ShowPropal"),"propal"); - print " ".$objp->ref."\n"; - if ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay) && $objp->fk_statut == 1) - { - print " ".img_warning(); - } - print "".dol_print_date($db->jdate($objp->dp),"day")."".price($objp->total_ht)."".$propal_static->LibStatut($objp->fk_statut,5)."
"; - } - else - { - dol_print_error($db); - } - - } - - print "
\n"; - - dol_fiche_end(); - - /* - * Barre d'action - */ - - print '
'; - - if (! empty($conf->propal->enabled) && $user->rights->propale->creer) - { - print ''.$langs->trans("AddProp").''; - } - - // Add action - if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { - if ($user->rights->agenda->myactions->create) - { - print ''.$langs->trans("AddAction").''; - } - else - { - print ''.$langs->trans("AddAction").''; - } - } - - print '
'; - - print '
'; - - - if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) - { - print '
'; - // List of contacts - show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } - - if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { - print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); - - // List of todo actions - show_actions_todo($conf,$langs,$db,$object); - - // List of done actions - show_actions_done($conf,$langs,$db,$object); - } -} - - -llxFooter(); - -$db->close(); -?> diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index ccaadefe2ee..03dde1a24ff 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2418,12 +2418,11 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):1; - $formmail->withtosocid=$soc->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; + $liste=array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; + $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste; + $formmail->withtocc=$liste; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtocccsocid=0; $formmail->withtopic=$langs->trans('SendOrderRef','__ORDERREF__'); $formmail->withfile=2; $formmail->withbody=1; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 4295e1f6fa9..bccac8d8354 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3403,12 +3403,11 @@ else if ($id > 0 || ! empty($ref)) $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; $formmail->withfrom=1; - $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$soc->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; + $liste=array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; + $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste; + $formmail->withtocc=$liste; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtocccsocid=0; $formmail->withtopic=$langs->transnoentities($topicmail,'__FACREF__'); $formmail->withfile=2; $formmail->withbody=1; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 9b3ac059454..fe0187624fe 100755 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -65,16 +65,11 @@ $offset = $limit * $page; $langs->load("companies"); $titre = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); -if ($type == "c") +if ($type == "c" || $type=="p") { $titre.=' ('.$langs->trans("ThirdPartyCustomers").')'; $urlfiche="fiche.php"; } -else if ($type == "p") -{ - $titre.=' ('.$langs->trans("ThirdPartyProspects").')'; - $urlfiche="prospect/fiche.php"; -} else if ($type == "f") { $titre.=' ('.$langs->trans("ThirdPartySuppliers").')'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ee422f4b505..249a4c9dca0 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2013 Christophe Battarel * * 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 @@ -27,7 +28,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; - +require_once(DOL_DOCUMENT_ROOT ."/margin/lib/margins.lib.php"); /** * Class to manage contracts @@ -402,7 +403,7 @@ class Contrat extends CommonObject // Selectionne les lignes contrats liees a un produit $sql = "SELECT p.label, p.description as product_desc, p.ref,"; - $sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.remise_percent, d.subprice,"; + $sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; $sql.= " d.total_ht,"; $sql.= " d.total_tva,"; $sql.= " d.total_localtax1,"; @@ -451,6 +452,10 @@ class Contrat extends CommonObject $line->fk_product = $objp->fk_product; $line->info_bits = $objp->info_bits; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->fk_user_author = $objp->fk_user_author; $line->fk_user_ouverture= $objp->fk_user_ouverture; $line->fk_user_cloture = $objp->fk_user_cloture; @@ -856,7 +861,7 @@ class Contrat extends CommonObject * @param int $info_bits Bits de type de lignes * @return int <0 si erreur, >0 si ok */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0) { global $user, $langs, $conf; @@ -875,6 +880,7 @@ class Contrat extends CommonObject if (! $pu_ttc) $pu_ttc=0; $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); + $pa_ht=price2num($pa_ht); $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); @@ -908,13 +914,21 @@ class Contrat extends CommonObject $price = $pu_ht - $remise; } + if (empty($pa_ht)) $pa_ht=0; + + // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente + if ($pa_ht == 0) { + if ($pu_ht > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) + $pa_ht = $pu_ht * (1 - $remise_percent / 100); + } + // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; $sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx,"; $sql.= " localtax1_tx, localtax2_tx, remise_percent, subprice,"; $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; $sql.= " info_bits,"; - $sql.= " price_ht, remise"; // TODO A virer + $sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; } if ($date_end > 0) { $sql.= ",date_fin_validite"; } $sql.= ") VALUES ($this->id, '', '" . $this->db->escape($desc) . "',"; @@ -926,7 +940,11 @@ class Contrat extends CommonObject $sql.= " ".price2num($remise_percent).",".price2num($pu_ht).","; $sql.= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).","; $sql.= " '".$info_bits."',"; - $sql.= " ".price2num($price).",".price2num($remise); // TODO A virer + $sql.= " ".price2num($price).",".price2num($remise).","; + if (isset($fk_fournprice)) $sql.= ' '.$fk_fournprice.','; + else $sql.= ' null,'; + if (isset($pa_ht)) $sql.= ' '.price2num($pa_ht); + else $sql.= ' null'; if ($date_start > 0) { $sql.= ",'".$this->db->idate($date_start)."'"; } if ($date_end > 0) { $sql.= ",'".$this->db->idate($date_end)."'"; } $sql.= ")"; @@ -983,7 +1001,7 @@ class Contrat extends CommonObject * @param int $info_bits Bits de type de lignes * @return int < 0 si erreur, > 0 si ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0) { global $user, $conf, $langs; @@ -995,6 +1013,7 @@ class Contrat extends CommonObject $tvatx = price2num($tvatx); $localtax1tx = price2num($localtax1tx); $localtax2tx = price2num($localtax2tx); + $pa_ht=price2num($pa_ht); $subprice = $price; $remise = 0; @@ -1016,7 +1035,7 @@ class Contrat extends CommonObject // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $localtaxtx1, $txlocaltaxtx2, 0, $price_base_type, $info_bits, 1); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtaxtx1, $txlocaltaxtx2, 0, $price_base_type, $info_bits, 1); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -1032,6 +1051,14 @@ class Contrat extends CommonObject $price = $pu_ht - $remise; } + if (empty($pa_ht)) $pa_ht=0; + + // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente + if ($pa_ht == 0) { + if ($pu_ht > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) + $pa_ht = $pu_ht * (1 - $remise_percent / 100); + } + $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'"; $sql.= ",price_ht='" . price2num($price)."'"; $sql.= ",subprice='" . price2num($subprice)."'"; @@ -1046,6 +1073,8 @@ class Contrat extends CommonObject $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; $sql.= ", total_ttc='". price2num($total_ttc)."'"; + $sql.= ", fk_product_fournisseur_price='".$fk_fournprice."'"; + $sql.= ", buy_price_ht='".price2num($pa_ht)."'"; if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } else { $sql.=",date_ouverture_prevue=null"; } if ($date_end > 0) { $sql.= ",date_fin_validite='".$this->db->idate($date_end)."'"; } @@ -1610,6 +1639,9 @@ class ContratLigne var $total_localtax2; var $total_ttc; + var $fk_fournprice; + var $pa_ht; + var $info_bits; var $fk_user_author; var $fk_user_ouverture; @@ -1769,6 +1801,8 @@ class ContratLigne $sql.= " t.total_localtax1,"; $sql.= " t.total_localtax2,"; $sql.= " t.total_ttc,"; + $sql.= " t.fk_product_fournisseur_price as fk_fournprice,"; + $sql.= " t.buy_price_ht as pa_ht,"; $sql.= " t.info_bits,"; $sql.= " t.fk_user_author,"; $sql.= " t.fk_user_ouverture,"; @@ -1819,6 +1853,9 @@ class ContratLigne $this->fk_user_ouverture = $obj->fk_user_ouverture; $this->fk_user_cloture = $obj->fk_user_cloture; $this->commentaire = $obj->commentaire; + $this->fk_fournprice = $obj->fk_fournprice; + $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->fk_fournprice, $obj->pa_ht); + $this->pa_ht = $marginInfos[0]; } $this->db->free($resql); @@ -1887,6 +1924,14 @@ class ContratLigne $this->total_localtax1= $tabprice[9]; $this->total_localtax2= $tabprice[10]; + if (empty($this->pa_ht)) $this->pa_ht=0; + + // si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente + if ($this->pa_ht == 0) { + if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) + $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + } + // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; $sql.= " fk_contrat='".$this->fk_contrat."',"; @@ -1913,6 +1958,8 @@ class ContratLigne $sql.= " total_localtax1='".$this->total_localtax1."',"; $sql.= " total_localtax2='".$this->total_localtax2."',"; $sql.= " total_ttc='".$this->total_ttc."',"; + $sql.= " fk_product_fournisseur_price='".$this->fk_fournprice."',"; + $sql.= " buy_price_ht='".price2num($this->pa_ht)."',"; $sql.= " info_bits='".$this->info_bits."',"; $sql.= " fk_user_author=".($this->fk_user_author >= 0?$this->fk_user_author:"NULL").","; $sql.= " fk_user_ouverture=".($this->fk_user_ouverture > 0?$this->fk_user_ouverture:"NULL").","; diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 9578bf54c98..7034f765d5f 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2013 Christophe Battarel * * 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 @@ -305,6 +306,13 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $localtax1_tx=get_localtax($tva_tx,1,$object->societe); $localtax2_tx=get_localtax($tva_tx,2,$object->societe); + // ajout prix achat + $fk_fournprice = $_POST['fournprice']; + if ( ! empty($_POST['buying_price']) ) + $pa_ht = $_POST['buying_price']; + else + $pa_ht = null; + $info_bits=0; if ($tva_npr) $info_bits |= 0x01; @@ -329,7 +337,9 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $date_end, $price_base_type, $pu_ttc, - $info_bits + $info_bits, + $fk_fournprice, + $pa_ht ); } @@ -353,13 +363,18 @@ else if ($action == 'addline' && $user->rights->contrat->creer) } */ - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['idprod']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['tva_tx']); - unset($_POST['dp_desc']); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprod']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); } else { @@ -389,6 +404,13 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST( $localtax1_tx=get_localtax(GETPOST('eltva_tx'),1,$object->thirdparty); $localtax2_tx=get_localtax(GETPOST('eltva_tx'),2,$object->thirdparty); + // ajout prix d'achat + $fk_fournprice = $_POST['fournprice']; + if ( ! empty($_POST['buying_price']) ) + $pa_ht = $_POST['buying_price']; + else + $pa_ht = null; + $objectline->description=GETPOST('product_desc'); $objectline->price_ht=GETPOST('elprice'); $objectline->subprice=GETPOST('elprice'); @@ -402,6 +424,8 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST( $objectline->date_fin_validite=$date_end_update; $objectline->date_cloture=$date_end_real_update; $objectline->fk_user_cloture=$user->id; + $objectline->fk_fournprice=$fk_fournprice; + $objectline->pa_ht=$pa_ht; // TODO verifier price_min si fk_product et multiprix @@ -872,7 +896,7 @@ else $sql.= " cd.tva_tx, cd.remise_percent, cd.info_bits, cd.subprice,"; $sql.= " cd.date_ouverture_prevue as date_debut, cd.date_ouverture as date_debut_reelle,"; $sql.= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,"; - $sql.= " cd.commentaire as comment,"; + $sql.= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,"; $sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype"; $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; @@ -889,6 +913,8 @@ else print '
'.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").''.$langs->trans("BuyingPrice").' 
 '.price($objp->pa_ht).''; if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) @@ -967,7 +997,7 @@ else if ($objp->subprice >= 0) { print '
'; + print ''; // Date planned print $langs->trans("DateStartPlanned").': '; @@ -998,6 +1028,8 @@ else print ''; print ''; print ''; + print ''; + print ''; // Ligne carac print "
'; @@ -1030,12 +1062,18 @@ else print '%'; + if ($objp->fk_product) + print ''; + print ''; print '
'; print '
'; + print ''; print $langs->trans("DateStartPlanned").' '; $form->select_date($db->jdate($objp->date_debut),"date_start_update",$usehm,$usehm,($db->jdate($objp->date_debut)>0?0:1),"update"); print '
'.$langs->trans("DateEndPlanned").' '; @@ -1056,7 +1094,7 @@ else if ($object->statut > 0) { print '


'.$langs->trans("Comment").'
'.$langs->trans("Comment").'
'; @@ -1395,3 +1433,59 @@ llxFooter(); $db->close(); ?> +margin->enabled) { +?> + + diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 802fe5ab071..254370a4395 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -89,11 +89,11 @@ class box_prospect extends ModeleBoxes $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, - 'url' => DOL_URL_ROOT."/comm/prospect/fiche.php?socid=".$objp->socid); + 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->nom, - 'url' => DOL_URL_ROOT."/comm/prospect/fiche.php?socid=".$objp->socid); + 'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => dol_print_date($datem, "day")); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 80859d5d883..28dee6f9383 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -823,11 +823,13 @@ class Form * @param string $showfunction Add function into label * @param string $moreclass Add more class to class style * @param string $showsoc Add company into label + * @param int $forcecombo Force to use combo box + * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return int <0 if KO, Nb of contact in list if OK */ - function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $showsoc=0) + function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $showsoc=0, $forcecombo=0, $event=array()) { - print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass, $showsoc); + print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass, $showsoc, $forcecombo, $event); return $this->num; } @@ -844,9 +846,11 @@ class Form * @param string $moreclass Add more class to class style * @param bool $options_only Return options only (for ajax treatment) * @param string $showsoc Add company into label + * @param int $forcecombo Force to use combo box + * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return int <0 if KO, Nb of contact in list if OK */ - function selectcontacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $options_only=false, $showsoc=0) + function selectcontacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $options_only=false, $showsoc=0, $forcecombo=0, $event=array()) { global $conf,$langs; @@ -872,6 +876,11 @@ class Form if ($resql) { $num=$this->db->num_rows($resql); + + if ($conf->use_javascript_ajax && $conf->global->CONTACT_USE_SEARCH_TO_SELECT && ! $forcecombo) + { + $out.= ajax_combobox($htmlname, $event); + } if ($htmlname != 'none' || $options_only) $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) + if (! empty($this->withtocc) && is_array($this->withtocc)) { $out.= " ".$langs->trans("or")." "; $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); } - if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtoccsocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); - } } $out.= "
    - +
'.$langs->trans("UseSearchToSelectContact").''; + print $langs->trans("NotAvailableWhenAjaxDisabled"); + print "'; + $arrval=array('0'=>$langs->trans("No"), + '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', + '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', + '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', + ); + print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT",$arrval,$conf->global->CONTACT_USE_SEARCH_TO_SELECT); + print ''; + print ''; + print "
'; + dol_fiche_end(); $db->close(); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index db147ffde86..0f5e7051010 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1437,18 +1437,11 @@ class Societe extends CommonObject if ($option == 'customer' || $option == 'compta') { - if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) // Only customer - { - $lien = 'trans("ProspectLevel".$fk_prospectlevel)) + { + $lib=$langs->getLabelFromKey($this->db,$fk_prospectlevel,'c_prospectlevel','code','label'); + } + return $lib; + } + + + /** + * Set prospect level + * + * @param User $user Utilisateur qui definie la remise + * @return int <0 if KO, >0 if OK + */ + function set_prospect_level($user) + { + if ($this->id) + { + $this->db->begin(); + + $now=dol_now(); + + // Positionne remise courante + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; + $sql.= " fk_prospectlevel='".$this->fk_prospectlevel."'"; + $sql.= ",fk_user_modif='".$user->id."'"; + $sql.= " WHERE rowid = ".$this->id; + dol_syslog(get_class($this)."::set_prospect_level sql=".$sql); + $resql=$this->db->query($sql); + if (! $resql) + { + $this->db->rollback(); + $this->error=$this->db->error(); + return -1; + } + + $this->db->commit(); + return 1; + } + } + + /** + * Return status of prospect + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @return string Libelle + */ + function getLibProspCommStatut($mode=0) + { + return $this->LibProspCommStatut($this->stcomm_id,$mode); + } + + /** + * Return label of a given status + * + * @param int $statut Id statut + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Libelle du statut + */ + function LibProspCommStatut($statut,$mode=0) + { + global $langs; + $langs->load('customers'); + + if ($mode == 2) + { + if ($statut == -1) return img_action($langs->trans("StatusProspect-1"),-1).' '.$langs->trans("StatusProspect-1"); + if ($statut == 0) return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + if ($statut == 1) return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + if ($statut == 2) return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + if ($statut == 3) return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + } + if ($mode == 3) + { + if ($statut == -1) return img_action($langs->trans("StatusProspect-1"),-1); + if ($statut == 0) return img_action($langs->trans("StatusProspect0"), 0); + if ($statut == 1) return img_action($langs->trans("StatusProspect1"), 1); + if ($statut == 2) return img_action($langs->trans("StatusProspect2"), 2); + if ($statut == 3) return img_action($langs->trans("StatusProspect3"), 3); + } + if ($mode == 4) + { + if ($statut == -1) return img_action($langs->trans("StatusProspect-1"),-1).' '.$langs->trans("StatusProspect-1"); + if ($statut == 0) return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + if ($statut == 1) return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + if ($statut == 2) return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + if ($statut == 3) return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + } + + return "Error, mode/status not found"; + } + + /** + * Set commnunication level + * + * @param User $user Utilisateur qui definie la remise + * @return int <0 if KO, >0 if OK + */ + function set_commnucation_level($user) + { + if ($this->id) + { + $this->db->begin(); + + $now=dol_now(); + + // Positionne remise courante + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; + $sql.= " fk_stcomm='".$this->stcomm_id."'"; + $sql.= ",fk_user_modif='".$user->id."'"; + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::set_commnucation_level sql=".$sql); + $resql=$this->db->query($sql); + if (! $resql) + { + $this->db->rollback(); + $this->error=$this->db->error(); + return -1; + } + + $this->db->commit(); + return 1; + } + } + + /** + * Return label of status customer is prospect/customer + * + * @return string Libelle + */ + function getLibCustProspStatut() + { + return $this->LibCustProspStatut($this->client,$mode); + } + + /** + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @return string Libelle du statut + */ + function LibCustProspStatut($statut) + { + global $langs; + $langs->load('companies'); + + if ($statut==0) return $langs->trans("NorProspectNorCustomer"); + if ($statut==1) return $langs->trans("Customer"); + if ($statut==2) return $langs->trans("Prospect"); + if ($statut==3) return $langs->trans("ProspectCustomer"); + + } + +} \ No newline at end of file diff --git a/htdocs/theme/amarok/img/background_login.png b/htdocs/theme/amarok/img/background_login.png old mode 100755 new mode 100644 index fd6e7805463..88594ffd7ca Binary files a/htdocs/theme/amarok/img/background_login.png and b/htdocs/theme/amarok/img/background_login.png differ diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index 28ba1ef2ec6..115a63d7e66 100755 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -210,8 +210,8 @@ form#login { } form#login img {width:auto; height:auto; opacity:.7;} form#login img#img_logo { - width:220px; - max-width:220px; + width:190px; + max-width:190px; height:auto; border-radius:6px; padding:6px; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 5b018a768ed..5d0fd96f4bc 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot + * Copyright (C) 2013 Philippe Grand * * 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 @@ -75,6 +76,7 @@ class User extends CommonObject var $contact_id; var $fk_member; + var $fk_user; var $webcal_login; var $phenix_login; @@ -91,9 +93,11 @@ class User extends CommonObject var $all_permissions_are_loaded; /**< \private all_permissions_are_loaded */ private $_tab_loaded=array(); // Array of cache of already loaded permissions - var $conf; // To store personal config - var $oldcopy; // To contains a clone of this when we need to save old properties of object + var $conf; // To store personal config + var $oldcopy; // To contains a clone of this when we need to save old properties of object + var $users; // To store all tree of users hierarchy + var $parentof; // To store an array of all parents for all ids. /** @@ -139,7 +143,7 @@ class User extends CommonObject $sql = "SELECT u.rowid, u.name, u.firstname, u.email, u.job, u.signature, u.office_phone, u.office_fax, u.user_mobile,"; $sql.= " u.admin, u.login, u.webcal_login, u.phenix_login, u.phenix_pass, u.note,"; $sql.= " u.pass, u.pass_crypted, u.pass_temp,"; - $sql.= " u.fk_societe, u.fk_socpeople, u.fk_member, u.ldap_sid,"; + $sql.= " u.fk_societe, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid,"; $sql.= " u.statut, u.lang, u.entity,"; $sql.= " u.datec as datec,"; $sql.= " u.tms as datem,"; @@ -221,8 +225,7 @@ class User extends CommonObject $this->societe_id = $obj->fk_societe; $this->contact_id = $obj->fk_socpeople; $this->fk_member = $obj->fk_member; - - if (! $this->lang) $this->lang='fr_FR'; + $this->fk_user = $obj->fk_user; $this->db->free($result); } @@ -993,11 +996,11 @@ class User extends CommonObject if ($result > 0) { $result=$this->setPassword($user,$this->pass); - if ($member->fk_soc) { + if ($member->fk_soc) { $sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql.= " SET fk_societe=".$member->fk_soc; $sql.= " WHERE rowid=".$this->id; - + dol_syslog(get_class($this)."::create_from_member sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -1009,7 +1012,7 @@ class User extends CommonObject { $this->error=$this->db->error(); dol_syslog(get_class($this)."::create_from_member - 1 - ".$this->error, LOG_ERR); - + $this->db->rollback(); return -1; } @@ -1069,7 +1072,7 @@ class User extends CommonObject } /** - * Update a user into databse (and also password if this->pass is defined) + * Update a user into database (and also password if this->pass is defined) * * @param User $user User qui fait la mise a jour * @param int $notrigger 1 ne declenche pas les triggers, 0 sinon @@ -1153,7 +1156,7 @@ class User extends CommonObject { // Si mot de passe saisi et different de celui en base $result=$this->setPassword($user,$this->pass,0,$notrigger,$nosyncmemberpass); - if (! $nbrowsaffected) $nbrowsaffected++; + if (! $nbrowsaffected) $nbrowsaffected++; } } @@ -1268,7 +1271,7 @@ class User extends CommonObject } /** - * Mise e jour en base de la date de deniere connexion d'un utilisateur + * Mise a jour en base de la date de derniere connexion d'un utilisateur * Fonction appelee lors d'une nouvelle connexion * * @return <0 si echec, >=0 si ok @@ -2074,7 +2077,8 @@ class User extends CommonObject * Update user using data from the LDAP * // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?) */ - function update_ldap2dolibarr(&$ldapuser) { + function update_ldap2dolibarr(&$ldapuser) + { global $user, $conf; $this->firstname=$ldapuser->{$conf->global->LDAP_FIELD_FIRSTNAME}; @@ -2091,13 +2095,214 @@ class User extends CommonObject $this->job=$ldapuser->{$conf->global->LDAP_FIELD_TITLE}; $this->note=$ldapuser->{$conf->global->LDAP_FIELD_DESCRIPTION}; - + $result = $this->update($user); - + dol_syslog(get_class($this)."::update_ldap2dolibarr result=".$result, LOG_DEBUG); - + return $result; } + + + /** + * Return and array with all instanciated children users of current user + * + * @return void + */ + function get_children() + { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; + $sql.= " WHERE fk_user = ".$this->id; + + dol_syslog(get_class($this)."::get_children result=".$result, LOG_DEBUG); + $res = $this->db->query($sql); + if ($res) + { + $users = array (); + while ($rec = $this->db->fetch_array($res)) + { + $user = new User($this->db); + $user->fetch($rec['rowid']); + $users[] = $user; + } + return $users; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + + /** + * Load this->parentof that is array(id_son=>id_parent, ...) + * + * @return int <0 if KO, >0 if OK + */ + private function load_parentof() + { + global $conf; + + $this->parentof=array(); + + // Load array[child]=parent + $sql = "SELECT fk_user as id_parent, rowid as id_son"; + $sql.= " FROM ".MAIN_DB_PREFIX."user"; + $sql.= " WHERE fk_user != 0"; + $sql.= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::load_parentof sql=".$sql); + $resql = $this->db->query($sql); + if ($resql) + { + while ($obj= $this->db->fetch_object($resql)) + { + $this->parentof[$obj->id_son]=$obj->id_parent; + } + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Reconstruit l'arborescence hierarchique des users sous la forme d'un tableau + * Renvoi un tableau de tableau('id','id_parent',...) trie selon arbre et avec: + * id = id du user + * id_parent = id du user parent + * id_children = tableau des id enfant + * name = nom du user + * fullname = nom avec chemin complet du user + * fullpath = chemin complet compose des id + * + * @param int $markafterid Removed all users including the leaf $markafterid in user tree. + * @return array Array of users. this->users and this->parentof are set. + */ + function get_full_tree($markafterid=0) + { + $this->users = array(); + + // Init this->parentof that is array(id_son=>id_parent, ...) + $this->load_parentof(); + + // Init $this->users array + $sql = "SELECT DISTINCT u.rowid, u.firstname, u.name, u.fk_user"; // Distinct reduce pb with old tables with duplicates + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE u.entity IN (".getEntity('user',1).")"; + + dol_syslog(get_class($this)."::get_full_tree get user list sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $i=0; + while ($obj = $this->db->fetch_object($resql)) + { + $this->users[$obj->rowid]['rowid'] = $obj->rowid; + $this->users[$obj->rowid]['id'] = $obj->rowid; + $this->users[$obj->rowid]['fk_user'] = $obj->fk_parent; + $this->users[$obj->rowid]['firstname'] = $obj->firstname; + $this->users[$obj->rowid]['name'] = $obj->name; + $i++; + } + } + else + { + dol_print_error($this->db); + return -1; + } + + // We add the fullpath property to each elements of first level (no parent exists) + dol_syslog(get_class($this)."::get_full_tree call to build_path_from_id_user", LOG_DEBUG); + foreach($this->users as $key => $val) + { + $this->build_path_from_id_user($key,0); // Process a branch from the root user key (this user has no parent) + } + + // Exclude leaf including $markafterid from tree + if ($markafterid) + { + //print "Look to discard user ".$markafterid."\n"; + $keyfilter1='^'.$markafterid.'$'; + $keyfilter2='_'.$markafterid.'$'; + $keyfilter3='^'.$markafterid.'_'; + $keyfilter4='_'.$markafterid.'_'; + foreach($this->users as $key => $val) + { + if (preg_match('/'.$keyfilter1.'/',$val['fullpath']) || preg_match('/'.$keyfilter2.'/',$val['fullpath']) + || preg_match('/'.$keyfilter3.'/',$val['fullpath']) || preg_match('/'.$keyfilter4.'/',$val['fullpath'])) + { + unset($this->users[$key]); + } + } + } + + dol_syslog(get_class($this)."::get_full_tree dol_sort_array", LOG_DEBUG); + $this->users=dol_sort_array($this->users, 'fullname', 'asc', true, false); + + //$this->debug_users(); + + return $this->users; + } + + /** + * For user id_user and its childs available in this->users, define property fullpath and fullname + * + * @param int $id_user id_user entry to update + * @param int $protection Deep counter to avoid infinite loop + * @return void + */ + function build_path_from_id_user($id_user,$protection=1000) + { + dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG); + + if (! empty($this->users[$id_user]['fullpath'])) + { + // Already defined + dol_syslog(get_class($this)."::build_path_from_id_user fullpath and fullname already defined", LOG_WARNING); + return; + } + + // Define fullpath and fullname + $this->users[$id_user]['fullpath'] = '_'.$id_user; + $this->users[$id_user]['fullname'] = $this->users[$id_user]['label']; + $i=0; $cursor_user=$id_user; + + while ((empty($protection) || $i < $protection) && ! empty($this->parentof[$cursor_user])) + { + $this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath']; + $this->users[$id_user]['fullname'] = $this->users[$this->parentof[$cursor_user]]['label'].' >> '.$this->users[$id_user]['fullname']; + $i++; $cursor_user=$this->parentof[$cursor_user]; + } + + // We count number of _ to have level + $this->users[$id_user]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->users[$id_user]['fullpath'])); + + return; + } + + /** + * Affiche contenu de $this->users + * + * @return void + */ + function debug_users() + { + // Affiche $this->users + foreach($this->users as $key => $val) + { + print 'id: '.$this->users[$key]['id']; + print ' name: '.$this->users[$key]['name']; + print ' parent: '.$this->users[$key]['fk_parent']; + print ' fullpath: '.$this->users[$key]['fullpath']; + print ' fullname: '.$this->users[$key]['fullname']; + print "
\n"; + } + } + } ?> diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 92ebb740523..cf0e0170c94 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -324,9 +324,7 @@ if ($action == 'update' && ! $_POST["cancel"]) $object->firstname = GETPOST("prenom"); $object->login = GETPOST("login"); $object->pass = GETPOST("password"); - if($user->admin == 1) { // A user can only be set admin by an admin - $object->admin = GETPOST("admin"); - } + $object->admin = empty($user->admin)?0:GETPOST("admin"); // A user can only be set admin by an admin $object->office_phone=GETPOST("office_phone"); $object->office_fax = GETPOST("office_fax"); $object->user_mobile= GETPOST("user_mobile");