New: Can filter list of proposal, order or invoice on sales

representative
This commit is contained in:
Laurent Destailleur 2012-06-23 20:39:20 +02:00
parent 9e4af7c5a7
commit f2de43b771
10 changed files with 145 additions and 105 deletions

View File

@ -5,6 +5,7 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.3 compared to 3.2 ***** ***** ChangeLog for 3.3 compared to 3.2 *****
For users: For users:
- New: Can filter list of proposal, order or invoice on sales representative.
- New: Add supplier ref on supplier orders. - New: Add supplier ref on supplier orders.
- New: Can export supplier orders. - New: Can export supplier orders.
- New: First feature to install external plugins from gui. - New: First feature to install external plugins from gui.

View File

@ -365,6 +365,9 @@ if ($id > 0)
print '</tr>'; print '</tr>';
} }
// Sales representative
include(DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php');
// Module Adherent // Module Adherent
if ($conf->adherent->enabled) if ($conf->adherent->enabled)
{ {

View File

@ -51,6 +51,7 @@ $confirm=GETPOST('confirm','alpha');
$lineid=GETPOST('lineid','int'); $lineid=GETPOST('lineid','int');
$search_user=GETPOST('search_user','int'); $search_user=GETPOST('search_user','int');
$search_sale=GETPOST('search_sale','int');
$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha'); $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha');
$search_refcustomer=GETPOST('search_refcustomer','alpha'); $search_refcustomer=GETPOST('search_refcustomer','alpha');
$search_societe=GETPOST('search_societe','alpha'); $search_societe=GETPOST('search_societe','alpha');
@ -105,6 +106,7 @@ if (GETPOST("button_removefilter_x"))
{ {
$search_categ=''; $search_categ='';
$search_user=''; $search_user='';
$search_sale='';
$search_ref=''; $search_ref='';
$search_refcustomer=''; $search_refcustomer='';
$search_societe=''; $search_societe='';
@ -152,7 +154,8 @@ $sql.= ' u.login';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p';
if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We'll need this table joined to the select in order to filter by sale
if ($search_sale || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if ($search_user > 0) if ($search_user > 0)
{ {
$sql.=", ".MAIN_DB_PREFIX."element_contact as c"; $sql.=", ".MAIN_DB_PREFIX."element_contact as c";
@ -160,7 +163,6 @@ if ($search_user > 0)
} }
$sql.= ' WHERE p.fk_soc = s.rowid'; $sql.= ' WHERE p.fk_soc = s.rowid';
$sql.= ' AND p.entity = '.$conf->entity; $sql.= ' AND p.entity = '.$conf->entity;
if (! $user->rights->societe->client->voir && ! $socid) //restriction if (! $user->rights->societe->client->voir && ! $socid) //restriction
{ {
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -200,6 +202,7 @@ else if ($year > 0)
{ {
$sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
} }
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
if ($search_user > 0) if ($search_user > 0)
{ {
$sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user;
@ -230,6 +233,7 @@ if ($result)
if ($search_refcustomer) $param.='&search_ref=' .$search_refcustomer; if ($search_refcustomer) $param.='&search_ref=' .$search_refcustomer;
if ($search_societe) $param.='&search_societe=' .$search_societe; if ($search_societe) $param.='&search_societe=' .$search_societe;
if ($search_user > 0) $param.='&search_user='.$search_user; if ($search_user > 0) $param.='&search_user='.$search_user;
if ($search_sale > 0) $param.='&search_sale='.$search_sale;
if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht;
print_barre_liste($langs->trans('ListOfProposals').' '.($socid?'- '.$soc->nom:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num); print_barre_liste($langs->trans('ListOfProposals').' '.($socid?'- '.$soc->nom:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num);
@ -239,6 +243,13 @@ if ($result)
$i = 0; $i = 0;
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
}
// If the user can view prospects other than his' // If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) if ($user->rights->societe->client->voir || $socid)
{ {

View File

@ -41,6 +41,8 @@ $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Prospect($db);
/* /*
* Actions * Actions
@ -55,9 +57,8 @@ if ($_GET["action"] == 'cstc')
// set prospect level // set prospect level
if ($_POST["action"] == 'setprospectlevel' && $user->rights->societe->creer) if ($_POST["action"] == 'setprospectlevel' && $user->rights->societe->creer)
{ {
$societe = new Societe($db); $object->fetch($_GET["socid"]);
$societe->fetch($_GET["socid"]); $object->fk_prospectlevel=$_POST['prospect_level_id'];
$societe->fk_prospectlevel=$_POST['prospect_level_id'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_prospectlevel='".$_POST['prospect_level_id']; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_prospectlevel='".$_POST['prospect_level_id'];
$sql.= "' WHERE rowid='".$_GET["socid"]."'"; $sql.= "' WHERE rowid='".$_GET["socid"]."'";
$result = $db->query($sql); $result = $db->query($sql);
@ -81,8 +82,7 @@ $formcompany=new FormCompany($db);
if ($socid > 0) if ($socid > 0)
{ {
$actionstatic=new ActionComm($db); $actionstatic=new ActionComm($db);
$societe = new Prospect($db, $socid); $result = $object->fetch($socid);
$result = $societe->fetch($socid);
if ($result < 0) if ($result < 0)
{ {
dol_print_error($db); dol_print_error($db);
@ -92,7 +92,7 @@ if ($socid > 0)
/* /*
* Affichage onglets * Affichage onglets
*/ */
$head = societe_prepare_head($societe); $head = societe_prepare_head($object);
dol_fiche_head($head, 'prospect', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'prospect', $langs->trans("ThirdParty"),0,'company');
@ -101,51 +101,51 @@ if ($socid > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td><td colspan="3">'; print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td><td colspan="3">';
$societe->next_prev_filter="te.client in (2,3)"; $object->next_prev_filter="te.client in (2,3)";
print $form->showrefnav($societe,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>'; print '</td></tr>';
// Address // Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'; print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
dol_print_address($societe->address,'gmap','thirdparty',$societe->id); dol_print_address($object->address,'gmap','thirdparty',$object->id);
print "</td></tr>"; print "</td></tr>";
// Zip / Town // Zip / Town
print '<tr><td nowrap="nowrap">'.$langs->trans('Zip').' / '.$langs->trans("Town").'</td><td colspan="3">'.$societe->cp.(($societe->cp && $societe->ville)?' / ':'').$societe->ville.'</td>'; print '<tr><td nowrap="nowrap">'.$langs->trans('Zip').' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$societe->town.'</td>';
print '</tr>'; print '</tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
$img=picto_from_langcode($societe->country_code); $img=picto_from_langcode($object->country_code);
if ($societe->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$societe->country,$langs->trans("CountryIsInEEC"),1,0); if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$societe->country; else print ($img?$img.' ':'').$object->country;
print '</td></tr>'; print '</td></tr>';
// Phone // Phone
print '<tr><td>'.$langs->trans("Phone").'</td><td style="min-width: 25%;">'.dol_print_phone($societe->tel,$societe->country_code,0,$societe->id,'AC_TEL').'</td>'; print '<tr><td>'.$langs->trans("Phone").'</td><td style="min-width: 25%;">'.dol_print_phone($object->tel,$object->country_code,0,$object->id,'AC_TEL').'</td>';
print '<td>'.$langs->trans("Fax").'</td><td style="min-width: 25%;">'.dol_print_phone($societe->fax,$societe->country_code).'</td></tr>'; print '<td>'.$langs->trans("Fax").'</td><td style="min-width: 25%;">'.dol_print_phone($object->fax,$object->country_code).'</td></tr>';
// EMail // EMail
print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'</td></tr>'; print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($object->email,0,$object->id,'AC_EMAIL').'</td></tr>';
// Web // Web
print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$societe->url\">$societe->url</a></td></tr>"; print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\"><a href=\"http://$object->url\">$object->url</a></td></tr>";
// Level of prospect // Level of prospect
print '<tr><td nowrap>'; print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>'; print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('ProspectLevelShort'); print $langs->trans('ProspectLevelShort');
print '<td>'; print '<td>';
if (($_GET['action'] != 'editlevel') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;socid='.$societe->id.'">'.img_edit($langs->trans('SetLevel'),1).'</a></td>'; if (($_GET['action'] != 'editlevel') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetLevel'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'editlevel') if ($_GET['action'] == 'editlevel')
{ {
$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$societe->id,$societe->fk_prospectlevel,'prospect_level_id',1); $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1);
} }
else else
{ {
print $societe->getLibLevel(); print $object->getLibLevel();
//$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none'); //$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none');
} }
print "</td>"; print "</td>";
@ -160,23 +160,26 @@ if ($socid > 0)
print '<td><td align="right">'; print '<td><td align="right">';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/multiprix.php?id='.$societe->id.'">'.img_edit($langs->trans("Modify")).'</a>'; print '<a href="'.DOL_URL_ROOT.'/comm/multiprix.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td><td colspan="3">'.$societe->price_level."</td>"; print '</td><td colspan="3">'.$object->price_level."</td>";
print '</tr>'; print '</tr>';
} }
// Status // Status
print '<tr><td>'.$langs->trans("StatusProsp").'</td><td colspan="2">'.$societe->getLibProspStatut(4).'</td>'; print '<tr><td>'.$langs->trans("StatusProsp").'</td><td colspan="2">'.$object->getLibProspStatut(4).'</td>';
print '<td>'; print '<td>';
if ($societe->stcomm_id != -1) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=-1&amp;action=cstc">'.img_action(0,-1).'</a>'; if ($object->stcomm_id != -1) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=-1&amp;action=cstc">'.img_action(0,-1).'</a>';
if ($societe->stcomm_id != 0) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=0&amp;action=cstc">'.img_action(0,0).'</a>'; if ($object->stcomm_id != 0) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=0&amp;action=cstc">'.img_action(0,0).'</a>';
if ($societe->stcomm_id != 1) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=1&amp;action=cstc">'.img_action(0,1).'</a>'; if ($object->stcomm_id != 1) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=1&amp;action=cstc">'.img_action(0,1).'</a>';
if ($societe->stcomm_id != 2) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=2&amp;action=cstc">'.img_action(0,2).'</a>'; if ($object->stcomm_id != 2) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=2&amp;action=cstc">'.img_action(0,2).'</a>';
if ($societe->stcomm_id != 3) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=3&amp;action=cstc">'.img_action(0,3).'</a>'; if ($object->stcomm_id != 3) print '<a href="fiche.php?socid='.$object->id.'&amp;stcomm=3&amp;action=cstc">'.img_action(0,3).'</a>';
print '</td></tr>'; print '</td></tr>';
// Sales representative
include(DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php');
// Module Adherent // Module Adherent
if ($conf->adherent->enabled) if ($conf->adherent->enabled)
{ {
@ -185,7 +188,7 @@ if ($socid > 0)
print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>'; print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
$adh=new Adherent($db); $adh=new Adherent($db);
$result=$adh->fetch('','',$societe->id); $result=$adh->fetch('','',$object->id);
if ($result > 0) if ($result > 0)
{ {
$adh->ref=$adh->getFullName($langs); $adh->ref=$adh->getFullName($langs);
@ -213,7 +216,7 @@ if ($socid > 0)
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/comm/prospect/recap-prospect.php?socid='.$societe->id.'">'.$langs->trans("ShowProspectPreview").'</a></td></tr></table></td>'; print '<td align="right"><a href="'.DOL_URL_ROOT.'/comm/prospect/recap-prospect.php?socid='.$object->id.'">'.$langs->trans("ShowProspectPreview").'</a></td></tr></table></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
@ -235,7 +238,7 @@ if ($socid > 0)
$sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.fk_statut = c.id"; $sql.= " AND p.fk_statut = c.id";
$sql.= " AND p.entity = ".$conf->entity; $sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND s.rowid = ".$societe->id; $sql.= " AND s.rowid = ".$object->id;
$sql.= " ORDER BY p.datep DESC"; $sql.= " ORDER BY p.datep DESC";
$resql=$db->query($sql); $resql=$db->query($sql);
@ -249,8 +252,8 @@ if ($socid > 0)
{ {
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$societe->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$object->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$societe->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>'; print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>'; print '</tr></table></td>';
print '</tr>'; print '</tr>';
} }
@ -296,7 +299,7 @@ if ($socid > 0)
if ($conf->propal->enabled && $user->rights->propale->creer) if ($conf->propal->enabled && $user->rights->propale->creer)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$societe->id.'&amp;action=create">'.$langs->trans("AddProp").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a>';
} }
// Add action // Add action
@ -304,7 +307,7 @@ if ($socid > 0)
{ {
if ($user->rights->agenda->myactions->create) if ($user->rights->agenda->myactions->create)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$societe->id.'">'.$langs->trans("AddAction").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a>';
} }
else else
{ {
@ -321,7 +324,7 @@ if ($socid > 0)
{ {
print '<br>'; print '<br>';
// List of contacts // List of contacts
show_contacts($conf,$langs,$db,$societe,$_SERVER["PHP_SELF"].'?socid='.$societe->id); show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
} }
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
@ -329,10 +332,10 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); print load_fiche_titre($langs->trans("ActionsOnCompany"),'','');
// List of todo actions // List of todo actions
show_actions_todo($conf,$langs,$db,$societe); show_actions_todo($conf,$langs,$db,$object);
// List of done actions // List of done actions
show_actions_done($conf,$langs,$db,$societe); show_actions_done($conf,$langs,$db,$object);
} }
} }

View File

@ -159,7 +159,7 @@ if ($_GET["action"] == 'cstc')
* View * View
*/ */
$htmlother=new FormOther($db); $formother=new FormOther($db);
$sql = "SELECT s.rowid, s.nom, s.ville, s.datec, s.datea, s.status as status,"; $sql = "SELECT s.rowid, s.nom, s.ville, s.datec, s.datea, s.status as status,";
$sql.= " st.libelle as stcomm, s.prefix_comm, s.fk_stcomm, s.fk_prospectlevel,"; $sql.= " st.libelle as stcomm, s.prefix_comm, s.fk_stcomm, s.fk_prospectlevel,";
@ -271,14 +271,14 @@ if ($resql)
if ($conf->categorie->enabled) if ($conf->categorie->enabled)
{ {
$moreforfilter.=$langs->trans('Categories'). ': '; $moreforfilter.=$langs->trans('Categories'). ': ';
$moreforfilter.=$htmlother->select_categories(2,$search_categ,'search_categ'); $moreforfilter.=$formother->select_categories(2,$search_categ,'search_categ');
$moreforfilter.=' &nbsp; &nbsp; &nbsp; '; $moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
} }
// If the user can view prospects other than his' // If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) if ($user->rights->societe->client->voir || $socid)
{ {
$moreforfilter.=$langs->trans('SalesRepresentatives'). ': '; $moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
$moreforfilter.=$htmlother->select_salesrepresentatives($search_sale,'search_sale',$user); $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
} }
if ($moreforfilter) if ($moreforfilter)
{ {

View File

@ -27,6 +27,7 @@
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
$langs->load('orders'); $langs->load('orders');
@ -43,6 +44,7 @@ $snom=GETPOST('snom','alpha');
$sall=GETPOST('sall'); $sall=GETPOST('sall');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
$search_user=GETPOST('search_user','int'); $search_user=GETPOST('search_user','int');
$search_sale=GETPOST('search_sale','int');
// Security check // Security check
$id = (GETPOST('orderid')?GETPOST('orderid'):GETPOST('id','int')); $id = (GETPOST('orderid')?GETPOST('orderid'):GETPOST('id','int'));
@ -63,6 +65,25 @@ $limit = $conf->liste_limit;
$viewstatut=GETPOST('viewstatut'); $viewstatut=GETPOST('viewstatut');
/*
* Actions
*/
// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x"))
{
$search_categ='';
$search_user='';
$search_sale='';
$search_ref='';
$search_refcustomer='';
$search_societe='';
$search_montant_ht='';
$year='';
$month='';
}
/* /*
* View * View
@ -71,6 +92,7 @@ $viewstatut=GETPOST('viewstatut');
$now=dol_now(); $now=dol_now();
$form = new Form($db); $form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$companystatic = new Societe($db); $companystatic = new Societe($db);
@ -80,7 +102,8 @@ $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.
$sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as facturee'; $sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as facturee';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
$sql.= ', '.MAIN_DB_PREFIX.'commande as c'; $sql.= ', '.MAIN_DB_PREFIX.'commande as c';
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We'll need this table joined to the select in order to filter by sale
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if ($search_user > 0) if ($search_user > 0)
{ {
$sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; $sql.=", ".MAIN_DB_PREFIX."element_contact as ec";
@ -152,6 +175,7 @@ if (!empty($sref_client))
{ {
$sql.= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\''; $sql.= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\'';
} }
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
if ($search_user > 0) if ($search_user > 0)
{ {
$sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
@ -196,6 +220,7 @@ if ($resql)
if ($snom) $param.='&snom='.$snom; if ($snom) $param.='&snom='.$snom;
if ($sref_client) $param.='&sref_client='.$sref_client; if ($sref_client) $param.='&sref_client='.$sref_client;
if ($search_user > 0) $param.='&search_user='.$search_user; if ($search_user > 0) $param.='&search_user='.$search_user;
if ($search_sale > 0) $param.='&search_sale='.$search_sale;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print_barre_liste($title, $page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num); print_barre_liste($title, $page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num);
@ -206,6 +231,13 @@ if ($resql)
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
}
// If the user can view prospects other than his' // If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) if ($user->rights->societe->client->voir || $socid)
{ {

View File

@ -112,7 +112,19 @@ $now=dol_now();
$parameters=array('socid'=>$socid); $parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
// None // Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x"))
{
$search_categ='';
$search_user='';
$search_sale='';
$search_ref='';
$search_refcustomer='';
$search_societe='';
$search_montant_ht='';
$year='';
$month='';
}
/* /*
@ -122,7 +134,7 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);
llxHeader('',$langs->trans('Bill'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes'); llxHeader('',$langs->trans('Bill'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
$form = new Form($db); $form = new Form($db);
$htmlother = new FormOther($db); $formother = new FormOther($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$bankaccountstatic=new Account($db); $bankaccountstatic=new Account($db);
$facturestatic=new Facture($db); $facturestatic=new Facture($db);
@ -135,10 +147,11 @@ $sql.= ' f.paye as paye, f.fk_statut, f.note,';
$sql.= ' s.nom, s.rowid as socid'; $sql.= ' s.nom, s.rowid as socid';
if (! $sall) $sql.= ', SUM(pf.amount) as am'; // To be able to sort on status if (! $sall) $sql.= ', SUM(pf.amount) as am'; // To be able to sort on status
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ', '.MAIN_DB_PREFIX.'facture as f'; $sql.= ', '.MAIN_DB_PREFIX.'facture as f';
if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
else $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as fd ON fd.fk_facture = f.rowid'; else $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as fd ON fd.fk_facture = f.rowid';
// We'll need this table joined to the select in order to filter by sale
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if ($search_user > 0) if ($search_user > 0)
{ {
$sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; $sql.=", ".MAIN_DB_PREFIX."element_contact as ec";
@ -191,6 +204,7 @@ else if ($year > 0)
{ {
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
} }
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
if ($search_user > 0) if ($search_user > 0)
{ {
$sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user;
@ -229,6 +243,7 @@ if ($resql)
if ($year) $param.='&year=' .$year; if ($year) $param.='&year=' .$year;
if ($search_ref) $param.='&search_ref=' .$search_ref; if ($search_ref) $param.='&search_ref=' .$search_ref;
if ($search_societe) $param.='&search_societe=' .$search_societe; if ($search_societe) $param.='&search_societe=' .$search_societe;
if ($search_sale > 0) $param.='&search_sale=' .$search_sale;
if ($search_user > 0) $param.='&search_user=' .$search_user; if ($search_user > 0) $param.='&search_user=' .$search_user;
if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht;
if ($search_montant_ttc) $param.='&search_montant_ttc='.$search_montant_ttc; if ($search_montant_ttc) $param.='&search_montant_ttc='.$search_montant_ttc;
@ -240,6 +255,13 @@ if ($resql)
// If the user can view prospects other than his' // If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) if ($user->rights->societe->client->voir || $socid)
{
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
}
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{ {
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
$moreforfilter.=$form->select_dolusers($search_user,'search_user',1); $moreforfilter.=$form->select_dolusers($search_user,'search_user',1);
@ -272,7 +294,7 @@ if ($resql)
print '<td class="liste_titre" align="center">'; print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">'; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$htmlother->select_year($year?$year:-1,'year',1, 20, 5); $formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre" align="left">&nbsp;</td>'; print '<td class="liste_titre" align="left">&nbsp;</td>';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';

View File

@ -24,6 +24,7 @@ TaskRDVWith=Meeting with %s
ShowTask=Show task ShowTask=Show task
ShowAction=Show event ShowAction=Show event
ActionsReport=Events report ActionsReport=Events report
ThirdPartiesOfSaleRepresentative=Thirdparties with sales representative
SalesRepresentative=Sales representative SalesRepresentative=Sales representative
SalesRepresentatives=Sales representatives SalesRepresentatives=Sales representatives
SalesRepresentativeFollowUp=Sales representative (follow-up) SalesRepresentativeFollowUp=Sales representative (follow-up)

View File

@ -24,6 +24,7 @@ TaskRDVWith=Rendez-vous avec %s
ShowTask=Afficher tâche ShowTask=Afficher tâche
ShowAction=Afficher événement ShowAction=Afficher événement
ActionsReport=Rapport des événements ActionsReport=Rapport des événements
ThirdPartiesOfSaleRepresentative=Tiers ayant pour commercial
SalesRepresentative=Commercial SalesRepresentative=Commercial
SalesRepresentatives=Commerciaux SalesRepresentatives=Commerciaux
SalesRepresentativeFollowUp=Commercial (suivi) SalesRepresentativeFollowUp=Commercial (suivi)

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Brian Fraval <brian@fraval.org> * Copyright (C) 2003 Brian Fraval <brian@fraval.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net> * Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
@ -629,7 +629,7 @@ else
$object->forme_juridique_code=$_POST['forme_juridique_code']; $object->forme_juridique_code=$_POST['forme_juridique_code'];
/* Show create form */ /* Show create form */
print_fiche_titre($langs->trans("NewCompany")); print_fiche_titre($langs->trans("NewThirdParty"));
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
@ -760,6 +760,7 @@ else
print '</td></tr>'; print '</td></tr>';
// Category // Category
/* This must be set into category tab, like for customer category
if ($object->fournisseur) if ($object->fournisseur)
{ {
$load = $object->LoadSupplierCateg(); $load = $object->LoadSupplierCateg();
@ -773,7 +774,7 @@ else
print '</td></tr>'; print '</td></tr>';
} }
} }
} }*/
} }
// Status // Status
@ -860,7 +861,7 @@ else
print "\n"; print "\n";
print '<script language="JavaScript" type="text/javascript">'; print '<script language="JavaScript" type="text/javascript">';
print "function CheckVAT(a) {\n"; print "function CheckVAT(a) {\n";
print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,230);\n"; print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,300);\n";
print "}\n"; print "}\n";
print '</script>'; print '</script>';
print "\n"; print "\n";
@ -1747,43 +1748,8 @@ else
print '</td></tr>'; print '</td></tr>';
} }
// Commercial // Sales representative
print '<tr><td>'; include(DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php');
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('SalesRepresentatives');
print '<td><td align="right">';
if ($user->rights->societe->creer)
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$object->id.'">'.img_edit().'</a>';
else
print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
$listsalesrepresentatives=$object->getSalesRepresentatives($user);
$nbofsalesrepresentative=count($listsalesrepresentatives);
if ($nbofsalesrepresentative > 3) // We print only number
{
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$object->id.'">';
print $nbofsalesrepresentative;
print '</a>';
}
else if ($nbofsalesrepresentative > 0)
{
$userstatic=new User($db);
$i=0;
foreach($listsalesrepresentatives as $val)
{
$userstatic->id=$val['id'];
$userstatic->lastname=$val['name'];
$userstatic->firstname=$val['firstname'];
print $userstatic->getNomUrl(1);
$i++;
if ($i < $nbofsalesrepresentative) print ', ';
}
}
else print $langs->trans("NoSalesRepresentativeAffected");
print '</td></tr>';
// Module Adherent // Module Adherent
if ($conf->adherent->enabled) if ($conf->adherent->enabled)