New: Remove tab accountancy. Now in customer tab for customer accountancy and in supplier tab for supplier tab.

This commit is contained in:
Laurent Destailleur 2010-09-19 12:50:53 +00:00
parent 11044f07ad
commit 64581c555b
13 changed files with 349 additions and 596 deletions

View File

@ -139,7 +139,7 @@ if ($result)
if ($user->rights->societe->client->voir || $socid)
{
$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
$moreforfilter.=$htmlother->select_salesrepresentatives($search_sale,'search_sale');
$moreforfilter.=$htmlother->select_salesrepresentatives($search_sale,'search_sale',$user);
}
if ($moreforfilter)
{

View File

@ -24,8 +24,8 @@
/**
* \file htdocs/comm/fiche.php
* \ingroup commercial
* \brief Onglet client de la fiche societe
* \ingroup commercial, compta
* \brief Page to show customer card of a third party
* \version $Id$
*/
@ -39,9 +39,10 @@ if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/cont
if (!empty($conf->global->MAIN_MODULE_CHRONODOCS)) require_once(DOL_DOCUMENT_ROOT."/chronodocs/chronodocs_entries.class.php");
$langs->load("companies");
$langs->load("orders");
$langs->load("bills");
$langs->load("contracts");
if ($conf->contrat->enabled) $langs->load("contracts");
if ($conf->commande->enabled) $langs->load("orders");
if ($conf->facture->enabled) $langs->load("bills");
if ($conf->projet->enabled) $langs->load("projects");
if ($conf->ficheinter->enabled) $langs->load("interventions");
if ($conf->notification->enabled) $langs->load("mails");
if (!empty($conf->global->MAIN_MODULE_CHRONODOCS)) $langs->load("chronodocs");
@ -61,6 +62,20 @@ if (! $sortfield) $sortfield="nom";
* Actions
*/
if ($_POST['action'] == 'setcustomeraccountancycode')
{
$societe = new Societe($db);
$result=$societe->fetch($_POST['socid']);
$societe->code_compta=$_POST["customeraccountancycode"];
$result=$societe->update($societe->id,$user,1,1,0);
if ($result < 0)
{
$mesg=join(',',$societe->errors);
}
$POST["action"]="";
$socid=$_POST["socid"];
}
if ($_GET["action"] == 'attribute_prefix' && $user->rights->societe->creer)
{
$societe = new Societe($db, $_GET["socid"]);
@ -106,8 +121,9 @@ if ($_POST["action"] == 'setassujtva' && $user->rights->societe->creer)
llxHeader('',$langs->trans('CustomerCard'));
$facturestatic=new Facture($db);
$contactstatic = new Contact($db);
$userstatic=new User($db);
$form = new Form($db);
@ -138,14 +154,18 @@ if ($mode == 'search')
if ($socid > 0)
{
// On recupere les donnees societes par l'objet
// Load data of third party
$objsoc = new Societe($db);
$objsoc->id=$socid;
$objsoc->fetch($socid,$to);
if ($objsoc->id <= 0)
{
dol_print_error($db,$objsoc->error);
}
if ($errmesg)
{
print "<b>$errmesg</b><br>";
print "<b>".$errmesg."</b><br>";
}
/*
@ -157,9 +177,6 @@ if ($socid > 0)
dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"),0,'company');
/*
*
*/
print '<table width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" class="notopnoleft">';
@ -170,7 +187,10 @@ if ($socid > 0)
print $form->showrefnav($objsoc,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>';
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$objsoc->prefix_comm.'</td></tr>';
// Prefix
print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
print ($objsoc->prefix_comm?$objsoc->prefix_comm:'&nbsp;');
print '</td></tr>';
if ($objsoc->client)
{
@ -179,9 +199,18 @@ if ($socid > 0)
print $objsoc->code_client;
if ($objsoc->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td></tr>';
print '<tr>';
print '<td>';
print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$objsoc->code_compta,'socid',$objsoc->id,$user->rights->societe->creer);
print '</td><td colspan="3">';
print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$objsoc->code_compta,'socid',$objsoc->id,$user->rights->societe->creer);
print '</td>';
print '</tr>';
}
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($objsoc->address)."</td></tr>";
// Address
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3">'.nl2br($objsoc->address)."</td></tr>";
// Zip / Town
print '<tr><td>'.$langs->trans('Zip').'</td><td>'.$objsoc->cp."</td>";
@ -206,7 +235,7 @@ if ($socid > 0)
// Web
print '<tr><td>'.$langs->trans("Web").'</td><td colspan="3">'.dol_print_url($objsoc->url,'_blank').'</td></tr>';
// Assujeti TVA ou pas
// Assujeti a TVA ou pas
print '<tr>';
print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
print yn($objsoc->tva_assuj);
@ -239,6 +268,11 @@ if ($socid > 0)
}
}
// TVA Intra
print '<tr><td nowrap>'.$langs->trans('VATIntraVeryShort').'</td><td colspan="3">';
print $objsoc->tva_intra;
print '</td></tr>';
// Conditions de reglement par defaut
$langs->load('bills');
$html = new Form($db);
@ -260,7 +294,7 @@ if ($socid > 0)
print "</td>";
print '</tr>';
// Mode de reglement
// Mode de reglement par defaut
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('PaymentMode');
@ -284,7 +318,7 @@ if ($socid > 0)
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans("CustomerRelativeDiscountShort");
print '<td><td align="right">';
if ($user->rights->societe->creer)
if ($user->rights->societe->creer && !$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$objsoc->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
@ -298,7 +332,7 @@ if ($socid > 0)
print '<tr><td nowrap>';
print $langs->trans("CustomerAbsoluteDiscountShort");
print '<td><td align="right">';
if ($user->rights->societe->creer)
if ($user->rights->societe->creer && !$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$objsoc->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
@ -372,12 +406,13 @@ if ($socid > 0)
// Nbre max d'elements des petites listes
$MAXLIST=4;
$tableaushown=1;
// Lien recap
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
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/recap-client.php?socid='.$objsoc->id.'">'.$langs->trans("ShowCustomerPreview").'</a></td></tr></table></td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$objsoc->id.'">'.$langs->trans("ShowCustomerPreview").'</a></td></tr></table></td>';
print '</tr>';
print '</table>';
print '<br>';
@ -387,7 +422,6 @@ if ($socid > 0)
/*
* Last proposals
*/
// TODO remplacer par une fonction
if ($conf->propal->enabled && $user->rights->propale->lire)
{
$propal_static = new Propal($db);
@ -591,6 +625,75 @@ if ($socid > 0)
print "</table>";
}
/*
* Last invoices
*/
if ($conf->facture->enabled && $user->rights->facture->lire)
{
$facturestatic = new Facture($db);
print '<table class="noborder" width="100%">';
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
$sql.= ' f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut,';
$sql.= ' s.nom, s.rowid as socid,';
$sql.= ' SUM(pf.amount) as am';
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$objsoc->id;
$sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
$sql.= ' f.datef, f.datec, f.paye, f.fk_statut,';
$sql.= ' s.nom, s.rowid';
$sql.= " ORDER BY f.datef DESC, f.datec DESC";
$resql=$db->query($sql);
if ($resql)
{
$var=true;
$num = $db->num_rows($resql);
$i = 0;
if ($num > 0)
{
$tableaushown=1;
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$objsoc->id.'">'.$langs->trans("AllBills").' ('.$num.')</a></td></tr></table></td>';
print '</tr>';
}
while ($i < $num && $i < $MAXLIST)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>';
$facturestatic->id=$objp->facid;
$facturestatic->ref=$objp->facnumber;
$facturestatic->type=$objp->type;
print $facturestatic->getNomUrl(1);
print '</td>';
if ($objp->df > 0)
{
print "<td align=\"right\">".dol_print_date($db->jdate($objp->df))."</td>\n";
}
else
{
print "<td align=\"right\"><b>!!!</b></td>\n";
}
print "<td align=\"right\">".price($objp->total_ttc)."</td>\n";
print '<td align="right" nowrap="nowrap">'.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am))."</td>\n";
print "</tr>\n";
$i++;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
print "</table>";
}
/*
* Last linked chronodocs
*/
@ -632,12 +735,13 @@ if ($socid > 0)
}
print "</td></tr>";
print "</table></div>\n";
print "</table>";
print "\n</div>\n";
/*
* Barre d'action
*
* Barre d'actions
*/
print '<div class="tabsAction">';
@ -665,9 +769,41 @@ if ($socid > 0)
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/fiche.php?socid='.$objsoc->id.'&amp;action=create">'.$langs->trans("AddIntervention").'</a>';
}
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
// Add invoice
if ($user->societe_id == 0)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$objsoc->id.'">'.$langs->trans("AddAction").'</a>';
if ($conf->deplacement->enabled)
{
$langs->load("trips");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/fiche.php?socid='.$objsoc->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a>';
}
if ($conf->facture->enabled)
{
if ($user->rights->facture->creer)
{
$langs->load("bills");
if ($objsoc->client != 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$objsoc->id.'">'.$langs->trans("AddBill").'</a>';
else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>';
}
else
{
print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>';
}
}
}
// Add action
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
if ($user->rights->agenda->myactions->create)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$objsoc->id.'">'.$langs->trans("AddAction").'</a>';
}
else
{
print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>';
}
}
if ($user->rights->societe->contact->creer)
@ -681,23 +817,20 @@ if ($socid > 0)
}
print '</div>';
print '<br>';
print "<br>\n";
if ($conf->global->MAIN_REPEATCONTACTTASKONEACHTAB)
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
{
/*
* Liste des contacts
*/
// List of contacts
show_contacts($conf,$langs,$db,$objsoc);
}
/*
* Listes des actions a faire
*/
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
// List of todo actions
show_actions_todo($conf,$langs,$db,$objsoc);
/*
* Listes des actions effectuees
*/
// List of done actions
show_actions_done($conf,$langs,$db,$objsoc);
}
}

View File

@ -262,51 +262,49 @@ if ($socid > 0)
/*
* Barre d'action
*
*/
print '<div class="tabsAction">';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$societe->id.'&amp;action=create">'.$langs->trans("AddContact").'</a>';
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>';
}
if ($conf->agenda->enabled)
{
// Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-action-button-behaviour.html)
// Don't force the user to add a "todo action"; he could report an action that he did
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$socid.'">'.$langs->trans("AddAction").'</a>';
}
// Add action
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
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>';
}
else
{
print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>';
}
}
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.'/contact/fiche.php?socid='.$societe->id.'&amp;action=create">'.$langs->trans("AddContact").'</a>';
if ($conf->projet->enabled && $user->rights->projet->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/fiche.php?socid='.$socid.'&action=create">'.$langs->trans("AddProject").'</a>';
}
print '</div>';
print '<br>';
if ($conf->global->MAIN_REPEATCONTACTTASKONEACHTAB)
{
/*
* Liste des contacts
*/
show_contacts($conf,$langs,$db,$societe);
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
{
// List of contacts
show_contacts($conf,$langs,$db,$societe);
}
/*
* Listes des actions a faire
*/
show_actions_todo($conf,$langs,$db,$societe);
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
// List of todo actions
show_actions_todo($conf,$langs,$db,$societe);
/*
* Listes des actions effectuees
*/
show_actions_done($conf,$langs,$db,$societe);
}
// List of done actions
show_actions_done($conf,$langs,$db,$societe);
}
}
$db->close();

View File

@ -274,7 +274,7 @@ if ($resql)
if ($user->rights->societe->client->voir || $socid)
{
$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
$moreforfilter.=$htmlother->select_salesrepresentatives($search_sale,'search_sale');
$moreforfilter.=$htmlother->select_salesrepresentatives($search_sale,'search_sale',$user);
}
if ($moreforfilter)
{

View File

@ -1,455 +0,0 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/compta/fiche.php
* \ingroup compta
* \brief Page de fiche compta
* \version $Id$
*/
require('../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
$langs->load("companies");
if ($conf->facture->enabled) $langs->load("bills");
if ($conf->projet->enabled) $langs->load("projects");
if ($conf->notification->enabled) $langs->load("mails");
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe',$socid,'');
/*
* Action
*/
if ($mode == 'search')
{
if ($mode-search == 'soc')
{
$sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s ";
$sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'";
}
$resql=$db->query($sql);
if ($resql)
{
if ( $db->num_rows($resql) == 1)
{
$obj = $db->fetch_object($resql);
$socid = $obj->rowid;
}
$db->free();
}
if ($user->societe_id > 0)
{
$socid = $user->societe_id;
}
}
if ($_POST['action'] == 'setcustomeraccountancycode')
{
$societe = new Societe($db);
$result=$societe->fetch($_POST['socid']);
$societe->code_compta=$_POST["customeraccountancycode"];
$result=$societe->update($societe->id,$user,1,1,0);
if ($result < 0)
{
$mesg=join(',',$societe->errors);
}
$POST["action"]="";
$socid=$_POST["socid"];
}
if ($_POST['action'] == 'setsupplieraccountancycode')
{
$societe = new Societe($db);
$result=$societe->fetch($_POST['socid']);
$societe->code_compta_fournisseur=$_POST["supplieraccountancycode"];
$result=$societe->update($societe->id,$user,1,0,1);
if ($result < 0)
{
$mesg=join(',',$societe->errors);
}
$POST["action"]="";
$socid=$_POST["socid"];
}
/*
* View
*/
llxHeader();
$facturestatic=new Facture($db);
$contactstatic = new Contact($db);
$form = new Form($db);
if ($socid > 0)
{
$societe = new Societe($db);
$societe->fetch($socid);
if ($societe->id <= 0)
{
dol_print_error($db,$societe->error);
}
/*
* Affichage onglets
*/
$head = societe_prepare_head($societe);
dol_fiche_head($head, 'compta', $langs->trans("ThirdParty"),0,'company'); // Add a div
if ($mesg) print $mesg;
print '<table width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="50%" class="notopnoleft">';
print '<table class="border" width="100%">';
print '<tr><td width="100">'.$langs->trans("Name").'</td><td colspan="3">';
$societe->next_prev_filter="te.client in (1,3)";
print $form->showrefnav($societe,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>';
// Prefix
print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
print ($societe->prefix_comm?$societe->prefix_comm:'&nbsp;');
print '</td></tr>';
if ($societe->client)
{
print '<tr>';
print '<td nowrap>'.$langs->trans("CustomerCode").'</td><td colspan="3">';
print $societe->code_client;
if ($societe->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$societe->code_compta,'socid',$societe->id,$user->rights->societe->creer);
print '</td><td colspan="3">';
print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$societe->code_compta,'socid',$societe->id,$user->rights->societe->creer);
print '</td>';
print '</tr>';
}
if ($societe->fournisseur)
{
print '<tr>';
print '<td nowrap>'.$langs->trans("SupplierCode"). '</td><td colspan="3">';
print $societe->code_fournisseur;
if ($societe->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print $form->editfieldkey("SupplierAccountancyCode",'supplieraccountancycode',$societe->code_compta_fournisseur,'socid',$societe->id,$user->rights->societe->creer);
print '</td><td colspan="3">';
print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$societe->code_compta_fournisseur,'socid',$societe->id,$user->rights->societe->creer);
print '</td>';
print '</tr>';
}
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'.nl2br($societe->adresse)."</td></tr>";
print '<tr><td>'.$langs->trans('Zip').'</td><td>'.$societe->cp.'</td>';
print '<td>'.$langs->trans('Town').'</td><td>'.$societe->ville.'</td></tr>';
// Country
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
$img=picto_from_langcode($societe->pays_code);
if ($societe->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$societe->pays,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$societe->pays;
print '</td></tr>';
// Phone
print '<tr><td>'.$langs->trans("Phone").'</td><td>'.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'</td>';
// Fax
print '<td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'</td></tr>';
// EMail
print '<tr><td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'</td></tr>';
// Web
print '<tr><td>'.$langs->trans("Web").'</td><td colspan="3">'.dol_print_url($societe->url,'_blank').'</td></tr>';
// Assujeti a TVA ou pas
print '<tr>';
print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
print yn($societe->tva_assuj);
print '</td>';
print '</tr>';
// Local Taxes
if($mysoc->pays_code=='ES')
{
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
{
print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax1IsUsedES').'</td><td colspan="3">';
print yn($societe->localtax1_assuj);
print '</td></tr>';
print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax2IsUsedES').'</td><td colspan="3">';
print yn($societe->localtax2_assuj);
print '</td></tr>';
}
elseif($mysoc->localtax1_assuj=="1")
{
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
print yn($societe->localtax1_assuj);
print '</td></tr>';
}
elseif($mysoc->localtax2_assuj=="1")
{
print '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
print yn($societe->localtax2_assuj);
print '</td></tr>';
}
}
// TVA Intra
print '<tr><td nowrap>'.$langs->trans('VATIntraVeryShort').'</td><td colspan="3">';
print $societe->tva_intra;
print '</td></tr>';
if ($societe->client == 1)
{
// Remise permanente
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans("CustomerRelativeDiscountShort");
print '<td><td align="right">';
if (!$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$societe->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td><td colspan="3">'.($societe->remise_client?price2num($societe->remise_client,'MT').'%':$langs->trans("DiscountNone")).'</td>';
print '</tr>';
// Reductions (Discounts-Drawbacks-Rebates)
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding">';
print '<tr><td nowrap>';
print $langs->trans("CustomerAbsoluteDiscountShort");
print '<td><td align="right">';
if (!$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$societe->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
$amount_discount=$societe->getAvailableDiscounts();
if ($amount_discount < 0) dol_print_error($db,$societe->error);
if ($amount_discount > 0) print price($amount_discount).'&nbsp;'.$langs->trans("Currency".$conf->monnaie);
else print $langs->trans("DiscountNone");
print '</td>';
print '</tr>';
}
print "</table>";
print "</td>\n";
print '<td valign="top" width="50%" class="notopnoleftnoright">';
// Nbre max d'elements des petites listes
$MAXLIST=5;
$tableaushown=1;
// Lien recap
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$societe->id.'">'.$langs->trans("ShowAccountancyPreview").'</a></td></tr></table></td>';
print '</tr>';
print '</table>';
print '<br>';
/*
* Last invoices
*/
if ($conf->facture->enabled && $user->rights->facture->lire)
{
$facturestatic = new Facture($db);
print '<table class="noborder" width="100%">';
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
$sql.= ' f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut,';
$sql.= ' s.nom, s.rowid as socid,';
$sql.= ' SUM(pf.amount) as am';
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
$sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
$sql.= ' f.datef, f.datec, f.paye, f.fk_statut,';
$sql.= ' s.nom, s.rowid';
$sql.= " ORDER BY f.datef DESC, f.datec DESC";
$resql=$db->query($sql);
if ($resql)
{
$var=true;
$num = $db->num_rows($resql);
$i = 0;
if ($num > 0)
{
$tableaushown=1;
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$societe->id.'">'.$langs->trans("AllBills").' ('.$num.')</a></td></tr></table></td>';
print '</tr>';
}
while ($i < $num && $i < $MAXLIST)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>';
$facturestatic->id=$objp->facid;
$facturestatic->ref=$objp->facnumber;
$facturestatic->type=$objp->type;
print $facturestatic->getNomUrl(1);
print '</td>';
if ($objp->df > 0)
{
print "<td align=\"right\">".dol_print_date($db->jdate($objp->df))."</td>\n";
}
else
{
print "<td align=\"right\"><b>!!!</b></td>\n";
}
print "<td align=\"right\">".price($objp->total_ttc)."</td>\n";
print '<td align="right" nowrap="nowrap">'.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am))."</td>\n";
print "</tr>\n";
$i++;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
print "</table>";
}
print "</td></tr>";
print "</table>";
print "\n</div>\n";
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
if ($user->societe_id == 0)
{
// Si societe cliente ou prospect, on affiche bouton "Creer facture client"
if ($conf->facture->enabled)
{
if ($user->rights->facture->creer)
{
$langs->load("bills");
if ($societe->client != 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$societe->id.'">'.$langs->trans("AddBill").'</a>';
else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>';
}
else
{
print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>';
}
}
if ($conf->deplacement->enabled)
{
$langs->load("trips");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/fiche.php?socid='.$societe->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a>';
}
}
// Add action
if ($conf->agenda->enabled)
{
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>';
}
else
{
print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>';
}
}
if ($user->rights->societe->contact->creer)
{
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT.'/contact/fiche.php?socid='.$societe->id."&amp;action=create\">".$langs->trans("AddContact")."</a>";
}
print '</div>';
print "<br>\n";
if ($conf->global->MAIN_REPEATCONTACTTASKONEACHTAB)
{
/*
* Liste des contacts
*/
show_contacts($conf,$langs,$db,$societe);
/*
* Listes des actions a faire
*/
show_actions_todo($conf,$langs,$db,$societe);
/*
* Listes des actions effectuees
*/
show_actions_done($conf,$langs,$db,$societe);
}
}
else
{
dol_print_error($db,'Bad value for socid parameter');
}
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -57,7 +57,7 @@ if ($socid > 0)
*/
$head = societe_prepare_head($societe);
dol_fiche_head($head, 'compta', $langs->trans("ThirdParty"), 0, 'company');
dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company');
print "<table width=\"100%\">\n";
print '<tr><td valign="top" width="50%">';

View File

@ -218,7 +218,8 @@ class Conf
if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US";
// By default, we repeat info on all tabs
if (! isset($this->global->MAIN_REPEATCONTACTTASKONEACHTAB)) $this->global->MAIN_REPEATCONTACTTASKONEACHTAB=1;
if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1;
//if (! isset($this->global->MAIN_REPEATTASKONEACHTAB)) $this->global->MAIN_REPEATTASKONEACHTAB=1; No more required as we have now an agenda tab
$rootfordata = DOL_DATA_ROOT;
$rootforuser = DOL_DATA_ROOT;

View File

@ -269,12 +269,13 @@ class FormOther
/**
* \brief Return select list for categories (to use in form search selectors)
* \param selected Preselected value
* \param htmlname Name of combo list
* \return return Html combo list code
* Return select list for categories (to use in form search selectors)
* @param selected Preselected value
* @param htmlname Name of combo list
* @param user Object user
* @return return Html combo list code
*/
function select_salesrepresentatives($selected=0,$htmlname='search_sale')
function select_salesrepresentatives($selected=0,$htmlname='search_sale',$user)
{
global $conf;
@ -282,12 +283,24 @@ class FormOther
$moreforfilter ='<select class="flat" name="'.$htmlname.'">';
$moreforfilter.='<option value="">&nbsp;</option>';
$sql_usr = "SELECT u.rowid, u.name, u.firstname, u.login";
// Get list of users allowed to be viewed
$sql_usr = "SELECT u.rowid, u.name as name, u.firstname, u.login";
$sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")";
$sql_usr.= " ORDER BY u.name ASC";
if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.fk_societe = ".($user->societe_id?$user->societe_id:0);
// Add existing sales representatives of company
if (empty($user->rights->user->user->lire) && $user->societe_id)
{
$sql_usr.=" UNION ";
$sql_usr.= "SELECT u2.rowid, u2.name as name, u2.firstname, u2.login";
$sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql_usr.= " WHERE u2.entity IN (0,".$conf->entity.")";
$sql_usr.= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->societe_id;
}
$sql_usr.= " ORDER BY name ASC";
//print $sql_usr;exit;
$resql_usr = $this->db->query($sql_usr);
$resql_usr = $this->db->query($sql_usr);
if ($resql_usr)
{
while ($obj_usr = $this->db->fetch_object($resql_usr))
@ -305,7 +318,7 @@ class FormOther
}
else
{
dol_print_error($db);
dol_print_error($this->db);
}
$moreforfilter.='</select>';
@ -313,7 +326,7 @@ class FormOther
}
/**
* \brief Retourn list of project and tasks
* \brief Return list of project and tasks
* \param selectedtask Pre-selected task
* \param projectid Project id
* \param htmlname Name of html select

View File

@ -46,6 +46,25 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe',$socid,'');
/*
* Action
*/
if ($_POST['action'] == 'setsupplieraccountancycode')
{
$societe = new Societe($db);
$result=$societe->fetch($_POST['socid']);
$societe->code_compta_fournisseur=$_POST["supplieraccountancycode"];
$result=$societe->update($societe->id,$user,1,0,1);
if ($result < 0)
{
$mesg=join(',',$societe->errors);
}
$POST["action"]="";
$socid=$_POST["socid"];
}
/*
* View
@ -80,15 +99,26 @@ if ( $societe->fetch($socid) )
if ($societe->fournisseur)
{
print '<tr><td nowrap="nowrap">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $societe->code_fournisseur;
if ($societe->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td></tr>';
print '<tr>';
print '<td nowrap="nowrap">'.$langs->trans("SupplierCode"). '</td><td colspan="3">';
print $societe->code_fournisseur;
if ($societe->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print $form->editfieldkey("SupplierAccountancyCode",'supplieraccountancycode',$societe->code_compta_fournisseur,'socid',$societe->id,$user->rights->societe->creer);
print '</td><td colspan="3">';
print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$societe->code_compta_fournisseur,'socid',$societe->id,$user->rights->societe->creer);
print '</td>';
print '</tr>';
}
// Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'.nl2br($societe->address).'</td></tr>';
// Zip / Town
print '<tr><td>'.$langs->trans("Zip").'</td><td>'.$societe->cp.'</td>';
print '<td>'.$langs->trans("Town").'</td><td>'.$societe->ville.'</td></tr>';
@ -303,10 +333,18 @@ if ( $societe->fetch($socid) )
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?action=create&socid='.$societe->id.'">'.$langs->trans("AddBill").'</a>';
}
if ($conf->agenda->enabled && $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>';
}
// Add action
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
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>';
}
else
{
print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>';
}
}
if ($user->rights->societe->contact->creer)
{
@ -316,24 +354,20 @@ if ( $societe->fetch($socid) )
print '</div>';
print '<br>';
if ($conf->global->MAIN_REPEATCONTACTTASKONEACHTAB)
{
/*
* Liste des contacts
*/
show_contacts($conf,$langs,$db,$societe);
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
{
// List of contacts
show_contacts($conf,$langs,$db,$societe);
}
/*
* Listes des actions a faire
*/
show_actions_todo($conf,$langs,$db,$societe);
/*
* Listes des actions effectuees
*/
show_actions_done($conf,$langs,$db,$societe);
}
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
// List of todo actions
show_actions_todo($conf,$langs,$db,$societe);
// List of done actions
show_actions_done($conf,$langs,$db,$societe);
}
}
else
{

View File

@ -44,11 +44,6 @@ function societe_prepare_head($objsoc)
$head[$h][2] = 'company';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Agenda");
$head[$h][2] = 'agenda';
$h++;
if ($objsoc->client==1 || $objsoc->client==3 || $objsoc->object->client==1 || $objsoc->object->client==3)
{
$head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objsoc->id;
@ -70,14 +65,19 @@ function societe_prepare_head($objsoc)
$head[$h][2] = 'supplier';
$h++;
}
if ($conf->facture->enabled || $conf->compta->enabled || $conf->accounting->enabled)
/*if ($conf->facture->enabled || $conf->compta->enabled || $conf->accounting->enabled)
{
$langs->load("compta");
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Accountancy");
$head[$h][2] = 'compta';
$h++;
}
}*/
$head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Agenda");
$head[$h][2] = 'agenda';
$h++;
//show categorie tab
if ($conf->categorie->enabled)
@ -165,7 +165,7 @@ function societe_prepare_head2($objsoc)
$h++;
$head[$h][0] = 'lien.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Links");
$head[$h][1] = $langs->trans("ParentCompany");
$head[$h][2] = 'links';
$h++;

View File

@ -150,15 +150,38 @@ if ($_GET["socid"])
if ($mesg) print($mesg);
/*
* Listes des actions a faire
*/
show_actions_todo($conf,$langs,$db,$soc);
/*
* Barre d'action
*/
print '<div class="tabsAction">';
if ($conf->agenda->enabled)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$socid.'">'.$langs->trans("AddAction").'</a>';
}
print '</div>';
print '<br>';
/*
if ($conf->global->MAIN_REPEATCONTACTONEACHTAB)
{
// List of contacts
show_contacts($conf,$langs,$db,$societe);
}
if ($conf->global->MAIN_REPEATTASKONEACHTAB)
{
*/
// List of todo actions
show_actions_todo($conf,$langs,$db,$soc);
// List of done actions
show_actions_done($conf,$langs,$db,$soc);
// }
/*
* Listes des actions effectuees
*/
show_actions_done($conf,$langs,$db,$soc);
}

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -53,10 +53,12 @@ if($_GET["socid"] && $_GET["commid"])
$soc->add_commercial($user, $_GET["commid"]);
Header("Location: commerciaux.php?socid=".$soc->id);
exit;
}
else
{
Header("Location: commerciaux.php?socid=".$_GET["socid"]);
exit;
}
}
@ -144,25 +146,18 @@ if ($_GET["socid"])
{
$obj = $db->fetch_object($resql);
if (!$user->rights->societe->client->voir)
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowUser"),"user").' ';
print $obj->firstname." " .$obj->name."\n";
print '</a>&nbsp;';
if ($user->rights->societe->creer)
{
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowUser"),"user").' ';
print stripslashes($obj->firstname)." " .stripslashes($obj->name)."\n";
print '</a><br>';
$i++;
}
else
{
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowUser"),"user").' ';
print $obj->firstname." " .$obj->name."\n";
print '</a>&nbsp;';
print '<a href="commerciaux.php?socid='.$_GET["socid"].'&amp;delcommid='.$obj->rowid.'">';
print img_delete();
print '</a><br>';
$i++;
print '<a href="commerciaux.php?socid='.$_GET["socid"].'&amp;delcommid='.$obj->rowid.'">';
print img_delete();
print '</a>';
}
print '<br>';
$i++;
}
$db->free($resql);

View File

@ -1650,7 +1650,13 @@ else
{
$num = $db->num_rows($resql);
$obj = $db->fetch_object($resql);
print $obj->nb?($obj->nb):$langs->trans("NoSalesRepresentativeAffected");
if ($obj->nb)
{
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$soc->id.'">';
print $obj->nb;
print '</a>';
}
else print $langs->trans("NoSalesRepresentativeAffected");
}
else {
dol_print_error($db);
@ -1700,7 +1706,12 @@ else
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$soc->id.'&amp;action=create">'.$langs->trans("AddContact").'</a>';
}
if ($user->rights->societe->supprimer)
if ($conf->projet->enabled && $user->rights->projet->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/fiche.php?socid='.$socid.'&action=create">'.$langs->trans("AddProject").'</a>';
}
if ($user->rights->societe->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?socid='.$soc->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}