2004-10-19 20:43:23 +00:00
|
|
|
<?php
|
2005-04-08 15:37:29 +00:00
|
|
|
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2008-01-08 08:39:25 +00:00
|
|
|
* Copyright (C) 2003 Eric Seigne <erics@rycks.com>
|
2011-06-11 14:14:27 +00:00
|
|
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-12-30 14:13:49 +00:00
|
|
|
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
2013-01-05 15:03:00 +00:00
|
|
|
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
2002-05-06 19:10:48 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 14:36:08 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-05-06 19:10:48 +00:00
|
|
|
* (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
|
2011-07-31 23:45:11 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-05-06 19:10:48 +00:00
|
|
|
*/
|
2004-12-11 00:54:01 +00:00
|
|
|
|
2005-04-28 20:33:30 +00:00
|
|
|
/**
|
2009-02-18 14:29:56 +00:00
|
|
|
* \file htdocs/fourn/fiche.php
|
|
|
|
|
* \ingroup fournisseur, facture
|
2010-10-30 10:52:53 +00:00
|
|
|
* \brief Page for supplier third party card (view, edit)
|
2009-02-18 12:26:55 +00:00
|
|
|
*/
|
2004-12-11 00:54:01 +00:00
|
|
|
|
2012-08-22 21:24:21 +00:00
|
|
|
require '../main.inc.php';
|
2012-08-22 21:11:24 +00:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
2012-09-15 08:01:35 +00:00
|
|
|
if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
2002-05-06 19:10:48 +00:00
|
|
|
|
2005-11-03 16:23:11 +00:00
|
|
|
$langs->load('suppliers');
|
|
|
|
|
$langs->load('products');
|
|
|
|
|
$langs->load('bills');
|
|
|
|
|
$langs->load('orders');
|
|
|
|
|
$langs->load('companies');
|
2006-07-30 18:06:28 +00:00
|
|
|
$langs->load('commercial');
|
2004-08-06 00:46:07 +00:00
|
|
|
|
2011-11-08 22:10:31 +00:00
|
|
|
$action = GETPOST('action');
|
|
|
|
|
|
2008-02-25 16:30:43 +00:00
|
|
|
// Security check
|
2012-02-27 21:26:22 +00:00
|
|
|
$id = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
|
2011-11-08 22:10:31 +00:00
|
|
|
if ($user->societe_id) $id=$user->societe_id;
|
2012-10-16 15:59:00 +00:00
|
|
|
$result = restrictedArea($user, 'societe&fournisseur', $id, '&societe');
|
2006-04-06 19:21:19 +00:00
|
|
|
|
2011-11-08 22:10:31 +00:00
|
|
|
$object = new Fournisseur($db);
|
2006-04-06 19:21:19 +00:00
|
|
|
|
2010-09-19 12:50:53 +00:00
|
|
|
/*
|
|
|
|
|
* Action
|
|
|
|
|
*/
|
|
|
|
|
|
2011-11-08 22:10:31 +00:00
|
|
|
if ($action == 'setsupplieraccountancycode')
|
2010-09-19 12:50:53 +00:00
|
|
|
{
|
2011-11-08 22:10:31 +00:00
|
|
|
$result=$object->fetch($id);
|
|
|
|
|
$object->code_compta_fournisseur=$_POST["supplieraccountancycode"];
|
|
|
|
|
$result=$object->update($object->id,$user,1,0,1);
|
2010-09-19 12:50:53 +00:00
|
|
|
if ($result < 0)
|
|
|
|
|
{
|
2011-11-08 22:10:31 +00:00
|
|
|
$mesg=join(',',$object->errors);
|
2010-09-19 12:50:53 +00:00
|
|
|
}
|
2011-11-08 22:10:31 +00:00
|
|
|
$action="";
|
2010-09-19 12:50:53 +00:00
|
|
|
}
|
2013-07-30 13:06:57 +00:00
|
|
|
// conditions de reglement
|
|
|
|
|
if ($action == 'setconditions' && $user->rights->societe->creer)
|
|
|
|
|
{
|
|
|
|
|
$object->fetch($id);
|
|
|
|
|
$result=$object->setPaymentTerms(GETPOST('cond_reglement_supplier_id','int'));
|
|
|
|
|
if ($result < 0) dol_print_error($db,$object->error);
|
|
|
|
|
}
|
|
|
|
|
// mode de reglement
|
|
|
|
|
if ($action == 'setmode' && $user->rights->societe->creer)
|
|
|
|
|
{
|
|
|
|
|
$object->fetch($id);
|
|
|
|
|
$result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int'));
|
|
|
|
|
if ($result < 0) dol_print_error($db,$object->error);
|
|
|
|
|
}
|
2010-09-19 12:50:53 +00:00
|
|
|
|
2005-06-11 11:34:38 +00:00
|
|
|
|
2002-05-06 19:10:48 +00:00
|
|
|
/*
|
2008-03-07 02:08:43 +00:00
|
|
|
* View
|
2009-02-18 12:26:55 +00:00
|
|
|
*/
|
2009-02-18 14:29:56 +00:00
|
|
|
|
2007-12-05 13:37:39 +00:00
|
|
|
$contactstatic = new Contact($db);
|
2008-03-07 02:08:43 +00:00
|
|
|
$form = new Form($db);
|
2002-05-06 19:10:48 +00:00
|
|
|
|
2011-11-08 22:10:31 +00:00
|
|
|
if ($object->fetch($id))
|
2004-02-12 18:14:58 +00:00
|
|
|
{
|
2009-03-07 00:56:00 +00:00
|
|
|
llxHeader('',$langs->trans('SupplierCard'));
|
2009-02-18 12:26:55 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Affichage onglets
|
|
|
|
|
*/
|
2011-11-08 22:10:31 +00:00
|
|
|
$head = societe_prepare_head($object);
|
2009-02-18 12:26:55 +00:00
|
|
|
|
2009-10-29 17:30:29 +00:00
|
|
|
dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"),0,'company');
|
2009-02-18 12:26:55 +00:00
|
|
|
|
|
|
|
|
|
2013-04-21 15:56:29 +00:00
|
|
|
print '<div class="fichecenter"><div class="fichehalfleft">';
|
2009-02-18 12:26:55 +00:00
|
|
|
|
|
|
|
|
print '<table width="100%" class="border">';
|
2013-07-30 13:06:57 +00:00
|
|
|
print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
$object->next_prev_filter="te.fournisseur = 1";
|
|
|
|
|
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
|
2010-07-14 20:47:35 +00:00
|
|
|
print '</td></tr>';
|
2009-02-18 12:26:55 +00:00
|
|
|
|
2011-01-29 16:25:01 +00:00
|
|
|
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
|
|
|
|
{
|
2011-11-08 22:10:31 +00:00
|
|
|
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
2011-01-29 16:25:01 +00:00
|
|
|
}
|
2009-02-18 12:26:55 +00:00
|
|
|
|
2011-11-08 22:10:31 +00:00
|
|
|
if ($object->fournisseur)
|
2009-02-18 12:26:55 +00:00
|
|
|
{
|
2013-05-24 16:20:28 +00:00
|
|
|
print '<tr>';
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<td class="nowrap">'.$langs->trans("SupplierCode"). '</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
print $object->code_fournisseur;
|
|
|
|
|
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
2010-09-19 12:50:53 +00:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
2013-05-24 16:20:28 +00:00
|
|
|
$langs->load('compta');
|
2010-09-19 12:50:53 +00:00
|
|
|
print '<tr>';
|
|
|
|
|
print '<td>';
|
2011-11-08 22:10:31 +00:00
|
|
|
print $form->editfieldkey("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
|
2010-09-19 12:50:53 +00:00
|
|
|
print '</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
|
2010-09-19 12:50:53 +00:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
2009-02-18 12:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-19 12:50:53 +00:00
|
|
|
// Address
|
2011-05-12 19:01:14 +00:00
|
|
|
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
dol_print_address($object->address,'gmap','thirdparty',$object->id);
|
2011-05-12 19:01:14 +00:00
|
|
|
print '</td></tr>';
|
2009-02-18 12:26:55 +00:00
|
|
|
|
2010-09-19 12:50:53 +00:00
|
|
|
// Zip / Town
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<tr><td class="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td>';
|
2011-06-11 14:14:27 +00:00
|
|
|
print '</tr>';
|
2009-02-18 12:26:55 +00:00
|
|
|
|
|
|
|
|
// Country
|
|
|
|
|
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
$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;
|
2009-02-18 12:26:55 +00:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2013-04-27 23:12:40 +00:00
|
|
|
// EMail
|
|
|
|
|
print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($object->email,0,$object->id,'AC_EMAIL').'</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Web
|
|
|
|
|
print '<tr><td>'.$langs->trans("Web").'</td><td colspan="3">'.dol_print_url($object->url).'</td></tr>';
|
|
|
|
|
|
2009-02-18 14:29:56 +00:00
|
|
|
// Phone
|
2013-09-25 17:58:22 +00:00
|
|
|
print '<tr><td>'.$langs->trans("Phone").'</td><td style="min-width: 25%;">'.dol_print_phone($object->phone,$object->country_code,0,$object->id,'AC_TEL').'</td>';
|
2009-10-04 12:16:45 +00:00
|
|
|
|
2009-02-18 14:29:56 +00:00
|
|
|
// Fax
|
2011-11-08 22:10:31 +00:00
|
|
|
print '<td>'.$langs->trans("Fax").'</td><td style="min-width: 25%;">'.dol_print_phone($object->fax,$object->country_code,0,$object->id,'AC_FAX').'</td></tr>';
|
2009-10-04 12:16:45 +00:00
|
|
|
|
2009-02-18 12:26:55 +00:00
|
|
|
// Assujetti a TVA ou pas
|
|
|
|
|
print '<tr>';
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<td class="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
print yn($object->tva_assuj);
|
2009-02-18 12:26:55 +00:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
2010-02-08 03:38:05 +00:00
|
|
|
|
|
|
|
|
// Local Taxes
|
2013-01-05 15:03:00 +00:00
|
|
|
//TODO: Place into a function to control showing by country or study better option
|
2011-11-08 22:10:31 +00:00
|
|
|
if($mysoc->country_code=='ES')
|
2010-02-07 11:18:00 +00:00
|
|
|
{
|
2010-04-24 17:31:16 +00:00
|
|
|
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
|
|
|
|
|
{
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<tr><td class="nowrap">'.$langs->trans('LocalTax1IsUsedES').'</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
print yn($object->localtax1_assuj);
|
2010-04-24 17:31:16 +00:00
|
|
|
print '</td></tr>';
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<tr><td class="nowrap">'.$langs->trans('LocalTax2IsUsedES').'</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
print yn($object->localtax2_assuj);
|
2010-04-24 17:31:16 +00:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
elseif($mysoc->localtax1_assuj=="1")
|
|
|
|
|
{
|
|
|
|
|
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
print yn($object->localtax1_assuj);
|
2010-04-24 17:31:16 +00:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
elseif($mysoc->localtax2_assuj=="1")
|
|
|
|
|
{
|
|
|
|
|
print '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
print yn($object->localtax2_assuj);
|
2010-04-24 17:31:16 +00:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
2013-04-27 23:12:40 +00:00
|
|
|
|
2013-01-05 15:03:00 +00:00
|
|
|
if ($mysoc->localtax2_assuj!="1")
|
|
|
|
|
{
|
|
|
|
|
print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
|
|
|
|
|
print yn($object->localtax2_assuj);
|
|
|
|
|
print '</td><tr>';
|
|
|
|
|
}
|
2013-04-27 23:12:40 +00:00
|
|
|
|
2010-02-07 11:18:00 +00:00
|
|
|
}
|
2010-05-08 17:17:17 +00:00
|
|
|
|
2011-05-12 19:01:14 +00:00
|
|
|
// TVA Intra
|
2013-07-19 12:23:42 +00:00
|
|
|
print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td colspan="3">';
|
2011-11-08 22:10:31 +00:00
|
|
|
print $object->tva_intra;
|
2011-05-12 19:01:14 +00:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2013-07-30 13:06:57 +00:00
|
|
|
// Conditions de reglement par defaut
|
|
|
|
|
$langs->load('bills');
|
|
|
|
|
$form = new Form($db);
|
|
|
|
|
print '<tr><td>';
|
|
|
|
|
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
|
|
|
|
print $langs->trans('PaymentConditions');
|
|
|
|
|
print '<td>';
|
|
|
|
|
if (($action != 'editconditions') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&socid='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
|
|
|
|
|
print '</tr></table>';
|
|
|
|
|
print '</td><td colspan="3">';
|
|
|
|
|
if ($action == 'editconditions')
|
|
|
|
|
{
|
|
|
|
|
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->cond_reglement_supplier_id,'cond_reglement_supplier_id',-1,1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->cond_reglement_supplier_id,'none');
|
|
|
|
|
}
|
|
|
|
|
print "</td>";
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
// Mode de reglement par defaut
|
|
|
|
|
print '<tr><td class="nowrap">';
|
|
|
|
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
|
|
|
|
print $langs->trans('PaymentMode');
|
|
|
|
|
print '<td>';
|
|
|
|
|
if (($action != 'editmode') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
|
|
|
|
|
print '</tr></table>';
|
|
|
|
|
print '</td><td colspan="3">';
|
|
|
|
|
if ($action == 'editmode')
|
|
|
|
|
{
|
|
|
|
|
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement_supplier_id,'mode_reglement_supplier_id');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement_supplier_id,'none');
|
|
|
|
|
}
|
|
|
|
|
print "</td>";
|
|
|
|
|
print '</tr>';
|
2011-05-12 19:01:14 +00:00
|
|
|
|
2011-02-09 15:28:15 +00:00
|
|
|
// Module Adherent
|
2012-09-15 08:01:35 +00:00
|
|
|
if (! empty($conf->adherent->enabled))
|
2011-02-09 15:28:15 +00:00
|
|
|
{
|
|
|
|
|
$langs->load("members");
|
|
|
|
|
$langs->load("users");
|
|
|
|
|
print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
|
|
|
|
|
print '<td colspan="3">';
|
|
|
|
|
$adh=new Adherent($db);
|
2011-11-08 22:10:31 +00:00
|
|
|
$result=$adh->fetch('','',$object->id);
|
2011-02-09 15:28:15 +00:00
|
|
|
if ($result > 0)
|
|
|
|
|
{
|
|
|
|
|
$adh->ref=$adh->getFullName($langs);
|
|
|
|
|
print $adh->getNomUrl(1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-11-05 14:29:58 +00:00
|
|
|
print $langs->trans("ThirdpartyNotLinkedToMember");
|
2011-02-09 15:28:15 +00:00
|
|
|
}
|
|
|
|
|
print '</td>';
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-18 12:26:55 +00:00
|
|
|
print '</table>';
|
|
|
|
|
|
2013-04-27 23:12:40 +00:00
|
|
|
|
2013-06-05 14:24:32 +00:00
|
|
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
2013-04-21 15:56:29 +00:00
|
|
|
|
2013-04-27 23:12:40 +00:00
|
|
|
|
2009-02-18 12:26:55 +00:00
|
|
|
$var=true;
|
|
|
|
|
|
|
|
|
|
$MAXLIST=5;
|
|
|
|
|
|
|
|
|
|
// Lien recap
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
2009-10-29 17:30:29 +00:00
|
|
|
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>';
|
2011-11-08 22:10:31 +00:00
|
|
|
print '<td align="right"><a href="'.DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id.'">'.$langs->trans("ShowSupplierPreview").'</a></td></tr></table></td>';
|
2009-02-18 12:26:55 +00:00
|
|
|
print '</tr>';
|
|
|
|
|
print '</table>';
|
2009-02-21 13:45:25 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* List of products
|
|
|
|
|
*/
|
2012-09-15 09:21:22 +00:00
|
|
|
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
|
2009-02-21 13:45:25 +00:00
|
|
|
{
|
|
|
|
|
$langs->load("products");
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td>'.$langs->trans("ProductsAndServices").'</td><td align="right">';
|
2011-12-30 13:45:07 +00:00
|
|
|
print '<a href="'.DOL_URL_ROOT.'/fourn/product/liste.php?fourn_id='.$object->id.'">'.$langs->trans("All").' ('.$object->nbOfProductRefs().')';
|
2009-02-21 13:45:25 +00:00
|
|
|
print '</a></td></tr></table>';
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-04 12:16:45 +00:00
|
|
|
|
2009-02-18 12:26:55 +00:00
|
|
|
print '<br>';
|
|
|
|
|
|
|
|
|
|
/*
|
2009-10-04 12:16:45 +00:00
|
|
|
* Last orders
|
2009-02-18 12:26:55 +00:00
|
|
|
*/
|
|
|
|
|
$orderstatic = new CommandeFournisseur($db);
|
|
|
|
|
|
2009-10-04 12:16:45 +00:00
|
|
|
if ($user->rights->fournisseur->commande->lire)
|
2006-04-06 19:21:19 +00:00
|
|
|
{
|
2011-11-08 22:10:31 +00:00
|
|
|
// TODO move to DAO class
|
2010-05-08 17:17:17 +00:00
|
|
|
$sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut";
|
2009-10-04 12:16:45 +00:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p ";
|
2011-11-08 22:10:31 +00:00
|
|
|
$sql.= " WHERE p.fk_soc =".$object->id;
|
2009-10-04 12:16:45 +00:00
|
|
|
$sql.= " ORDER BY p.date_commande DESC";
|
|
|
|
|
$sql.= " ".$db->plimit($MAXLIST);
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2006-04-06 19:21:19 +00:00
|
|
|
{
|
2009-10-04 12:16:45 +00:00
|
|
|
$i = 0 ;
|
|
|
|
|
$num = $db->num_rows($resql);
|
2011-06-13 15:14:11 +00:00
|
|
|
|
|
|
|
|
if ($num > 0)
|
|
|
|
|
{
|
2011-11-03 00:59:13 +00:00
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
2011-06-13 15:14:11 +00:00
|
|
|
print '<td colspan="3">';
|
|
|
|
|
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastOrders",($num<$MAXLIST?"":$MAXLIST)).'</td>';
|
2011-11-08 22:10:31 +00:00
|
|
|
print '<td align="right"><a href="commande/liste.php?socid='.$object->id.'">'.$langs->trans("AllOrders").' ('.$num.')</td>';
|
|
|
|
|
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
|
2011-06-13 15:14:11 +00:00
|
|
|
print '</tr></table>';
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-04 12:16:45 +00:00
|
|
|
while ($i < $num && $i <= $MAXLIST)
|
2006-04-06 19:21:19 +00:00
|
|
|
{
|
2009-10-04 12:16:45 +00:00
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
2013-06-20 07:18:12 +00:00
|
|
|
print "<tr ".$bc[$var].">";
|
2009-10-04 12:16:45 +00:00
|
|
|
print '<td><a href="commande/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref.'</a></td>';
|
|
|
|
|
print '<td align="center" width="80">';
|
|
|
|
|
if ($obj->dc)
|
|
|
|
|
{
|
2010-05-08 17:17:17 +00:00
|
|
|
print dol_print_date($db->jdate($obj->dc),'day');
|
2009-10-04 12:16:45 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print "-";
|
|
|
|
|
}
|
|
|
|
|
print '</td>';
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<td align="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut,5).'</td>';
|
2009-10-04 12:16:45 +00:00
|
|
|
print '</tr>';
|
|
|
|
|
$i++;
|
2006-04-06 19:21:19 +00:00
|
|
|
}
|
2009-10-04 12:16:45 +00:00
|
|
|
$db->free($resql);
|
2011-11-03 00:59:13 +00:00
|
|
|
|
|
|
|
|
if ($num >0) print "</table>";
|
2006-04-06 19:21:19 +00:00
|
|
|
}
|
2009-10-04 12:16:45 +00:00
|
|
|
else
|
2006-04-06 19:21:19 +00:00
|
|
|
{
|
2009-10-04 12:16:45 +00:00
|
|
|
dol_print_error($db);
|
2006-04-06 19:21:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-11-30 19:24:11 +00:00
|
|
|
|
2006-04-06 19:21:19 +00:00
|
|
|
/*
|
2009-10-04 12:16:45 +00:00
|
|
|
* Last invoices
|
2006-04-06 19:21:19 +00:00
|
|
|
*/
|
2006-03-18 22:46:29 +00:00
|
|
|
$MAXLIST=5;
|
|
|
|
|
|
2005-12-05 18:49:35 +00:00
|
|
|
$langs->load('bills');
|
2006-03-18 22:46:29 +00:00
|
|
|
$facturestatic = new FactureFournisseur($db);
|
|
|
|
|
|
2009-10-04 12:16:45 +00:00
|
|
|
if ($user->rights->fournisseur->facture->lire)
|
2005-12-05 18:49:35 +00:00
|
|
|
{
|
2011-11-08 22:10:31 +00:00
|
|
|
// TODO move to DAO class
|
2013-04-01 14:04:15 +00:00
|
|
|
$sql = 'SELECT f.rowid,f.libelle,f.ref_supplier,f.fk_statut,f.datef as df,f.total_ttc as amount,f.paye,';
|
2010-05-20 22:23:58 +00:00
|
|
|
$sql.= ' SUM(pf.amount) as am';
|
|
|
|
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
|
|
|
|
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
|
2011-11-08 22:10:31 +00:00
|
|
|
$sql.= ' WHERE f.fk_soc = '.$object->id;
|
2013-04-01 14:04:15 +00:00
|
|
|
$sql.= ' GROUP BY f.rowid,f.libelle,f.ref_supplier,f.fk_statut,f.datef,f.total_ttc,f.paye';
|
2010-05-20 22:23:58 +00:00
|
|
|
$sql.= ' ORDER BY f.datef DESC';
|
2009-10-04 12:16:45 +00:00
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2005-12-05 18:49:35 +00:00
|
|
|
{
|
2009-10-04 12:16:45 +00:00
|
|
|
$i = 0 ;
|
|
|
|
|
$num = $db->num_rows($resql);
|
2011-06-13 15:14:11 +00:00
|
|
|
if ($num > 0)
|
|
|
|
|
{
|
2011-11-03 00:59:13 +00:00
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
2011-06-13 15:14:11 +00:00
|
|
|
print '<td colspan="4">';
|
2013-08-24 20:41:32 +00:00
|
|
|
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id.'">'.$langs->trans('AllBills').' ('.$num.')</td>';
|
2011-11-08 22:10:31 +00:00
|
|
|
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
|
2011-06-13 15:14:11 +00:00
|
|
|
print '</tr></table>';
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
2009-10-04 12:16:45 +00:00
|
|
|
while ($i < min($num,$MAXLIST))
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
$var=!$var;
|
|
|
|
|
print '<tr '.$bc[$var].'>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
print '<a href="facture/fiche.php?facid='.$obj->rowid.'">';
|
2013-04-01 14:04:15 +00:00
|
|
|
print img_object($langs->trans('ShowBill'),'bill').' '.$obj->ref_supplier.'</a> '.dol_trunc($obj->libelle,14).'</td>';
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->df),'day').'</td>';
|
|
|
|
|
print '<td align="right" class="nowrap">'.price($obj->amount).'</td>';
|
|
|
|
|
print '<td align="right" class="nowrap">';
|
2010-05-20 22:23:58 +00:00
|
|
|
print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$obj->am);
|
|
|
|
|
print '</td>';
|
2009-10-04 12:16:45 +00:00
|
|
|
print '</tr>';
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
$db->free($resql);
|
2011-11-03 00:59:13 +00:00
|
|
|
if ($num > 0) print '</table>';
|
2005-12-05 18:49:35 +00:00
|
|
|
}
|
2009-10-04 12:16:45 +00:00
|
|
|
else
|
2005-12-05 18:49:35 +00:00
|
|
|
{
|
2009-10-04 12:16:45 +00:00
|
|
|
dol_print_error($db);
|
2005-12-05 18:49:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-01-28 17:54:37 +00:00
|
|
|
|
2013-04-21 15:56:29 +00:00
|
|
|
print '</div></div></div>';
|
|
|
|
|
print '<div style="clear:both"></div>';
|
2013-04-27 23:12:40 +00:00
|
|
|
|
2013-04-21 15:56:29 +00:00
|
|
|
dol_fiche_end();
|
2006-03-18 22:46:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Barre d'actions
|
|
|
|
|
*/
|
2006-04-06 19:21:19 +00:00
|
|
|
|
2006-03-18 22:46:29 +00:00
|
|
|
print '<div class="tabsAction">';
|
2006-04-06 19:21:19 +00:00
|
|
|
|
2006-03-18 22:46:29 +00:00
|
|
|
if ($user->rights->fournisseur->commande->creer)
|
|
|
|
|
{
|
|
|
|
|
$langs->load("orders");
|
2011-11-08 22:10:31 +00:00
|
|
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?action=create&socid='.$object->id.'">'.$langs->trans("AddOrder").'</a>';
|
2006-03-18 22:46:29 +00:00
|
|
|
}
|
2006-04-06 19:21:19 +00:00
|
|
|
|
2006-03-18 22:46:29 +00:00
|
|
|
if ($user->rights->fournisseur->facture->creer)
|
|
|
|
|
{
|
|
|
|
|
$langs->load("bills");
|
2011-11-08 22:10:31 +00:00
|
|
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
|
2006-03-18 22:46:29 +00:00
|
|
|
}
|
2006-04-06 19:21:19 +00:00
|
|
|
|
2010-09-19 12:50:53 +00:00
|
|
|
// Add action
|
2012-09-15 09:21:22 +00:00
|
|
|
if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
|
2010-09-19 12:50:53 +00:00
|
|
|
{
|
|
|
|
|
if ($user->rights->agenda->myactions->create)
|
|
|
|
|
{
|
2011-11-08 22:10:31 +00:00
|
|
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a>';
|
2010-09-19 12:50:53 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>';
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-18 12:26:55 +00:00
|
|
|
|
2006-03-18 22:46:29 +00:00
|
|
|
print '</div>';
|
2006-04-29 00:35:00 +00:00
|
|
|
print '<br>';
|
2006-04-06 19:21:19 +00:00
|
|
|
|
2010-09-19 12:50:53 +00:00
|
|
|
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
|
|
|
|
|
{
|
2011-06-13 13:07:10 +00:00
|
|
|
print '<br>';
|
2010-09-19 12:50:53 +00:00
|
|
|
// List of contacts
|
2013-11-13 15:37:17 +00:00
|
|
|
show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
2010-09-19 12:50:53 +00:00
|
|
|
}
|
2012-10-16 15:59:00 +00:00
|
|
|
|
2012-10-18 08:36:53 +00:00
|
|
|
// Addresses list
|
|
|
|
|
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB))
|
|
|
|
|
{
|
2012-07-02 17:30:37 +00:00
|
|
|
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
2012-03-14 17:03:36 +00:00
|
|
|
}
|
2010-09-19 12:50:53 +00:00
|
|
|
|
|
|
|
|
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
|
|
|
|
|
{
|
2012-02-13 00:43:35 +00:00
|
|
|
print load_fiche_titre($langs->trans("ActionsOnCompany"),'','');
|
|
|
|
|
|
2010-09-19 12:50:53 +00:00
|
|
|
// List of todo actions
|
2011-11-08 22:10:31 +00:00
|
|
|
show_actions_todo($conf,$langs,$db,$object);
|
2010-02-27 20:30:55 +00:00
|
|
|
|
2010-09-19 12:50:53 +00:00
|
|
|
// List of done actions
|
2011-11-08 22:10:31 +00:00
|
|
|
show_actions_done($conf,$langs,$db,$object);
|
2010-09-19 12:50:53 +00:00
|
|
|
}
|
2003-05-13 14:27:40 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-02-20 22:53:15 +00:00
|
|
|
dol_print_error($db);
|
2002-05-06 19:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-27 14:24:16 +00:00
|
|
|
llxFooter();
|
2011-12-28 14:21:29 +00:00
|
|
|
|
|
|
|
|
$db->close();
|
2002-05-06 19:10:48 +00:00
|
|
|
?>
|