Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2015-08-31 12:13:35 +02:00
commit 942723ff8d
22 changed files with 307 additions and 76 deletions

View File

@ -97,6 +97,12 @@ $modules=array(
'img' => 'user'
)
),
'expensereport' => array(
array(
'code' => 'MAIN_DELAY_EXPENSEREPORTS',
'img' => 'trip'
)
),
);
if ($action == 'update')

View File

@ -538,11 +538,11 @@ if ($id > 0 || ! empty($ref))
print '<input type="hidden" name="id" value="'.$object->id.'">';
$period_filter .= $langs->trans('From').'&nbsp;'.$form->select_date($req_stdt,'req_stdt',0,0,1,null,1,1,1);
$period_filter .= '<BR>'. $langs->trans('to').'&nbsp;'.$form->select_date($req_enddt,'req_enddt',0,0,1,null,1,1,1);
$period_filter .= '&nbsp;';
$period_filter .= $langs->trans('to').'&nbsp;'.$form->select_date($req_enddt,'req_enddt',0,0,1,null,1,1,1);
print '<tr class="liste_titre">';
print '<td>&nbsp;</td>';
print '<td>'.$period_filter.'</td>';
print '<td colspan="2">'.$period_filter.'</td>';
print '<td>';
//$filtertype=array('TIP'=>'TIP','PRE'=>'PRE',...)
$filtertype='';

View File

@ -3851,6 +3851,7 @@ else if ($id > 0 || ! empty($ref))
$formmail->substit['__REFCLIENT__'] = $object->ref_client;
$formmail->substit['__THIRPARTY_NAME__'] = $object->thirdparty->name;
$formmail->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:'');
$formmail->substit['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:'');
$formmail->substit['__PERSONALIZED__'] = '';
$formmail->substit['__CONTACTCIVNAME__'] = '';

View File

@ -191,17 +191,18 @@ if ($result)
// Type
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
// Amount
print "<td align=\"right\">".price($obj->amount,0,$outputlangs,1,-1,-1,$conf->currency)."</td>";
print "<td>&nbsp;</td>";
print "<td align=\"right\">".price($obj->amount)."</td>";
print "<td></td>";
print "</tr>\n";
$total = $total + $obj->amount;
$i++;
}
print '<tr class="liste_total"><td colspan="6" class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.price($total,0,$outputlangs,1,-1,-1,$conf->currency)."</td>";
print "<td>&nbsp;</td></tr>";
print "<td></td></tr>";
print "</table>";

View File

@ -516,9 +516,10 @@ class Contact extends CommonObject
*/
function fetch($id, $user=0, $ref_ext='')
{
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
global $langs;
dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG);
if (empty($id) && empty($ref_ext))
{
$this->error='BadParameter';
@ -547,7 +548,6 @@ class Contact extends CommonObject
if ($id) $sql.= " WHERE c.rowid = ". $id;
elseif ($ref_ext) $sql .= " WHERE c.ref_ext = '".$this->db->escape($ref_ext)."'";
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{

View File

@ -2159,11 +2159,11 @@ abstract class CommonObject
$sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element);
$targettype = (! empty($targettype) ? $targettype : $this->element);
if (empty($sourceid) && empty($targetid))
/*if (empty($sourceid) && empty($targetid))
{
dol_syslog('Bad usage of function. No source nor target id defined (nor as parameter nor as object id)', LOG_ERR);
return -1;
}
}*/
// Links between objects are stored in table element_element
$sql = 'SELECT rowid, fk_source, sourcetype, fk_target, targettype';
@ -3794,7 +3794,7 @@ abstract class CommonObject
*/
function showOptionals($extrafields, $mode='view', $params=null, $keyprefix='')
{
global $_POST, $conf;
global $_POST, $conf, $langs;
$out = '';
@ -3852,7 +3852,7 @@ abstract class CommonObject
if($extrafields->attribute_required[$key])
$label = '<span class="fieldrequired">'.$label.'</span>';
$out .= '<td>'.$label.'</td>';
$out .= '<td>'.$langs->trans($label).'</td>';
$out .='<td'.($colspan?' colspan="'.$colspan.'"':'').'>';
switch($mode) {

View File

@ -474,6 +474,7 @@ class Conf
$this->adherent->cotisation = new stdClass();
$this->bank->rappro = new stdClass();
$this->bank->cheque = new stdClass();
$this->expensereport->payment = new stdClass();
$this->actions->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60;
$this->commande->client->warning_delay=(isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_ORDERS_TO_PROCESS:2)*24*60*60;
$this->commande->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS:7)*24*60*60;
@ -486,6 +487,7 @@ class Conf
$this->adherent->cotisation->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60;
$this->bank->rappro->warning_delay=(isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE)?$this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE:0)*24*60*60;
$this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60;
$this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60;
// For modules that want to disable top or left menu
if (! empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu=$this->global->MAIN_HIDE_TOP_MENU;

View File

@ -24,12 +24,12 @@
/**
* Function get content from an URL (use proxy if proxy defined)
*
* @param string $url URL to call.
* @param string $postorget 'POST', 'GET', 'HEAD'
* @param string $param Parameters of URL (x=value1&y=value2)
* @param string $followlocation 1=Follow location, 0=Do not follow
* @param array $addheaders Array of string to add into header. Example: array('Accept: application/xrds+xml', ....)
* @return array Returns an associative array containing the response from the server array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
* @param string $url URL to call.
* @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'DELETE'
* @param string $param Parameters of URL (x=value1&y=value2) or may be a formated content with PUTALREADYFORMATED
* @param string $followlocation 1=Follow location, 0=Do not follow
* @param array $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....)
* @return array Returns an associative array containing the response from the server array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
*/
function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addheaders=array())
{
@ -74,7 +74,18 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
else if ($postorget == 'PUT')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as PUT fields
if (! is_array($param)) parse_str($param, $array_param);
else
{
dol_syslog("parameter param must be a string", LOG_WARNING);
$array_param=$param;
}
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields
}
else if ($postorget == 'PUTALREADYFORMATED')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string
}
else if ($postorget == 'HEAD')
{

View File

@ -744,7 +744,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
// First line of company infos
$line1=""; $line2=""; $line3=""; $line4="";
if ($showdetails && 1)
if ($showdetails)
{
// Company name
if ($fromcompany->name)
@ -788,7 +788,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
$line2.=($line2?" - ":"").$fromcompany->email;
}
}
if (($showdetails && 2) || ($fromcompany->country_code == 'DE'))
if ($showdetails || ($fromcompany->country_code == 'DE'))
{
// Managers
if ($fromcompany->managers)
@ -1707,7 +1707,7 @@ function pdf_getLinkedObjects($object,$outputlangs)
foreach($objects as $elementobject)
{
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$objects[$i]->ref_client.')' : '');
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '');
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs);
}

View File

@ -49,7 +49,7 @@ if (empty($reshook) && ! empty($extrafields->attribute_label))
print '<table width="100%" class="nobordernopadding"><tr><td';
//var_dump($action);exit;
if ((! empty($action) && ($action == 'create' || $action == 'edit')) && ! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
print '>' . $label . '</td>';
print '>' . $langs->trans($label) . '</td>';
//TODO Improve element and rights detection
//var_dump($user->rights);

View File

@ -1480,6 +1480,89 @@ class ExpenseReport extends CommonObject
return $ret;
}
/**
* Charge indicateurs this->nb pour le tableau de bord
*
* @return int <0 if KO, >0 if OK
*/
function load_state_board()
{
global $conf;
$this->nb=array();
$sql = "SELECT count(ex.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
$sql.= " WHERE ex.fk_statut > 0";
$sql.= " AND ex.entity IN (".getEntity('expensereport', 1).")";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["expensereports"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Objet user
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/
function load_board($user)
{
global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
$now=dol_now();
$sql = "SELECT ex.rowid, ex.date_valid";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
$sql.= " WHERE ex.fk_statut = 5";
$sql.= " AND ex.entity IN (".getEntity('expensereport', 1).")";
$resql=$this->db->query($sql);
if ($resql)
{
$langs->load("members");
$response = new WorkboardResponse();
$response->warning_delay=$conf->expensereport->payment->warning_delay/60/60/24;
$response->label=$langs->trans("ExpenseReportsToPay");
$response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut=5';
$response->img=img_object($langs->trans("ExpenseReports"),"user");
while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;
if ($this->db->jdate($obj->datevalid) < ($now - $conf->expensereport->payment->warning_delay)) {
$response->nbtodolate++;
}
}
return $response;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
}

View File

@ -4,8 +4,9 @@
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2014 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* 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
@ -262,6 +263,12 @@ if ($object->id > 0)
print "</td>";
print '</tr>';
// Categories
print '<tr><td>' . $langs->trans("Categories") . '</td>';
print '<td colspan="3">';
print $form->showCategories($object->id, 'supplier', 1);
print "</td></tr>";
// Other attributes
$parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook

View File

@ -158,7 +158,8 @@ if (empty($user->societe_id))
! empty($conf->facture->enabled) && $user->rights->facture->lire,
! empty($conf->contrat->enabled) && $user->rights->contrat->activer,
! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire,
! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire);
! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire,
! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire);
// Class file containing the method load_state_board for each line
$includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
@ -171,7 +172,8 @@ if (empty($user->societe_id))
DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php",
DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php",
DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php");
DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php",
DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php");
// Name class containing the method load_state_board for each line
$classes=array('Client',
'Client',
@ -184,7 +186,8 @@ if (empty($user->societe_id))
'Facture',
'Contrat',
'CommandeFournisseur',
'FactureFournisseur');
'FactureFournisseur',
'ExpenseReport');
// Cle array returned by the method load_state_board for each line
$keys=array('customers',
'prospects',
@ -197,7 +200,8 @@ if (empty($user->societe_id))
'invoices',
'Contracts',
'supplier_orders',
'supplier_invoices');
'supplier_invoices',
'expensereports');
// Dashboard Icon lines
$icons=array('company',
'company',
@ -210,7 +214,8 @@ if (empty($user->societe_id))
'bill',
'order',
'order',
'bill');
'bill',
'trip');
// Translation keyword
$titres=array("ThirdPartyCustomersStats",
"ThirdPartyProspectsStats",
@ -223,7 +228,8 @@ if (empty($user->societe_id))
"BillsCustomers",
"Contracts",
"SuppliersOrders",
"SuppliersInvoices");
"SuppliersInvoices",
"ExpenseReports");
// Dashboard Link lines
$links=array(DOL_URL_ROOT.'/comm/list.php',
DOL_URL_ROOT.'/comm/prospect/list.php',
@ -236,7 +242,8 @@ if (empty($user->societe_id))
DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy',
DOL_URL_ROOT.'/contrat/list.php',
DOL_URL_ROOT.'/fourn/commande/list.php',
DOL_URL_ROOT.'/fourn/facture/list.php');
DOL_URL_ROOT.'/fourn/facture/list.php',
DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm');
// Translation lang files
$langfile=array("companies",
"prospects",
@ -247,7 +254,8 @@ if (empty($user->societe_id))
"propal",
"orders",
"bills",
"contracts");
"contracts",
"trips");
// Loop and displays each line of table
@ -402,6 +410,15 @@ if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $use
$dashboardlines[] = $board->load_board($user);
}
// Number of expense reports to pay
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
{
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board=new ExpenseReport($db);
$dashboardlines[] = $board->load_board($user);
}
// Calculate total nb of late
$totallate=0;
$var=true;

View File

@ -75,6 +75,7 @@ insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_NOT
insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_RUNNING_SERVICES','0','chaine','Tolérance de retard avant alerte (en jours) sur services expirés',0);
insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_MEMBERS','31','chaine','Tolérance de retard avant alerte (en jours) sur cotisations adhérent en retard',0);
insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE','62','chaine','Tolérance de retard avant alerte (en jours) sur rapprochements bancaires à faire',0);
insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_EXPENSEREPORTS_TO_PAY','31','chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0);
--

View File

@ -0,0 +1,25 @@
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
-- when current version is 3.9.0 or higher.
--
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name;
-- To restrict request to Mysql version x.y use -- VMYSQLx.y
-- To restrict request to Pgsql version x.y use -- VPGSQLx.y
-- To make pk to be auto increment (mysql): VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
-- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE
-- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
-- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_DELAY_EXPENSEREPORTS_TO_PAY','31','chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0);
ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32);
ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32);

View File

@ -21,7 +21,7 @@
create table llx_accounting_system
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
pcg_version varchar(12) NOT NULL,
pcg_version varchar(32) NOT NULL,
fk_pays integer NOT NULL,
label varchar(128) NOT NULL,
active smallint DEFAULT 0

View File

@ -24,7 +24,7 @@ create table llx_accountingaccount
entity integer DEFAULT 1 NOT NULL,
datec datetime,
tms timestamp,
fk_pcg_version varchar(12) NOT NULL,
fk_pcg_version varchar(32) NOT NULL,
pcg_type varchar(20) NOT NULL,
pcg_subtype varchar(20) NOT NULL,
account_number varchar(32) NOT NULL,

View File

@ -102,3 +102,5 @@ ConfirmSaveTrip=Are you sure you want to validate this expense report ?
NoTripsToExportCSV=No expense report to export for this period.
ExpenseReportPayment=Expense report payment
ExpenseReportsToPay=Expense reports to pay

View File

@ -204,7 +204,7 @@ if ($id > 0 || ! empty($ref))
print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->libelle.'</td>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td>';
print '</tr>';
// Nature

View File

@ -660,9 +660,16 @@ class MouvementStock extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$origin = new FactureFournisseur($this->db);
break;
default:
return '';
if ($origintype)
{
dol_include_once ('/'.$origintype.'/class/'.$origintype.'.class.php');
$classname = ucfirst($origintype);
$origin = new $classname($this->db);
}
else
return '';
break;
}

View File

@ -347,7 +347,7 @@ $langs->load("margins");
//print load_fiche_titre($langs->trans("Profit"),'','title_accountancy');
print '<div class="center">'.img_picto("", "title_accountancy").' '.$langs->trans("Profit").'</div><br>';
print '<table class="noborder">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td align="left" width="200">'.$langs->trans("Element").'</td>';
print '<td align="right" width="100">'.$langs->trans("Number").'</td>';

View File

@ -1,14 +1,15 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2013 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2013 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* 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
@ -411,7 +412,7 @@ if (empty($reshook))
}
}
// Categories association
// Customer categories association
$custcats = GETPOST( 'custcats', 'array' );
if (!empty( $custcats )) {
$cat = new Categorie( $db );
@ -421,6 +422,16 @@ if (empty($reshook))
}
}
// Supplier categories association
$suppcats = GETPOST('suppcats', 'array');
if (!empty($suppcats)) {
$cat = new Categorie($db);
foreach ($suppcats as $id_category) {
$cat->fetch($id_category);
$cat->add_type($object, 'supplier');
}
}
// Logo/Photo save
$dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
@ -525,7 +536,7 @@ if (empty($reshook))
$error = $object->error; $errors = $object->errors;
}
// Categories association
// Customer categories association
// First we delete all categories association
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_societe';
$sql .= ' WHERE fk_soc = ' . $object->id;
@ -541,6 +552,22 @@ if (empty($reshook))
}
}
// Supplier categories association
// First we delete all categories association
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_fournisseur';
$sql .= ' WHERE fk_soc = ' . $object->id;
$db->query($sql);
// Then we add the associated categories
$categories = GETPOST('suppcats', 'array');
if (!empty($categories)) {
$cat = new Categorie($db);
foreach ($categories as $id_category) {
$cat->fetch($id_category);
$cat->add_type($object, 'supplier');
}
}
// Logo/Photo save
$dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
@ -1245,13 +1272,26 @@ else
}
// Categories
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
{
print '<tr><td class="toptd">'.fieldLabel('Categories','custcats').'</td><td colspan="3">';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1);
print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%");
print "</td></tr>";
}
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
{
// Customer
if ($object->prospect || $object->client) {
print '<tr><td class="toptd">' . fieldLabel('CustomersCategoriesShort', 'custcats') . '</td><td colspan="3">';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1);
print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null,
null, "90%");
print "</td></tr>";
}
// Supplier
if ($object->fournisseur) {
print '<tr><td class="toptd">' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td><td colspan="3">';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1);
print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null,
null, "90%");
print "</td></tr>";
}
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
@ -1761,19 +1801,36 @@ else
}
// Categories
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
{
print '<tr><td>'.fieldLabel('Categories', 'custcats').'</td>';
print '<td colspan="3">';
$cate_arbo = $form->select_all_categories( Categorie::TYPE_CUSTOMER, null, null, null, null, 1);
$c = new Categorie( $db );
$cats = $c->containing( $object->id, Categorie::TYPE_CUSTOMER );
foreach ($cats as $cat) {
$arrayselected[] = $cat->id;
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
{
// Customer
if ($object->prospect || $object->client) {
print '<tr><td>' . fieldLabel('CustomersCategoriesShort', 'custcats') . '</td>';
print '<td colspan="3">';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1);
$c = new Categorie($db);
$cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
foreach ($cats as $cat) {
$arrayselected[] = $cat->id;
}
print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
print "</td></tr>";
}
print $form->multiselectarray( 'custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
print "</td></tr>";
}
// Supplier
if ($object->fournisseur) {
print '<tr><td>' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td>';
print '<td colspan="3">';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1);
$c = new Categorie($db);
$cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
foreach ($cats as $cat) {
$arrayselected[] = $cat->id;
}
print $form->multiselectarray('suppcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
print "</td></tr>";
}
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
@ -2207,13 +2264,24 @@ else
}
// Tags / categories
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
{
print '<tr><td>' . $langs->trans( "Categories" ) . '</td>';
print '<td colspan="3">';
print $form->showCategories( $object->id, 'customer', 1 );
print "</td></tr>";
}
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
{
// Customer
if ($object->prospect || $object->client) {
print '<tr><td>' . $langs->trans("CustomersCategoriesShort") . '</td>';
print '<td colspan="3">';
print $form->showCategories($object->id, 'customer', 1);
print "</td></tr>";
}
// Supplier
if ($object->fournisseur) {
print '<tr><td>' . $langs->trans("SuppliersCategoriesShort") . '</td>';
print '<td colspan="3">';
print $form->showCategories($object->id, 'supplier', 1);
print "</td></tr>";
}
}
// Incoterms
if (!empty($conf->incoterm->enabled))