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

This commit is contained in:
Laurent Destailleur 2015-06-12 13:09:32 +02:00
commit ed0e6753e3
84 changed files with 2631 additions and 1370 deletions

View File

@ -41,6 +41,7 @@ Dolibarr better:
- Hooks 'printLeftBlock' and 'formConfirm' are now compliant with hook development rules. They are
"addreplace" hooks, so you must return content with "->resprints='mycontent'" and not with "return 'mycontent'"
- All fields "fk_societe" were renamed into "fk_soc".
- Method select_PriceBaseType and load_PriceBaseType were merged into selectPriceBaseType
***** ChangeLog for 3.7.1 compared to 3.7.* *****
FIX Bug in the new photo system

View File

@ -352,8 +352,9 @@ if ($id && (empty($action) || $action == 'view'))
// Example 2 : Adding links to objects
// The class must extends CommonObject class to have this method available
//$somethingshown=$object->showLinkedObjectBlock();
//$somethingshown=$form->showLinkedObjectBlock($object);
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
}

View File

@ -385,7 +385,7 @@ if ($action == 'edit' || $action == 'updateedit')
}
else
{
print '<img height="30" src="'.DOL_URL_ROOT.'/theme/common/nophoto.jpg">';
print '<img height="30" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.jpg">';
}
print '</td></tr></table>';
print '</td></tr>';
@ -777,7 +777,7 @@ else
}
else
{
print '<img height="30" src="'.DOL_URL_ROOT.'/theme/common/nophoto.jpg">';
print '<img height="30" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.jpg">';
}
print '</td></tr></table>';

View File

@ -44,6 +44,8 @@ class DolibarrApiAccess implements iAuthenticate
*/
public static $user = '';
// @codingStandardsIgnoreStart
/**
* Check access
*
@ -106,7 +108,6 @@ class DolibarrApiAccess implements iAuthenticate
return in_array(static::$role, (array) static::$requires) || static::$role == 'admin';
}
// @codingStandardsIgnoreStart
/**
* @return string string to be used with WWW-Authenticate header
* @example Basic

View File

@ -102,7 +102,7 @@ print "</tr>\n";
$var=!$var;
print '<tr '.$bc[$var].'><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
print '<td colspan="2">';
print $form->select_thirdparty($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3)',0,array(),1);
print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3)',1,0,1,array(),0);
print '</td></tr>';
if (! empty($conf->banque->enabled))
{
@ -133,17 +133,17 @@ if (! empty($conf->stock->enabled))
if (empty($conf->productbatch->enabled)) {
print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK',$conf->global->CASHDESK_NO_DECREASE_STOCK,1);
}
else
else
{
if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
$res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity);
}
print $langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch');
print $langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch');
}
print '</td></tr>';
$disabled=$conf->global->CASHDESK_NO_DECREASE_STOCK;
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
print '<td colspan="2">';

View File

@ -1215,7 +1215,7 @@ class Categorie extends CommonObject
}
/**
* Return list of categories (id or instances) linked to element of id $id and type $type
* Return list of categories (object instances or labels) linked to element of id $id and type $type
* Should be named getListOfCategForObject
*
* @param int $id Id of element
@ -1228,20 +1228,15 @@ class Categorie extends CommonObject
*/
function containing($id,$type,$mode='object')
{
// Deprecation warning
if (is_numeric($type)) {
dol_syslog(__METHOD__ . ': using numeric types is deprecated.', LOG_WARNING);
}
$cats = array();
// For backward compatibility
if (is_numeric( $type )) {
if (is_numeric($type))
{
dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
// We want to reverse lookup
$map_type = array_flip( $this->MAP_ID );
$map_type = array_flip($this->MAP_ID);
$type = $map_type[$type];
dol_syslog( get_class( $this ) . "::containing(): numeric types are deprecated, please use string instead",
LOG_WARNING );
}
$sql = "SELECT ct.fk_categorie, c.label";
@ -1249,7 +1244,6 @@ class Categorie extends CommonObject
$sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . $id . " AND c.type = " . $this->MAP_ID[$type];
$sql .= " AND c.entity IN (" . getEntity( 'category', 1 ) . ")";
dol_syslog(get_class($this).'::containing', LOG_DEBUG);
$res = $this->db->query($sql);
if ($res)
{

View File

@ -215,7 +215,7 @@ if ($action == 'add')
$object->duree=((float) (GETPOST('dureehour') * 60) + (float) GETPOST('dureemin')) * 60;
$listofuserid=array();
if (! empty($_SESSION['assignedtouser'])) $listofuserid=json_decode($_SESSION['assignedtouser']);
if (! empty($_SESSION['assignedtouser'])) $listofuserid=json_decode($_SESSION['assignedtouser'], true);
$i=0;
foreach($listofuserid as $key => $value)
{

View File

@ -1709,10 +1709,12 @@ if ($action == 'create')
$somethingshown = $formfile->show_documents('askpricesupplier', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
/*
* Linked object block
*/
$somethingshown = $object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@ -2307,10 +2307,13 @@ if ($action == 'create')
$somethingshown = $formfile->show_documents('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
/*
* Linked object block
*/
$somethingshown = $object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object);
if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// print '</td><td valign="top" width="50%">';
@ -2337,7 +2340,7 @@ if ($action == 'create')
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/'));
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file = $fileparams['fullname'];
// Define output language
@ -2362,7 +2365,7 @@ if ($action == 'create')
dol_print_error($db, $result);
exit();
}
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/'));
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file = $fileparams['fullname'];
}

View File

@ -56,6 +56,7 @@ $search_refcustomer=GETPOST('search_refcustomer','alpha');
$search_societe=GETPOST('search_societe','alpha');
$search_montant_ht=GETPOST('search_montant_ht','alpha');
$search_author=GETPOST('search_author','alpha');
$search_product_category=GETPOST('search_product_category','int');
$search_town=GETPOST('search_town','alpha');
$viewstatut=$db->escape(GETPOST('viewstatut'));
$object_statut=$db->escape(GETPOST('propal_statut'));
@ -91,6 +92,7 @@ if (GETPOST("button_removefilter") || GETPOST("button_removefilter_x")) // Both
$search_societe='';
$search_montant_ht='';
$search_author='';
$search_product_category='';
$search_town='';
$year='';
$month='';
@ -145,14 +147,15 @@ if (! $sortorder) $sortorder='DESC';
$limit = $conf->liste_limit;
if (! $sall) $sql = 'SELECT';
else $sql = 'SELECT DISTINCT';
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql.= ' s.rowid, s.nom as name, s.town, s.client, s.code_client,';
$sql.= ' p.rowid as propalid, p.note_private, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,';
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,";
$sql.= ' u.login';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p';
if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
// We'll need this table joined to the select in order to filter by sale
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -190,7 +193,8 @@ if ($search_montant_ht != '')
if ($sall) {
$sql .= natural_search(array('s.nom', 'p.note_private', 'p.note_public', 'pd.description'), $sall);
}
if ($socid) $sql.= ' AND s.rowid = '.$socid;
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
if ($viewstatut <> '')
{
$sql.= ' AND p.fk_statut IN ('.$viewstatut.')';
@ -223,7 +227,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
//print $sql;
$sql.= $db->plimit($limit + 1,$offset);
$result=$db->query($sql);
@ -265,15 +269,28 @@ if ($result)
if ($user->rights->societe->client->voir || $socid)
{
$langs->load("commercial");
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
$moreforfilter.='</div>';
}
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
$moreforfilter.=$form->select_dolusers($search_user,'search_user',1);
$moreforfilter.='</div>';
}
// If the user can view prospects other than his'
if ($conf->categorie->enabled && $user->rights->produit->lire)
{
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
$moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1);
$moreforfilter.='</div>';
}
if (! empty($moreforfilter))
{

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
@ -2305,10 +2305,13 @@ if ($action == 'create' && $user->rights->commande->creer)
$delallowed = $user->rights->commande->supprimer;
$somethingshown = $formfile->show_documents('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
/*
* Linked object block
*/
$somethingshown = $object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// print '</td><td valign="top" width="50%">';
@ -2331,7 +2334,6 @@ if ($action == 'create' && $user->rights->commande->creer)
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams['fullname'];
// Define output language
@ -2356,7 +2358,7 @@ if ($action == 'create' && $user->rights->commande->creer)
dol_print_error($db, $result);
exit();
}
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/'));
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file = $fileparams['fullname'];
}

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
@ -2134,7 +2134,7 @@ if ($action == 'create')
print '</div></div>';
// Next situation invoice
$opt = $form->load_situation_invoices(GETPOST('originid'), $socid);
$opt = $form->selectSituationInvoices(GETPOST('originid'), $socid);
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" value="5"' . (GETPOST('type') == 5 && GETPOST('originid') ? ' checked' : '');
if ($opt == ('<option value ="0" selected>' . $langs->trans('NoSituations') . '</option>') || (GETPOST('origin') && GETPOST('origin') != 'facture')) $tmp.=' disabled';
@ -3776,77 +3776,10 @@ if ($action == 'create')
$somethingshown = $formfile->numoffiles;
// Linked object block
$somethingshown = $object->showLinkedObjectBlock();
$somethingshown = $form->showLinkedObjectBlock($object);
$linktoelem='';
if (! empty($conf->commande->enabled))
{
$linktoelem.=($linktoelem?' &nbsp; ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
print '
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#linktoorder").click(function() {
jQuery("#orderlist").toggle();
jQuery("#linktoorder").toggle();
});
});
</script>
';
print '<div id="orderlist" style="display:none">';
$sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_client, c.total_ht";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "commande as c";
$sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $soc->id . '';
$resqlorderlist = $db->query($sql);
if ($resqlorderlist)
{
$num = $db->num_rows($resqlorderlist);
$i = 0;
print '<br><form action="" method="POST" name="LinkedOrder">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td class="nowrap"></td>';
print '<td align="center">' . $langs->trans("Ref") . '</td>';
print '<td align="left">' . $langs->trans("RefCustomer") . '</td>';
print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>';
print '<td align="left">' . $langs->trans("Company") . '</td>';
print '</tr>';
while ($i < $num)
{
$objp = $db->fetch_object($resqlorderlist);
if ($objp->socid == $soc->id) {
$var = ! $var;
print '<tr ' . $bc [$var] . '>';
print '<td aling="left">';
print '<input type="radio" name="linkedOrder" value=' . $objp->rowid . '>';
print '<td align="center">' . $objp->ref . '</td>';
print '<td>' . $objp->ref_client . '</td>';
print '<td>' . price($objp->total_ht) . '</td>';
print '<td>' . $objp->name . '</td>';
print '</td>';
print '</tr>';
}
$i ++;
}
print '</table>';
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('ToLink') . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
print '</form>';
$db->free($resqlorderlist);
} else {
dol_print_error($db);
}
print '</div>';
}
// Show link to elements
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print '<br>'.$linktoelem;
// Link for paypal payment
@ -3888,7 +3821,7 @@ if ($action == 'create')
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/'));
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file = $fileparams['fullname'];
// Define output language
@ -3913,7 +3846,7 @@ if ($action == 'create')
dol_print_error($db, $result);
exit();
}
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/'));
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file = $fileparams['fullname'];
}

View File

@ -1871,10 +1871,13 @@ else
$somethingshown = $formfile->show_documents('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
/*
* Linked object block
*/
$somethingshown=$object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object);
if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2011-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2011-2015 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
@ -148,7 +148,21 @@ if ($action == 'add')
}
}
$result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params,(GETPOST('alwayseditable')?1:0));
$result=$extrafields->addExtraField(
GETPOST('attrname'),
GETPOST('label'),
GETPOST('type'),
GETPOST('pos'),
$extrasize,
$elementtype,
(GETPOST('unique')?1:0),
(GETPOST('required')?1:0),
$default_value,
$params,
(GETPOST('alwayseditable')?1:0),
(GETPOST('perms')?GETPOST('perms'):''),
(GETPOST('list')?1:0)
);
if ($result > 0)
{
setEventMessage($langs->trans('SetupSaved'));
@ -285,7 +299,20 @@ if ($action == 'update')
$params['options'][$key] = $value;
}
}
$result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$pos,$params,(GETPOST('alwayseditable')?1:0));
$result=$extrafields->update(
GETPOST('attrname'),
GETPOST('label'),
GETPOST('type'),
$extrasize,
$elementtype,
(GETPOST('unique')?1:0),
(GETPOST('required')?1:0),
$pos,
$params,
(GETPOST('alwayseditable')?1:0),
(GETPOST('perms')?GETPOST('perms'):''),
(GETPOST('list')?1:0)
);
if ($result > 0)
{
setEventMessage($langs->trans('SetupSaved'));

View File

@ -37,7 +37,7 @@
class CMailFile
{
var $subject; // Topic: Subject of email
var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@mydomain.com>' or 'John Doe <myemail@mydomain.com>' or '<myemail+trackingid@mydomain.com>')
var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>')
// Sender: Who send the email ("Sender" has sent emails on behalf of "From").
// Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, use for Sender an email of the protected domain.
// Return-Path: Email where to send bounds.
@ -387,7 +387,7 @@ class CMailFile
// If Windows, sendmail_from must be defined
if (isset($_SERVER["WINDIR"]))
{
if (empty($this->addr_from)) $this->addr_from = 'robot@mydomain.com';
if (empty($this->addr_from)) $this->addr_from = 'robot@example.com';
@ini_set('sendmail_from',$this->getValidAddress($this->addr_from,2));
}

View File

@ -135,8 +135,8 @@ abstract class CommonObject
$sql = "SELECT rowid, ref, ref_ext";
$sql.= " FROM ".MAIN_DB_PREFIX.$element;
$sql.= " WHERE entity IN (".getEntity($element).")" ;
$sql.= " WHERE entity IN (".getEntity($element).")" ;
if ($id > 0) $sql.= " AND rowid = ".$db->escape($id);
else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'";
else if ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'";
@ -2580,88 +2580,19 @@ abstract class CommonObject
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions
// --------------------
/* This is to show linked object block */
/**
* Show linked object block
* TODO Move this into html.class.php
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* Show linked object block.
*
* @return int
* @return int <0 if KO, >0 if OK
* @deprecated 3.8 Use instead $form->shoLinkedObjectBlock($object)
*/
function showLinkedObjectBlock()
{
global $conf,$langs,$hookmanager;
global $bc;
$this->fetchObjectLinked();
// Bypass the default method
$hookmanager->initHooks(array('commonobject'));
$parameters=array();
$reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
$num = count($this->linkedObjects);
foreach($this->linkedObjects as $objecttype => $objects)
{
$tplpath = $element = $subelement = $objecttype;
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
$tplpath = $element.'/'.$subelement;
}
// To work with non standard path
if ($objecttype == 'facture') {
$tplpath = 'compta/'.$element;
if (empty($conf->facture->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'propal') {
$tplpath = 'comm/'.$element;
if (empty($conf->propal->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'askpricesupplier') {
$tplpath = 'comm/'.$element;
if (empty($conf->askpricesupplier->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'shipping' || $objecttype == 'shipment') {
$tplpath = 'expedition';
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'delivery') {
$tplpath = 'livraison';
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'invoice_supplier') {
$tplpath = 'fourn/facture';
}
else if ($objecttype == 'order_supplier') {
$tplpath = 'fourn/commande';
}
global $linkedObjectBlock;
$linkedObjectBlock = $objects;
// Output template part (modules that overwrite templates must declare this into descriptor)
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/linkedobjectblock.tpl.php');
if ($res) break;
}
}
return $num;
}
global $form;
return $form->showLinkedObjectBlock($this);
}
/* This is to show add lines */
/**
@ -3108,222 +3039,18 @@ abstract class CommonObject
}
/**
* get Margin info
*
* @param boolean $force_price True of not
* @return mixed Array with info
*/
function getMarginInfos($force_price=false)
{
global $conf;
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$marginInfos = array(
'pa_products' => 0,
'pv_products' => 0,
'margin_on_products' => 0,
'margin_rate_products' => '',
'mark_rate_products' => '',
'pa_services' => 0,
'pv_services' => 0,
'margin_on_services' => 0,
'margin_rate_services' => '',
'mark_rate_services' => '',
'pa_total' => 0,
'pv_total' => 0,
'total_margin' => 0,
'total_margin_rate' => '',
'total_mark_rate' => ''
);
foreach($this->lines as $line) {
if (empty($line->pa_ht) && isset($line->fk_fournprice) && !$force_price) {
$product = new ProductFournisseur($this->db);
if ($product->fetch_product_fournisseur_price($line->fk_fournprice))
$line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100);
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0)
$line->pa_ht += $product->fourn_unitcharges;
}
// si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente
if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) {
$line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100));
}
// calcul des marges
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
$pa = $line->qty * $line->pa_ht;
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit
$marginInfos['pa_products'] += $pa;
$marginInfos['pv_products'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_products'] += $pv - $pa;
}
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service
$marginInfos['pa_services'] += $pa;
$marginInfos['pv_services'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_services'] += $pv - $pa;
}
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
}
}
else {
$type=$line->product_type?$line->product_type:$line->fk_product_type;
if ($type == 0) { // product
$pa = $line->qty * $line->pa_ht;
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pa_products'] += $pa;
$marginInfos['pv_products'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_products'] += $pv - $pa;
}
elseif ($type == 1) { // service
$pa = $line->qty * $line->pa_ht;
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pa_services'] += $pa;
$marginInfos['pv_services'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_services'] += $pv - $pa;
}
}
}
if ($marginInfos['pa_products'] > 0)
$marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products'];
if ($marginInfos['pv_products'] > 0)
$marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products'];
if ($marginInfos['pa_services'] > 0)
$marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services'];
if ($marginInfos['pv_services'] > 0)
$marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services'];
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($marginInfos['pv_total'] < 0)
$marginInfos['total_margin'] = -1 * (abs($marginInfos['pv_total']) - $marginInfos['pa_total']);
else
$marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total'];
if ($marginInfos['pa_total'] > 0)
$marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total'];
if ($marginInfos['pv_total'] > 0)
$marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total'];
return $marginInfos;
}
/**
* Show the array with all margin infos
*
* @param boolean $force_price Force price
* @return void
* @param boolean $force_price Force price
* @return void
* @deprecated 3.8 Load FormMargin class and make a direct call to displayMarginInfos
*/
function displayMarginInfos($force_price=false)
{
global $langs, $conf, $user;
if (! empty($user->societe_id)) return;
if (! $user->rights->margins->liretous) return;
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
$marginInfo = $this->getMarginInfos($force_price);
if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better
{
print $langs->trans('ShowMarginInfos').' : ';
$hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW'];
print '<span id="showMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'':'hideobject').'">'.img_picto($langs->trans("Disabled"),'switch_off').'</span>';
print '<span id="hideMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'hideobject':'').'">'.img_picto($langs->trans("Enabled"),'switch_on').'</span>';
print '<script>$(document).ready(function() {
$("span#showMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 0); $(".margininfos").show(); $("span#showMarginInfos").addClass("hideobject"); $("span#hideMarginInfos").removeClass("hideobject");})});
$("span#hideMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 1); $(".margininfos").hide(); $("span#hideMarginInfos").addClass("hideobject"); $("span#showMarginInfos").removeClass("hideobject");})});
});</script>';
if (!empty($hidemargininfos)) print '<script>$(document).ready(function() {$(".margininfos").hide();});</script>';
}
print '<table class="nobordernopadding margintable" width="100%">';
print '<tr class="liste_titre">';
print '<td class="liste_titre">'.$langs->trans('Margins').'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans('SellingPrice').'</td>';
if ($conf->global->MARGIN_TYPE == "1")
print '<td class="liste_titre" align="right">'.$langs->trans('BuyingPrice').'</td>';
else
print '<td class="liste_titre" align="right">'.$langs->trans('CostPrice').'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans('Margin').'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td class="liste_titre" align="right">'.$langs->trans('MarginRate').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td class="liste_titre" align="right">'.$langs->trans('MarkRate').'</td>';
print '</tr>';
if (! empty($conf->product->enabled))
{
//if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) {
print '<tr class="impair">';
print '<td>'.$langs->trans('MarginOnProducts').'</td>';
print '<td align="right">'.price($marginInfo['pv_products'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['pa_products'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right">'.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'</td>';
print '</tr>';
}
if (! empty($conf->service->enabled))
{
print '<tr class="pair">';
print '<td>'.$langs->trans('MarginOnServices').'</td>';
print '<td align="right">'.price($marginInfo['pv_services'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['pa_services'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right">'.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'</td>';
print '</tr>';
}
if (! empty($conf->product->enabled) && ! empty($conf->service->enabled))
{
print '<tr class="impair">';
print '<td>'.$langs->trans('TotalMargin').'</td>';
print '<td align="right">'.price($marginInfo['pv_total'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['pa_total'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['total_margin'], null, null, null, null, $rounding).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right">'.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'</td>';
print '</tr>';
}
print '</table>';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
$formmargin=new FormMargin($this->db);
$formmargin->displayMarginInfos($this, $force_price);
}

View File

@ -404,7 +404,7 @@ class Conf
$this->css = "/theme/".$this->theme."/style.css.php";
// conf->email_from = email pour envoi par dolibarr des mails automatiques
$this->email_from = "robot@domain.com";
$this->email_from = "robot@example.com";
if (! empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
// conf->notification->email_from = email pour envoi par Dolibarr des notifications

View File

@ -41,6 +41,8 @@
/**
* Class to manage generation of HTML components
* Only common components must be here.
*
* TODO Merge all function load_cache_* and loadCache* (except load_cache_vatrates) into one generic function loadCacheTable
*/
class Form
{
@ -101,7 +103,7 @@ class Form
}
}
else
{
{
$ret.='<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
$ret.=$langs->trans($text);
$ret.='</td>';
@ -497,7 +499,7 @@ class Form
$sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
$sql.= " FROM ".MAIN_DB_PREFIX."c_country";
$sql.= " WHERE active = 1";
$sql.= " WHERE active > 0";
//$sql.= " ORDER BY code ASC";
dol_syslog(get_class($this)."::select_country", LOG_DEBUG);
@ -585,7 +587,7 @@ class Form
$sql = "SELECT rowid, code";
$sql.= " FROM ".MAIN_DB_PREFIX."c_incoterms";
$sql.= " WHERE active = 1";
$sql.= " WHERE active > 0";
$sql.= " ORDER BY code ASC";
dol_syslog(get_class($this)."::select_incoterm", LOG_DEBUG);
@ -712,22 +714,23 @@ class Form
/**
* Load into cache cache_types_fees, array of types of fees
*
* @return int Nb of lines loaded, 0 if already loaded, <0 if ko
* TODO move in DAO class
* @return int Nb of lines loaded, <0 if KO
*/
function load_cache_types_fees()
{
global $langs;
$langs->load("trips");
$num = count($this->cache_types_fees);
if ($num > 0) return 0; // Cache already loaded
if (count($this->cache_types_fees)) return 0; // Cache already load
dol_syslog(__METHOD__, LOG_DEBUG);
$langs->load("trips");
$sql = "SELECT c.code, c.label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees as c";
//$sql.= " ORDER BY c.label ASC"; // No sort here, sort must be done after translation
$sql.= " WHERE active > 0";
dol_syslog(get_class($this).'::load_cache_types_fees', LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -749,7 +752,7 @@ class Form
return $num;
}
else
{
{
dol_print_error($this->db);
return -1;
}
@ -767,7 +770,7 @@ class Form
{
global $user, $langs;
dol_syslog(get_class($this)."::select_type_fees ".$selected.", ".$htmlname, LOG_DEBUG);
dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
$this->load_cache_types_fees();
@ -803,11 +806,28 @@ class Form
* @param array $ajaxoptions Options for ajax_autocompleter
* @param int $forcecombo Force to use combo box
* @return string Return select box for thirdparty.
* @deprecated 3.8 Use select_company instead. For exemple $form->select_thirdparty(GETPOST('socid'),'socid','',0) => $form->select_company(GETPOST('socid'),'socid','',1,0,0,array(),0)
*/
function select_thirdparty($selected='', $htmlname='socid', $filter='', $limit=20, $ajaxoptions=array(), $forcecombo=0)
{
global $langs,$conf;
return $this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0,$limit);
}
/**
* Output html form to select a third party
*
* @param string $selected Preselected type
* @param string $htmlname Name of field in form
* @param string $filter optional filters criteras (example: 's.rowid <> x')
* @param int $showempty Add an empty field
* @param int $showtype Show third party type in combolist (customer, prospect or supplier)
* @param int $forcecombo Force to use combo box
* @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param int $limit Maximum number of elements
* @return string HTML string with select box for thirdparty.
*/
function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0)
{
$out='';
/* TODO Use ajax_autocompleter like for products (not finished)
@ -840,32 +860,12 @@ class Form
}
else
{*/
$out.=$this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0,$limit);
$out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit);
//}
return $out;
}
/**
* Output html form to select a third party
*
* @param string $selected Preselected type
* @param string $htmlname Name of field in form
* @param string $filter optional filters criteras (example: 's.rowid <> x')
* @param int $showempty Add an empty field
* @param int $showtype Show third party type in combolist (customer, prospect or supplier)
* @param int $forcecombo Force to use combo box
* @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param int $limit Maximum number of elements
* @return string HTML string with
* @deprecated Use select_thirdparty instead
* @see select_thirdparty()
*/
function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0)
{
return $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit);
}
/**
* Output html form to select a third party
*
@ -896,7 +896,7 @@ class Form
if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id;
if ($filter) $sql.= " AND (".$filter.")";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND s.status<>0 ";
if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND s.status <> 0";
// Add criteria
if ($filterkey && $filterkey != '')
{
@ -1123,7 +1123,7 @@ class Form
if ($showsoc > 0) $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX ."societe as s ON s.rowid=sp.fk_soc";
$sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")";
if ($socid > 0) $sql.= " AND sp.fk_soc=".$socid;
if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut<>0";
if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut <> 0";
$sql.= " ORDER BY sp.lastname ASC";
dol_syslog(get_class($this)."::select_contacts", LOG_DEBUG);
@ -2324,19 +2324,22 @@ class Form
/**
* Charge dans cache la liste des conditions de paiements possibles
*
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
* @return int Nb of lines loaded, <0 if KO
*/
function load_cache_conditions_paiements()
{
global $langs;
if (count($this->cache_conditions_paiements)) return 0; // Cache deja charge
$num = count($this->cache_conditions_paiements);
if ($num > 0) return 0; // Cache already loaded
$sql = "SELECT rowid, code, libelle";
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = "SELECT rowid, code, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_payment_term';
$sql.= " WHERE active=1";
$sql.= " WHERE active > 0";
$sql.= " ORDER BY sortorder";
dol_syslog(get_class($this).'::load_cache_conditions_paiements', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -2347,14 +2350,18 @@ class Form
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$libelle=($langs->trans("PaymentConditionShort".$obj->code)!=("PaymentConditionShort".$obj->code)?$langs->trans("PaymentConditionShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
$label=($langs->trans("PaymentConditionShort".$obj->code)!=("PaymentConditionShort".$obj->code)?$langs->trans("PaymentConditionShort".$obj->code):($obj->label!='-'?$obj->label:''));
$this->cache_conditions_paiements[$obj->rowid]['code'] =$obj->code;
$this->cache_conditions_paiements[$obj->rowid]['label']=$libelle;
$this->cache_conditions_paiements[$obj->rowid]['label']=$label;
$i++;
}
return 1;
//$this->cache_conditions_paiements=dol_sort_array($this->cache_conditions_paiements, 'label'); // We use the sortorder
return $num;
}
else {
else
{
dol_print_error($this->db);
return -1;
}
@ -2363,19 +2370,21 @@ class Form
/**
* Charge dans cache la liste des délais de livraison possibles
*
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
* @return int Nb of lines loaded, <0 if KO
*/
function load_cache_availability()
{
global $langs;
if (count($this->cache_availability)) return 0; // Cache deja charge
$num = count($this->cache_availability);
if ($num > 0) return 0; // Cache already loaded
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = "SELECT rowid, code, label";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_availability';
$sql.= " WHERE active=1";
$sql.= " ORDER BY rowid";
dol_syslog(get_class($this).'::load_cache_availability', LOG_DEBUG);
$sql.= " WHERE active > 0";
$resql = $this->db->query($sql);
if ($resql)
{
@ -2391,9 +2400,13 @@ class Form
$this->cache_availability[$obj->rowid]['label']=$label;
$i++;
}
return 1;
$this->cache_availability = dol_sort_array($this->cache_availability, 'label');
return $num;
}
else {
else
{
dol_print_error($this->db);
return -1;
}
@ -2414,6 +2427,8 @@ class Form
$this->load_cache_availability();
dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
print '<select class="flat" name="'.$htmlname.'">';
if ($addempty) print '<option value="0">&nbsp;</option>';
foreach($this->cache_availability as $id => $arrayavailability)
@ -2436,19 +2451,19 @@ class Form
/**
* Load into cache cache_demand_reason, array of input reasons
*
* @return int Nb of lines loaded, 0 if already loaded, <0 if ko
* @return int Nb of lines loaded, <0 if KO
*/
function loadCacheInputReason()
{
global $langs;
if (count($this->cache_demand_reason)) return 0; // Cache already loaded
$num = count($this->cache_demand_reason);
if ($num > 0) return 0; // Cache already loaded
$sql = "SELECT rowid, code, label";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_input_reason';
$sql.= " WHERE active=1";
$sql.= " ORDER BY rowid";
dol_syslog(get_class($this)."::loadCacheInputReason", LOG_DEBUG);
$sql.= " WHERE active > 0";
$resql = $this->db->query($sql);
if ($resql)
{
@ -2466,12 +2481,14 @@ class Form
$tmparray[$obj->rowid]['label']=$label;
$i++;
}
$this->cache_demand_reason=dol_sort_array($tmparray, 'label', 'asc');
unset($tmparray);
return 1;
return $num;
}
else {
else
{
dol_print_error($this->db);
return -1;
}
@ -2517,19 +2534,21 @@ class Form
/**
* Charge dans cache la liste des types de paiements possibles
*
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
* @return int Nb of lines loaded, <0 if KO
*/
function load_cache_types_paiements()
{
global $langs;
if (count($this->cache_types_paiements)) return 0; // Cache deja charge
$num=count($this->cache_types_paiements);
if ($num > 0) return $num; // Cache already loaded
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = "SELECT id, code, libelle, type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement";
$sql.= " WHERE active > 0";
$sql.= " ORDER BY id";
dol_syslog(get_class($this)."::load_cache_types_paiements", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -2540,16 +2559,19 @@ class Form
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$libelle=($langs->trans("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->trans("PaymentTypeShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
$label=($langs->trans("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->trans("PaymentTypeShort".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
$this->cache_types_paiements[$obj->id]['code'] =$obj->code;
$this->cache_types_paiements[$obj->id]['label']=$libelle;
$this->cache_types_paiements[$obj->id]['label']=$label;
$this->cache_types_paiements[$obj->id]['type'] =$obj->type;
$i++;
}
$this->cache_types_paiements = dol_sort_array($this->cache_types_paiements, 'label');
return $num;
}
else
{
{
dol_print_error($this->db);
return -1;
}
@ -2569,6 +2591,8 @@ class Form
{
global $langs,$user;
dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
$this->load_cache_conditions_paiements();
print '<select class="flat" name="'.$htmlname.'">';
@ -2607,7 +2631,7 @@ class Form
{
global $langs,$user;
dol_syslog(get_class($this)."::select_type_paiements ".$selected.", ".$htmlname.", ".$filtertype.", ".$format,LOG_DEBUG);
dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
$filterarray=array();
if ($filtertype == 'CRDT') $filterarray=array(0,2,3);
@ -2647,26 +2671,13 @@ class Form
/**
* Selection HT or TTC
* Selection HT or TTC
*
* @param string $selected Id pre-selectionne
* @param string $htmlname Nom de la zone select
* @return void
* @param string $selected Id pre-selectionne
* @param string $htmlname Nom de la zone select
* @return string Code of HTML select to chose tax or not
*/
function select_PriceBaseType($selected='',$htmlname='price_base_type')
{
print $this->load_PriceBaseType($selected,$htmlname);
}
/**
* Selection HT or TTC
*
* @param string $selected Id pre-selectionne
* @param string $htmlname Nom de la zone select
* @return void
*/
function load_PriceBaseType($selected='',$htmlname='price_base_type')
function selectPriceBaseType($selected='',$htmlname='price_base_type')
{
global $langs;
@ -2711,9 +2722,9 @@ class Form
$langs->load("admin");
$langs->load("deliveries");
$sql = "SELECT rowid, code, libelle";
$sql = "SELECT rowid, code, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode";
$sql.= " WHERE active = 1";
$sql.= " WHERE active > 0";
if ($filtre) $sql.=" AND ".$filtre;
$sql.= " ORDER BY libelle ASC";
@ -2734,7 +2745,7 @@ class Form
} else {
print '<option value="'.$obj->rowid.'">';
}
print $langs->trans("SendingMethod".strtoupper($obj->code));
print ($langs->trans("SendingMethod".strtoupper($obj->code)) != "SendingMethod".strtoupper($obj->code)) ? $langs->trans("SendingMethod".strtoupper($obj->code)) : $obj->label;
print '</option>';
$i++;
}
@ -2786,12 +2797,12 @@ class Form
/**
* Creates HTML last in cycle situation invoices selector
*
* @param string $selected Preselected ID
* @param int $socid Company ID
* @param string $selected Preselected ID
* @param int $socid Company ID
*
* @return string HTML select
*/
function load_situation_invoices($selected = '', $socid = '')
function selectSituationInvoices($selected = '', $socid = 0)
{
global $langs;
@ -2799,7 +2810,7 @@ class Form
$opt = '<option value ="" selected></option>';
$sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1';
$sql .= ' order by situation_cycle_ref, situation_counter desc';
$sql.= ' ORDER by situation_cycle_ref, situation_counter desc';
$resql = $this->db->query($sql);
if ($resql && $this->db->num_rows($resql) > 0) {
// Last seen cycle
@ -2825,10 +2836,13 @@ class Form
}
}
}
} else {
}
else
{
dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR);
}
if ($opt == '<option value ="" selected></option>') {
if ($opt == '<option value ="" selected></option>')
{
$opt = '<option value ="0" selected>' . $langs->trans('NoSituations') . '</option>';
}
return $opt;
@ -2850,7 +2864,9 @@ class Form
$return= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
$sql = 'select rowid, label from '.MAIN_DB_PREFIX.'c_units where active=1';
$sql = 'SELECT rowid, label from '.MAIN_DB_PREFIX.'c_units';
$sql.= ' WHERE active > 0';
$resql = $this->db->query($sql);
if($resql && $this->db->num_rows($resql) > 0)
{
@ -3521,9 +3537,9 @@ class Form
*
* @param string $page Page
* @param string $selected Id of user preselected
* @param string $htmlname Name of input html field
* @param array $exclude List of users id to exclude
* @param array $include List of users id to include
* @param string $htmlname Name of input html field. If 'none', we just output the user link.
* @param array $exclude List of users id to exclude
* @param array $include List of users id to include
* @return void
*/
function form_users($page, $selected='', $htmlname='userid', $exclude='', $include='')
@ -3543,12 +3559,10 @@ class Form
print '</tr></table></form>';
}
else
{
{
if ($selected)
{
require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php';
//$this->load_cache_contacts();
//print $this->cache_contacts[$selected];
$theuser=new User($this->db);
$theuser->fetch($selected);
print $theuser->getNomUrl(1);
@ -3659,12 +3673,12 @@ class Form
/**
* Affiche formulaire de selection des contacts
* Show forms to select a contact
*
* @param string $page Page
* @param Societe $societe Third party
* @param int $selected Id contact pre-selectionne
* @param string $htmlname Nom du formulaire select
* @param string $page Page
* @param Societe $societe Filter on third party
* @param int $selected Id contact pre-selectionne
* @param string $htmlname Name of HTML select. If 'none', we just show contact link.
* @return void
*/
function form_contacts($page, $societe, $selected='', $htmlname='contactid')
@ -3694,8 +3708,6 @@ class Form
if ($selected)
{
require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php';
//$this->load_cache_contacts();
//print $this->cache_contacts[$selected];
$contact=new Contact($this->db);
$contact->fetch($selected);
print $contact->getFullName($langs);
@ -3811,12 +3823,14 @@ class Form
global $langs;
$num = count($this->cache_vatrates);
if ($num > 0) return $num; // Cache deja charge
if ($num > 0) return $num; // Cache already loaded
$sql = "SELECT DISTINCT t.taux, t.recuperableonly";
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = "SELECT DISTINCT t.taux, t.recuperableonly";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
$sql.= " WHERE t.fk_pays = c.rowid";
$sql.= " AND t.active = 1";
$sql.= " AND t.active > 0";
$sql.= " AND c.code IN (".$country_code.")";
$sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
@ -3850,7 +3864,8 @@ class Form
}
/**
* Output an HTML select vat rate
* Output an HTML select vat rate.
* The name of this function should be selectVat. We keep bad name for compatibility purpose.
*
* @param string $htmlname Name of html select field
* @param float $selectedrate Force preselected vat rate. Use '' for no forcing.
@ -4342,16 +4357,18 @@ class Form
global $conf, $langs;
// Do we want a multiselect ?
$multiselect = 0;
if (preg_match('/^multi/',$htmlname)) $multiselect = 1;
//$jsbeautify = 0;
//if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1;
$jsbeautify = 1;
if ($value_as_key) $array=array_combine($array, $array);
$out='';
// Add code for jquery to use multiselect
if ($addjscombo && empty($conf->dol_use_jmobile) && $multiselect)
if ($addjscombo && empty($conf->dol_use_jmobile) && $jsbeautify)
{
$minLengthToAutocomplete=0;
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT')?constant('REQUIRE_JQUERY_MULTISELECT'):'select2':$conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
<script type="text/javascript">
@ -4434,7 +4451,7 @@ class Form
{
$out = '';
// Add code for jquery to use multiselect
// Add code for jquery to use select2
if ($addjscombo && empty($conf->dol_use_jmobile))
{
$tmpplugin='select2';
@ -4620,6 +4637,236 @@ class Form
}
/**
* Show linked object block.
*
* @param CommonObject $object Object we want to show links to
* @return int <0 if KO, >0 if OK
*/
function showLinkedObjectBlock($object)
{
global $conf,$langs,$hookmanager;
global $bc;
$object->fetchObjectLinked();
// Bypass the default method
$hookmanager->initHooks(array('commonobject'));
$parameters=array();
$reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
$num = count($object->linkedObjects);
foreach($object->linkedObjects as $objecttype => $objects)
{
$tplpath = $element = $subelement = $objecttype;
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
$tplpath = $element.'/'.$subelement;
}
// To work with non standard path
if ($objecttype == 'facture') {
$tplpath = 'compta/'.$element;
if (empty($conf->facture->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'propal') {
$tplpath = 'comm/'.$element;
if (empty($conf->propal->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'askpricesupplier') {
$tplpath = 'comm/'.$element;
if (empty($conf->askpricesupplier->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'shipping' || $objecttype == 'shipment') {
$tplpath = 'expedition';
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'delivery') {
$tplpath = 'livraison';
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'invoice_supplier') {
$tplpath = 'fourn/facture';
}
else if ($objecttype == 'order_supplier') {
$tplpath = 'fourn/commande';
}
global $linkedObjectBlock;
$linkedObjectBlock = $objects;
// Output template part (modules that overwrite templates must declare this into descriptor)
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/linkedobjectblock.tpl.php');
if ($res) break;
}
}
return $num;
}
}
/**
* Show block with links to link to other objects.
*
* @param CommonObject $object Object we want to show links to
* @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order')
* @return int <0 if KO, >0 if OK
*/
function showLinkToObjectBlock($object, $restrictlinksto=array())
{
global $conf, $langs, $hookmanager;
global $bc;
$linktoelem='';
if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
if (((! is_array($restrictlinksto)) || in_array('order',$restrictlinksto))
&& ! empty($conf->commande->enabled))
{
$linktoelem.=($linktoelem?' &nbsp; ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
print '
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#linktoorder").click(function() {
jQuery("#orderlist").toggle();
jQuery("#linktoorder").toggle();
});
});
</script>
';
print '<div id="orderlist"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>';
$sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_client, c.total_ht";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "commande as c";
$sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $object->thirdparty->id . '';
$resqlorderlist = $this->db->query($sql);
if ($resqlorderlist)
{
$num = $this->db->num_rows($resqlorderlist);
$i = 0;
print '<br><form action="" method="POST" name="LinkedOrder">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td class="nowrap"></td>';
print '<td align="center">' . $langs->trans("Ref") . '</td>';
print '<td align="left">' . $langs->trans("RefCustomer") . '</td>';
print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>';
print '<td align="left">' . $langs->trans("Company") . '</td>';
print '</tr>';
while ($i < $num)
{
$objp = $this->db->fetch_object($resqlorderlist);
$var = ! $var;
print '<tr ' . $bc [$var] . '>';
print '<td aling="left">';
print '<input type="radio" name="linkedOrder" value=' . $objp->rowid . '>';
print '<td align="center">' . $objp->ref . '</td>';
print '<td>' . $objp->ref_client . '</td>';
print '<td>' . price($objp->total_ht) . '</td>';
print '<td>' . $objp->name . '</td>';
print '</td>';
print '</tr>';
$i ++;
}
print '</table>';
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('ToLink') . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
print '</form>';
$this->db->free($resqlorderlist);
} else {
dol_print_error($this->db);
}
print '</div>';
}
if (((! is_array($restrictlinksto)) || in_array('supplier_order',$restrictlinksto))
&& ! empty($conf->fournisseur->enabled))
{
$linktoelem.=($linktoelem?' &nbsp; ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
print '
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#linktoorder").click(function() {
jQuery("#orderlist").toggle();
jQuery("#linktoorder").toggle();
});
});
</script>
';
print '<div id="orderlist"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>';
$sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_supplier, c.total_ht";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "commande_fournisseur as c";
$sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $object->thirdparty->id;
$resqlorderlist = $this->db->query($sql);
if ($resqlorderlist)
{
$num = $this->db->num_rows($resqlorderlist);
$i = 0;
print '<br><form action="" method="POST" name="LinkedOrder">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td class="nowrap"></td>';
print '<td align="center">' . $langs->trans("Ref") . '</td>';
print '<td align="left">' . $langs->trans("RefSupplier") . '</td>';
print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>';
print '<td align="left">' . $langs->trans("Company") . '</td>';
print '</tr>';
while ($i < $num) {
$objp = $this->db->fetch_object($resqlorderlist);
if ($objp->socid == $societe->id) {
$var = ! $var;
print '<tr ' . $bc [$var] . '>';
print '<td aling="left">';
print '<input type="radio" name="linkedOrder" value=' . $objp->rowid . '>';
print '<td align="center">' . $objp->ref . '</td>';
print '<td>' . $objp->ref_supplier . '</td>';
print '<td>' . price($objp->total_ht) . '</td>';
print '<td>' . $objp->name . '</td>';
print '</td>';
print '</tr>';
}
$i ++;
}
print '</table>';
print '<br><div class="center"><input type="submit" class="button" value="' . $langs->trans('ToLink') . '"> &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
print '</form>';
$this->db->free($resqlorderlist);
} else {
dol_print_error($this->db);
}
print '</div>';
}
return $linktoelem;
}
/**
* Return an html string with a select combo box to choose yes or no
*
@ -4719,7 +4966,7 @@ class Form
* @param string $paramid Name of parameter to use to name the id into the URL link
* @param string $morehtml More html content to output just before the nav bar
* @param int $shownav Show Condition (navigation is shown if value is 1)
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
* @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
* @param string $morehtmlref Code html supplementaire a afficher apres ref
* @param string $moreparam More param to add in nav link url.
@ -4745,7 +4992,7 @@ class Form
//print "xx".$previous_ref."x".$next_ref;
//if ($previous_ref || $next_ref || $morehtml) {
//$ret.='<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
$ret.='<div style="vertical-align: middle"><div class="inline-block floatleft refid">';
$ret.='<div style="vertical-align: middle"><div class="inline-block floatleft refid'.(($shownav && ($previous_ref || $next_ref))?' refidpadding':'').'">';
//}
$ret.=dol_htmlentities($object->$fieldref);
@ -4863,7 +5110,6 @@ class Form
$cache='0';
if ($file && file_exists($dir."/".$file))
{
// TODO Link to large image
$ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
$ret.='<img alt="Photo" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="'.$cssclass.'" '.($width?' width="'.$width.'"':'').($height?' height="'.$height.'"':'').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
$ret.='</a>';
@ -4876,19 +5122,22 @@ class Form
}
else
{
$nophoto='/theme/common/nophoto.jpg';
$nophoto='/public/theme/common/nophoto.jpg';
if (in_array($modulepart,array('userphoto','contact'))) // For module thar are "physical" users
{
$nophoto='/theme/common/user_anonymous.png';
if ($object->gender == 'man') $nophoto='/theme/common/user_man.png';
if ($object->gender == 'woman') $nophoto='/theme/common/user_woman.png';
$nophoto='/public/theme/common/user_anonymous.png';
if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png';
if ($object->gender == 'woman') $nophoto='/public/theme/common/user_woman.png';
}
if (! empty($conf->gravatar->enabled) && $email)
{
/**
* @see https://gravatar.com/site/implement/images/php/
*/
global $dolibarr_main_url_root;
$ret.='<!-- Put link to gravatar -->';
$ret.='<img class="photo'.$modulepart.'" alt="Photo found on Gravatar" title="Photo Gravatar.com - email '.$email.'" border="0"'.($width?' width="'.$width.'"':'').($height?' height="'.$height.'"':'').' src="http://www.gravatar.com/avatar/'.dol_hash($email,3).'?s='.$width.'&d='.urlencode(dol_buildpath($nophoto,2)).'">'; // gravatar need md5 hash
$ret.='<img class="photo'.$modulepart.'" alt="Gravatar avatar" title="'.$email.' Gravatar avatar" border="0"'.($width?' width="'.$width.'"':'').($height?' height="'.$height.'"':'').' src="https://www.gravatar.com/avatar/'.dol_hash(strtolower(trim($email)),3).'?s='.$width.'&d='.urlencode(dol_buildpath($nophoto,2)).'">'; // gravatar need md5 hash
}
else
{

View File

@ -0,0 +1,273 @@
<?php
/* Copyright (c) 2015 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/class/html.formmargin.class.php
* \ingroup core
* \brief Fichier de la classe des fonctions predefinie de composants html autre
*/
/**
* Classe permettant la generation de composants html autre
* Only common components are here.
*/
class FormMargin
{
var $db;
var $error;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
return 1;
}
/**
* get array with margin information from lines of object
*
* @param CommonObject $object Object we want to get margin information for
* @param boolean $force_price True of not
* @return array Array with info
*/
function getMarginInfosArray($object, $force_price=false)
{
global $conf, $db;
// Default returned array
$marginInfos = array(
'pa_products' => 0,
'pv_products' => 0,
'margin_on_products' => 0,
'margin_rate_products' => '',
'mark_rate_products' => '',
'pa_services' => 0,
'pv_services' => 0,
'margin_on_services' => 0,
'margin_rate_services' => '',
'mark_rate_services' => '',
'pa_total' => 0,
'pv_total' => 0,
'total_margin' => 0,
'total_margin_rate' => '',
'total_mark_rate' => ''
);
foreach($object->lines as $line)
{
if (empty($line->pa_ht) && isset($line->fk_fournprice) && !$force_price)
{
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$product = new ProductFournisseur($db);
if ($product->fetch_product_fournisseur_price($line->fk_fournprice))
$line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100);
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0)
$line->pa_ht += $product->fourn_unitcharges;
}
// si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente
if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) {
$line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100));
}
// calcul des marges
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
$pa = $line->qty * $line->pa_ht;
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit
$marginInfos['pa_products'] += $pa;
$marginInfos['pv_products'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_products'] += $pv - $pa;
}
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service
$marginInfos['pa_services'] += $pa;
$marginInfos['pv_services'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_services'] += $pv - $pa;
}
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
}
}
else {
$type=$line->product_type?$line->product_type:$line->fk_product_type;
if ($type == 0) { // product
$pa = $line->qty * $line->pa_ht;
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pa_products'] += $pa;
$marginInfos['pv_products'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_products'] += $pv - $pa;
}
elseif ($type == 1) { // service
$pa = $line->qty * $line->pa_ht;
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pa_services'] += $pa;
$marginInfos['pv_services'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_services'] += $pv - $pa;
}
}
}
if ($marginInfos['pa_products'] > 0)
$marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products'];
if ($marginInfos['pv_products'] > 0)
$marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products'];
if ($marginInfos['pa_services'] > 0)
$marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services'];
if ($marginInfos['pv_services'] > 0)
$marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services'];
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($marginInfos['pv_total'] < 0)
$marginInfos['total_margin'] = -1 * (abs($marginInfos['pv_total']) - $marginInfos['pa_total']);
else
$marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total'];
if ($marginInfos['pa_total'] > 0)
$marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total'];
if ($marginInfos['pv_total'] > 0)
$marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total'];
return $marginInfos;
}
/**
* Show the array with all margin infos
*
* @param CommonObject $object Object we want to get margin information for
* @param boolean $force_price Force price
* @return void
*/
function displayMarginInfos($object, $force_price=false)
{
global $langs, $conf, $user;
if (! empty($user->societe_id)) return;
if (! $user->rights->margins->liretous) return;
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
$marginInfo = $this->getMarginInfosArray($object, $force_price);
if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better
{
print $langs->trans('ShowMarginInfos').' : ';
$hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW'];
print '<span id="showMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'':'hideobject').'">'.img_picto($langs->trans("Disabled"),'switch_off').'</span>';
print '<span id="hideMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'hideobject':'').'">'.img_picto($langs->trans("Enabled"),'switch_on').'</span>';
print '<script>$(document).ready(function() {
$("span#showMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 0); $(".margininfos").show(); $("span#showMarginInfos").addClass("hideobject"); $("span#hideMarginInfos").removeClass("hideobject");})});
$("span#hideMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 1); $(".margininfos").hide(); $("span#hideMarginInfos").addClass("hideobject"); $("span#showMarginInfos").removeClass("hideobject");})});
});</script>';
if (!empty($hidemargininfos)) print '<script>$(document).ready(function() {$(".margininfos").hide();});</script>';
}
print '<table class="nobordernopadding margintable" width="100%">';
print '<tr class="liste_titre">';
print '<td class="liste_titre">'.$langs->trans('Margins').'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans('SellingPrice').'</td>';
if ($conf->global->MARGIN_TYPE == "1")
print '<td class="liste_titre" align="right">'.$langs->trans('BuyingPrice').'</td>';
else
print '<td class="liste_titre" align="right">'.$langs->trans('CostPrice').'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans('Margin').'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td class="liste_titre" align="right">'.$langs->trans('MarginRate').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td class="liste_titre" align="right">'.$langs->trans('MarkRate').'</td>';
print '</tr>';
if (! empty($conf->product->enabled))
{
//if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) {
print '<tr class="impair">';
print '<td>'.$langs->trans('MarginOnProducts').'</td>';
print '<td align="right">'.price($marginInfo['pv_products'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['pa_products'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right">'.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'</td>';
print '</tr>';
}
if (! empty($conf->service->enabled))
{
print '<tr class="pair">';
print '<td>'.$langs->trans('MarginOnServices').'</td>';
print '<td align="right">'.price($marginInfo['pv_services'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['pa_services'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right">'.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'</td>';
print '</tr>';
}
if (! empty($conf->product->enabled) && ! empty($conf->service->enabled))
{
print '<tr class="impair">';
print '<td>'.$langs->trans('TotalMargin').'</td>';
print '<td align="right">'.price($marginInfo['pv_total'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['pa_total'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['total_margin'], null, null, null, null, $rounding).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right">'.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'</td>';
print '</tr>';
}
print '</table>';
}
}

View File

@ -55,7 +55,7 @@ abstract class DoliDB implements Database
public $transaction_opened;
/** @var string Last successful query */
public $lastquery;
/** @ar string Last failed query */
/** @var string Last failed query */
public $lastqueryerror;
/** @var string Last error message */
public $lasterror;

View File

@ -1084,18 +1084,18 @@ function form_constantes($tableau,$strictw3c=0)
if ($const == 'ADHERENT_MAILMAN_URL')
{
print '. '.$langs->trans("Example").': <a href="#" id="exampleclick1">'.img_down().'</a><br>';
//print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&subscribees=%EMAIL%&send_welcome_msg_to_this_batch=1';
//print 'http://lists.exampe.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&subscribees=%EMAIL%&send_welcome_msg_to_this_batch=1';
print '<div id="example1" class="hidden">';
print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&amp;adminpw=%MAILMAN_ADMINPW%&amp;subscribe_or_invite=0&amp;send_welcome_msg_to_this_batch=0&amp;notification_to_list_owner=0';
print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&amp;adminpw=%MAILMAN_ADMINPW%&amp;subscribe_or_invite=0&amp;send_welcome_msg_to_this_batch=0&amp;notification_to_list_owner=0';
print '</div>';
}
if ($const == 'ADHERENT_MAILMAN_UNSUB_URL')
{
print '. '.$langs->trans("Example").': <a href="#" id="exampleclick2">'.img_down().'</a><br>';
print '<div id="example2" class="hidden">';
print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/remove?unsubscribees_upload=%EMAIL%&amp;adminpw=%MAILMAN_ADMINPW%&amp;send_unsub_ack_to_this_batch=0&amp;send_unsub_notifications_to_list_owner=0';
print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?unsubscribees_upload=%EMAIL%&amp;adminpw=%MAILMAN_ADMINPW%&amp;send_unsub_ack_to_this_batch=0&amp;send_unsub_notifications_to_list_owner=0';
print '</div>';
//print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
//print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
}
if ($const == 'ADHERENT_MAILMAN_LISTS')
{
@ -1106,7 +1106,7 @@ function form_constantes($tableau,$strictw3c=0)
print 'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
if ($conf->categorie->enabled) print 'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
print '</div>';
//print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
//print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
}
print "</td>\n";

View File

@ -103,7 +103,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
print $langs->trans("ThirdParty").' &nbsp; ';
print '</td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px;">';
print $form->select_thirdparty($socid, 'socid');
print $form->select_company($socid, 'socid');
print '</td></tr>';
}

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2007-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -340,7 +340,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $
if ($forcefocus) $msg.= '.select2(\'focus\')';
$msg.= ';'."\n";
if (count($event))
if (count($events))
{
$msg.= '
jQuery("#'.$htmlname.'").change(function () {

View File

@ -364,7 +364,7 @@ function getState($id,$withcode='',$dbtouse=0)
}
else
{
return $langs->trans("NotDefined");
return $langs->transnoentitiesnoconv("NotDefined");
}
}
else dol_print_error($dbtouse,'');

View File

@ -78,6 +78,15 @@ function donation_prepare_head($object)
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation');
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
$head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
$head[$h][2] = 'documents';
$h++;
$head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';

View File

@ -1645,7 +1645,7 @@ function dol_print_address($address, $htmlid, $mode, $id)
/**
* Return true if email syntax is ok
*
* @param string $address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* @param string $address email (Ex: "toto@examle.com", "John Do <johndo@example.com>")
* @param int $acceptsupervisorkey If 1, the special string '__SUPERVISOREMAIL__' is also accepted as valid
* @return boolean true if email syntax is OK, false if KO or empty string
*/
@ -2637,11 +2637,12 @@ function dol_print_error_email($prefixcode)
* @param string $td Options of attribute td ("" by defaut, example: 'align="center"')
* @param string $sortfield Current field used to sort
* @param string $sortorder Current sort order
* @param string $prefix Prefix for css
* @return void
*/
function print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $td="", $sortfield="", $sortorder="")
function print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $td="", $sortfield="", $sortorder="", $prefix="")
{
print getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $td, $sortfield, $sortorder);
print getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $td, $sortfield, $sortorder, $prefix);
}
/**
@ -2656,9 +2657,10 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar
* @param string $moreattrib Add more attributes on th ("" by defaut)
* @param string $sortfield Current field used to sort
* @param string $sortorder Current sort order
* @param string $prefix Prefix for css
* @return string
*/
function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="")
function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="")
{
global $conf;
//print "$name, $file, $field, $begin, $options, $moreattrib, $sortfield, $sortorder<br>\n";
@ -2672,7 +2674,7 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
// If field is used as sort criteria we use a specific class
// Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom")
if ($field && ($sortfield == $field || $sortfield == preg_replace("/^[^\.]+\./","",$field))) $out.= '<'.$tag.' class="liste_titre_sel" '. $moreattrib.'>';
else $out.= '<'.$tag.' class="liste_titre" '. $moreattrib.'>';
else $out.= '<'.$tag.' class="'.$prefix.'liste_titre" '. $moreattrib.'>';
if (! empty($conf->dol_optimize_smallscreen) && empty($thead) && $field) // If this is a sort field
{
@ -4127,8 +4129,8 @@ function dol_textishtml($msg,$option=0)
elseif (preg_match('/<(br|div|font|li|span|strong|table)>/i',$msg)) return true;
elseif (preg_match('/<(br|div|font|li|span|strong|table)\s+[^<>\/]*>/i',$msg)) return true;
elseif (preg_match('/<(br|div|font|li|span|strong|table)\s+[^<>\/]*\/>/i',$msg)) return true;
elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i',$msg)) return true; // must accept <img src="http://mydomain.com/aaa.png" />
elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i',$msg)) return true; // must accept <a href="http://mydomain.com/aaa.png" />
elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i',$msg)) return true; // must accept <img src="http://example.com/aaa.png" />
elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i',$msg)) return true; // must accept <a href="http://example.com/aaa.png" />
elseif (preg_match('/<h[0-9]>/i',$msg)) return true;
elseif (preg_match('/&[A-Z0-9]{1,6};/i',$msg)) return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
elseif (preg_match('/&#[0-9]{2,3};/i',$msg)) return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
@ -4867,7 +4869,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
* Print common footer :
* conf->global->MAIN_HTML_FOOTER
* conf->global->MAIN_GOOGLE_AN_ID
* DOL_TUNING
* conf->global->MAIN_SHOW_TUNING_INFO or $_SERVER["MAIN_SHOW_TUNING_INFO"]
* conf->logbuffer
*
* @param string $zone 'private' (for private pages) or 'public' (for public pages)
@ -4904,7 +4906,7 @@ function printCommonFooter($zone='private')
}
// End of tuning
if (! empty($_SERVER['DOL_TUNING']) || ! empty($conf->global->MAIN_SHOW_TUNING_INFO))
if (! empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || ! empty($conf->global->MAIN_SHOW_TUNING_INFO))
{
print "\n".'<script type="text/javascript">'."\n";
print 'window.console && console.log("';

View File

@ -394,9 +394,9 @@ function dol_print_object_info($object)
/**
* Return an email formatted to include a tracking id
* For example myemail@mydomain.com becom myemail+trackingid@mydomain.com
* For example myemail@example.com becom myemail+trackingid@example.com
*
* @param string $email Email address (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* @param string $email Email address (Ex: "toto@example.com", "John Do <johndo@example.com>")
* @param string $trackingid Tracking id (Ex: thi123 for thirdparty with id 123)
* @return boolean True if domain email is OK, False if KO
*/
@ -409,7 +409,7 @@ function dolAddEmailTrackId($email, $trackingid)
/**
* Return true if email has a domain name that can't be resolved
*
* @param string $mail Email address (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* @param string $mail Email address (Ex: "toto@example.com", "John Do <johndo@example.com>")
* @return boolean True if domain email is OK, False if KO
*/
function isValidMailDomain($mail)

View File

@ -28,7 +28,7 @@
* @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: ('Accept: application/xrds+xml', ....)
* @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...)
*/
function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addheaders=array())
@ -74,15 +74,17 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
else if ($postorget == 'PUT')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
if ( ! is_array($param) )
parse_str($param, $array_param);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as PUT fields
}
else if ($postorget == 'HEAD')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request is 'HEAD'
curl_setopt($ch, CURLOPT_NOBODY, true);
}
else if ($postorget == 'DELETE')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); // POST
}
else
{
curl_setopt($ch, CURLOPT_POST, 0); // GET

View File

@ -69,7 +69,7 @@ class mailing_example extends MailingTargets
// ...
// $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n', 'other'=>'other_n');
// Example: $target[0]=array('email'=>'myemail@mydomain.com', 'name'=>'Doe', 'firstname'=>'John', 'other'=>'Other information');
// Example: $target[0]=array('email'=>'myemail@example.com', 'name'=>'Doe', 'firstname'=>'John', 'other'=>'Other information');
// ----- Your code end here -----

View File

@ -57,7 +57,7 @@ class modDon extends DolibarrModules
$this->picto='bill';
// Data directories to create when module is enabled
$this->dirs = array("/dons/temp");
$this->dirs = array("/don/temp");
// Dependancies
$this->depends = array();

View File

@ -211,7 +211,10 @@ class modFacture extends DolibarrModules
case 'sellist':
$tmp='';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
if ($tmpparam['options'] && is_array($tmpparam['options'])) {
$tmpkeys=array_keys($tmpparam['options']);
$tmp=array_shift($tmpkeys);
}
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
break;
}
@ -270,7 +273,10 @@ class modFacture extends DolibarrModules
case 'sellist':
$tmp='';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
if ($tmpparam['options'] && is_array($tmpparam['options'])) {
$tmpkeys=array_keys($tmpparam['options']);
$tmp=array_shift($tmpkeys);
}
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
break;
}

View File

@ -66,8 +66,8 @@ class modMailmanSpip extends DolibarrModules
// Constants
$this->const = array();
$this->const[1] = array("ADHERENT_MAILMAN_UNSUB_URL","chaine","http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&user=%EMAIL%","Url de désinscription aux listes mailman");
$this->const[2] = array("ADHERENT_MAILMAN_URL","chaine","http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&send_welcome_msg_to_this_batch=1&subscribees=%EMAIL%","Url pour les inscriptions mailman");
$this->const[1] = array("ADHERENT_MAILMAN_UNSUB_URL","chaine","http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&user=%EMAIL%","Url de désinscription aux listes mailman");
$this->const[2] = array("ADHERENT_MAILMAN_URL","chaine","http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&send_welcome_msg_to_this_batch=1&subscribees=%EMAIL%","Url pour les inscriptions mailman");
$this->const[3] = array("ADHERENT_MAILMAN_LISTS","chaine","","Mailing-list to subscribe new members to");
// Boxes

View File

@ -320,14 +320,14 @@ class printing_printgcp extends PrintingDriver
}
/**
* Curl request
* Make a curl request
*
* @param string $url url to hit
* @param array $postfields array of post fields
* @param string[] $headers array of http headers
* @return string response from curl
* @param string $url url to hit
* @param array $postfields array of post fields
* @param string[] $headers array of http headers
* @return string response from curl
*/
private function makeCurl($url,$postfields=array(),$headers=array())
private function makeCurl($url, $postfields=array(), $headers=array())
{
// Curl Init
$curl = curl_init($url);

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2010-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
@ -20,7 +20,7 @@
* The following vars must be defined
* $type2label
* $form
* $conf, $lang,
* $conf, $lang,
*/
?>
@ -113,6 +113,12 @@
<tr><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required" <?php echo (GETPOST('required')?' checked':''); ?>></td></tr>
<!-- Always editable -->
<tr><td><?php echo $langs->trans("AlwaysEditable"); ?></td><td class="valeur"><input id="alwayseditable" type="checkbox" name="alwayseditable" <?php echo (GETPOST('alwayseditable')?' checked':''); ?>></td></tr>
<?php if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { ?>
<!-- By default visible into list -->
<tr><td><?php echo $langs->trans("ByDefaultInList"); ?>
<?php echo img_info($langs->trans("FeatureNotYetSupported")); ?>
</td><td class="valeur"><input id="list" type="checkbox" name="list" <?php echo (GETPOST('list')?' checked':''); ?>></td></tr>
<?php } ?>
</table>
<div align="center"><br><input type="submit" name="button" class="button" value="<?php echo $langs->trans("Save"); ?>"> &nbsp;

View File

@ -56,6 +56,8 @@ $required=$extrafields->attribute_required[$attrname];
$pos=$extrafields->attribute_pos[$attrname];
$alwayseditable=$extrafields->attribute_alwayseditable[$attrname];
$param=$extrafields->attribute_param[$attrname];
$perms=$extrafields->attribute_perms[$attrname];
$list=$extrafields->attribute_list[$attrname];
if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param))
{
@ -113,7 +115,12 @@ if(($type == 'select') || ($type == 'sellist') || ($type == 'checkbox') || ($typ
<tr><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required" <?php echo ($required?' checked':''); ?>></td></tr>
<!-- Always editable -->
<tr><td><?php echo $langs->trans("AlwaysEditable"); ?></td><td class="valeur"><input id="alwayseditable" type="checkbox" name="alwayseditable" <?php echo ($alwayseditable?' checked':''); ?>></td></tr>
<!-- By default visible into list -->
<?php if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { ?>
<tr><td><?php echo $langs->trans("ByDefaultInList"); ?>
<?php echo img_info($langs->trans("FeatureNotYetSupported")); ?>
</td><td class="valeur"><input id="list" type="checkbox" name="list" <?php echo ($list?' checked':''); ?>></td></tr>
<?php } ?>
</table>
<div align="center"><br><input type="submit" name="button" class="button" value="<?php echo $langs->trans("Save"); ?>"> &nbsp;

View File

@ -49,7 +49,7 @@ if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
//var_dump($modulepart);
if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','askpricesupplier','ficheinter','contract','project','project_task','expensereport')))
{
$savingdocmask=$object->ref.'___file__';
$savingdocmask=$object->ref.'-__file__';
}
/*if (in_array($modulepart,array('member')))
{

136
htdocs/don/document.php Normal file
View File

@ -0,0 +1,136 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/don/document.php
* \ingroup donation
* \brief Page of linked files onto donation
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
$langs->load("other");
$langs->load("donations");
$langs->load("companies");
$id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'don', $id, '');
// Get parameters
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
$object = new Don($db);
$object->fetch($id, $ref);
$upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref);
$modulepart='don';
/*
* Actions
*/
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
* View
*/
$form = new Form($db);
llxHeader("","",$langs->trans("Donations"));
if ($object->id)
{
$object->fetch_thirdparty();
$head=donation_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans("Donation"), 0, 'generic');
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/don/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
print '</td></tr>';
// Societe
//print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
$modulepart = 'don';
$permission = $user->rights->don->lire;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{
print $langs->trans("ErrorUnknown");
}
llxFooter();
$db->close();

View File

@ -48,7 +48,7 @@ if ($id)
$head = donation_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Donation"), 0, 'bill');
dol_fiche_head($head, 'info', $langs->trans("Donation"), 0, 'generic');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);

View File

@ -1502,12 +1502,12 @@ else if ($id || $ref)
$somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
/*
* Linked object block
*/
$somethingshown=$object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
if ($genallowed && ! $somethingshown) $somethingshown=1;
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
print '</td><td valign="top" width="50%">';
@ -1530,7 +1530,7 @@ else if ($id || $ref)
{
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref,'/'));
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file=$fileparams['fullname'];
// Define output language
@ -1557,7 +1557,7 @@ else if ($id || $ref)
dol_print_error($db,$result);
exit;
}
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref,'/'));
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file=$fileparams['fullname'];
}

View File

@ -46,6 +46,7 @@ $date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth'), GETPOST('date_debu
$date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth'), GETPOST('date_finday'), GETPOST('date_finyear'));
$date = dol_mktime(0, 0, 0, GETPOST('datemonth'), GETPOST('dateday'), GETPOST('dateyear'));
$fk_projet=GETPOST('fk_projet');
$ref=GETPOST("ref",'alpha');
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
@ -92,7 +93,7 @@ if ($cancel) $action='';
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer)
{
$object = new ExpenseReport($db);
$result=$object->delete($id);
$result=$object->delete($id, $user);
if ($result >= 0)
{
header("Location: index.php");
@ -214,59 +215,67 @@ if ($action == "confirm_save" && GETPOST("confirm") == "yes" && $id > 0 && $user
$expediteur->fetch($object->fk_user_author);
$emailFrom = $expediteur->email;
// SUBJECT
$subject = $langs->trans("ExpenseReportWaitingForApproval");
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$message = $langs->trans("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link);
// Rebuild pdf
/*
$object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$id,'',"",$langs);
if($resultPDF):
// ATTACHMENT
$filename=array(); $filedir=array(); $mimetype=array();
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref).".pdf");
array_push($mimetype,"application/pdf");
*/
// PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
if ($mailfile)
if ($emailTo && $emailFrom)
{
// SEND
$result=$mailfile->sendfile();
if ($result)
// SUBJECT
$subject = $langs->trans("ExpenseReportWaitingForApproval");
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$message = $langs->trans("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link);
// Rebuild pdf
/*
$object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$id,'',"",$langs);
if($resultPDF):
// ATTACHMENT
$filename=array(); $filedir=array(); $mimetype=array();
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref).".pdf");
array_push($mimetype,"application/pdf");
*/
// PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
if ($mailfile)
{
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
setEventMessage($mesg);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
$langs->load("other");
if ($mailfile->error)
// SEND
$result=$mailfile->sendfile();
if ($result)
{
$mesg='';
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
setEventMessage($mesg,'errors');
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
setEventMessage($mesg);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
setEventMessage('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', 'warnings');
$langs->load("other");
if ($mailfile->error)
{
$mesg='';
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
setEventMessage($mesg,'errors');
}
else
{
setEventMessage('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', 'warnings');
}
}
}
else
{
setEventMessages($mailfile->error,$mailfile->errors,'errors');
$action='';
}
}
else
{
setEventMessages($mailfile->error,$mailfile->errors,'errors');
setEventMessage($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), 'warnings');
$action='';
}
}
@ -304,66 +313,73 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id
if ($result > 0)
{
// Send mail
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
{
// Send mail
// TO
$destinataire = new User($db);
$destinataire->fetch($object->fk_user_validator);
$emailTo = $destinataire->email;
// FROM
$expediteur = new User($db);
$expediteur->fetch($object->fk_user_author);
$emailFrom = $expediteur->email;
if ($emailTo)
{
// FROM
$expediteur = new User($db);
$expediteur->fetch($object->fk_user_author);
$emailFrom = $expediteur->email;
// SUBJECT
$subject = "' ERP - Note de frais à re-approuver";
// SUBJECT
$subject = "' ERP - Note de frais à re-approuver";
// CONTENT
$dateRefusEx = explode(" ",$object->date_refuse);
// CONTENT
$dateRefusEx = explode(" ",$object->date_refuse);
$message = "Bonjour {$destinataire->firstname},\n\n";
$message.= "Le {$dateRefusEx[0]} à {$dateRefusEx[1]} vous avez refusé d'approuver la note de frais \"{$object->ref}\". Vous aviez émis le motif suivant : {$object->detail_refuse}\n\n";
$message.= "L'auteur vient de modifier la note de frais, veuillez trouver la nouvelle version en pièce jointe.\n";
$message.= "- Déclarant : {$expediteur->firstname} {$expediteur->lastname}\n";
$message.= "- Période : du {$object->date_debut} au {$object->date_fin}\n";
$message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n";
$message.= "Bien cordialement,\n' SI";
$message = "Bonjour {$destinataire->firstname},\n\n";
$message.= "Le {$dateRefusEx[0]} à {$dateRefusEx[1]} vous avez refusé d'approuver la note de frais \"{$object->ref}\". Vous aviez émis le motif suivant : {$object->detail_refuse}\n\n";
$message.= "L'auteur vient de modifier la note de frais, veuillez trouver la nouvelle version en pièce jointe.\n";
$message.= "- Déclarant : {$expediteur->firstname} {$expediteur->lastname}\n";
$message.= "- Période : du {$object->date_debut} au {$object->date_fin}\n";
$message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n";
$message.= "Bien cordialement,\n' SI";
// Génération du pdf avant attachement
$object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
// Génération du pdf avant attachement
$object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
if($resultPDF):
// ATTACHMENT
$filename=array(); $filedir=array(); $mimetype=array();
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf");
array_push($mimetype,"application/pdf");
if($resultPDF)
{
// ATTACHMENT
$filename=array(); $filedir=array(); $mimetype=array();
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf");
array_push($mimetype,"application/pdf");
// PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
// PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
if(!$mailfile->error):
// SEND
$result=$mailfile->sendfile();
if ($result):
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
endif;
else:
$mesg="Impossible d'envoyer l'email.";
endif;
// END - Send mail
else:
dol_print_error($db,$resultPDF);
exit;
endif;
if (! $mailfile->error)
{
// SEND
$result=$mailfile->sendfile();
if ($result)
{
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
$mesg=$mailfile->error;
}
// END - Send mail
}
else
{
dol_print_error($db,$resultPDF);
exit;
}
}
}
}
}
else
@ -1168,10 +1184,10 @@ if ($action == 'create')
}
else
{
if($id > 0)
if($id > 0 || $ref)
{
$object = new ExpenseReport($db);
$result = $object->fetch($id);
$result = $object->fetch($id, $ref);
if ($result > 0)
{
@ -1218,7 +1234,7 @@ else
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print '</td></tr>';
print '<tr>';
@ -1376,7 +1392,7 @@ else
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'ref', 'ref', '');
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print '</td></tr>';
print '<tr>';
@ -1450,6 +1466,7 @@ else
print '</tr>';
}
// User to inform
if($object->fk_statut<3) // informed
{
print '<tr>';
@ -1460,6 +1477,7 @@ else
$userfee=new User($db);
$userfee->fetch($object->fk_user_validator);
print $userfee->getNomUrl(1);
if (empty($userfee->email) || ! isValidEmail($userfee->email)) print img_warning($langs->trans("EmailNotValid"));
}
print '</td></tr>';
}
@ -1530,7 +1548,7 @@ else
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid';
$sql.= ' WHERE fde.fk_expensereport = '.$id;
$sql.= ' WHERE fde.fk_expensereport = '.$object->id;
$resql = $db->query($sql);
if ($resql)
@ -1692,8 +1710,8 @@ else
print_fiche_titre($langs->trans("AddLine"),'','');
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="addline">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="fk_expensereport" value="'.$id.'" />';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="fk_expensereport" value="'.$object->id.'" />';
print '<input type="hidden" name="action" value="addline" />';
print '<table class="noborder" width="100%">';
@ -1789,7 +1807,7 @@ print '<div class="tabsAction">';
if ($action != 'create' && $action != 'edit')
{
$object = new ExpenseReport($db);
$object->fetch($id);
$object->fetch($id, $ref);
/* Si l'état est "Brouillon"
@ -1802,18 +1820,18 @@ if ($action != 'create' && $action != 'edit')
if ($object->fk_user_author == $user->id)
{
// Modify
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans('Modify').'</a>';
// Validate
if (count($object->lines) > 0 || count($object->lignes) > 0)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save&id='.$id.'">'.$langs->trans('ValidateAndSubmit').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save&id='.$object->id.'">'.$langs->trans('ValidateAndSubmit').'</a>';
}
if ($user->rights->expensereport->supprimer)
{
// Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
}
}
}
@ -1828,17 +1846,17 @@ if ($action != 'create' && $action != 'edit')
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
// Modify
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans('Modify').'</a>';
// Brouillonner (le statut refusée est identique à brouillon)
//print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('BROUILLONNER').'</a>';
// Enregistrer depuis le statut "Refusée"
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save_from_refuse&id='.$id.'">'.$langs->trans('ValidateAndSubmit').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save_from_refuse&id='.$object->id.'">'.$langs->trans('ValidateAndSubmit').'</a>';
if ($user->rights->expensereport->supprimer)
{
// Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
}
}
}
@ -1848,7 +1866,7 @@ if ($action != 'create' && $action != 'edit')
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
// Brouillonner
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('SetToDraft').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$object->id.'">'.$langs->trans('SetToDraft').'</a>';
}
}
@ -1862,7 +1880,7 @@ if ($action != 'create' && $action != 'edit')
if ($object->fk_user_author == $user->id)
{
// Brouillonner
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('SetToDraft').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$object->id.'">'.$langs->trans('SetToDraft').'</a>';
}
}
@ -1871,21 +1889,21 @@ if ($action != 'create' && $action != 'edit')
//if($object->fk_user_validator==$user->id)
//{
// Validate
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$id.'">'.$langs->trans('Approve').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$object->id.'">'.$langs->trans('Approve').'</a>';
// Deny
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$id.'">'.$langs->trans('Deny').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$object->id.'">'.$langs->trans('Deny').'</a>';
//}
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
// Cancel
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$object->id.'">'.$langs->trans('Cancel').'</a>';
}
if($user->rights->expensereport->supprimer)
{
// Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
}
}
@ -1896,18 +1914,18 @@ if ($action != 'create' && $action != 'edit')
if ($user->rights->expensereport->to_paid && $object->fk_statut == 5)
{
// Pay
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$id.'">'.$langs->trans('TO_PAID').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$object->id.'">'.$langs->trans('TO_PAID').'</a>';
// Cancel
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$object->id.'">'.$langs->trans('Cancel').'</a>';
}
if($user->rights->expensereport->supprimer)
{
// Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
}
}
@ -1919,11 +1937,11 @@ if ($action != 'create' && $action != 'edit')
if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6)
{
// Cancel
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$object->id.'">'.$langs->trans('Cancel').'</a>';
if($user->rights->expensereport->supprimer)
{
// Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
}
}
@ -1937,11 +1955,11 @@ if ($action != 'create' && $action != 'edit')
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
// Brouillonner
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('ReOpen').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$object->id.'">'.$langs->trans('ReOpen').'</a>';
}
// Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
}
}

View File

@ -348,7 +348,8 @@ class ExpenseReport extends CommonObject
$this->code_statut = $obj->code_statut;
$this->code_paiement = $obj->code_paiement;
$this->lignes = array();
$this->lignes = array(); // deprecated
$this->lines = array();
$result=$this->fetch_lines();
@ -772,9 +773,10 @@ class ExpenseReport extends CommonObject
* delete
*
* @param int $rowid Id to delete (optional)
* @param User $fuser User that delete
* @return int <0 if KO, >0 if OK
*/
function delete($rowid=0)
function delete($rowid=0, User $fuser=null)
{
global $user,$langs,$conf;
@ -810,10 +812,10 @@ class ExpenseReport extends CommonObject
/**
* Set to status validate
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function setValidate($user)
function setValidate($fuser)
{
global $conf,$langs;
@ -836,13 +838,13 @@ class ExpenseReport extends CommonObject
{
$prefix="ER";
if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX;
$this->ref = strtoupper($user->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d');
$this->ref = strtoupper($fuser->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d');
}
if ($this->fk_statut != 2)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$user->id.",";
$sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$fuser->id.",";
$sql.= " ref_number_int = ".$ref_number_int;
$sql.= ' WHERE rowid = '.$this->id;
@ -867,10 +869,10 @@ class ExpenseReport extends CommonObject
/**
* set_save_from_refuse
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function set_save_from_refuse($user)
function set_save_from_refuse($fuser)
{
global $conf,$langs;
@ -912,10 +914,10 @@ class ExpenseReport extends CommonObject
/**
* Set status to approved
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function setApproved($user)
function setApproved($fuser)
{
$now=dol_now();
@ -924,7 +926,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 5)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_statut = 5, fk_user_approve = ".$user->id.",";
$sql.= " SET ref = '".$this->ref."', fk_statut = 5, fk_user_approve = ".$fuser->id.",";
$sql.= " date_approve='".$this->date_approve."'";
$sql.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql))
@ -946,10 +948,10 @@ class ExpenseReport extends CommonObject
/**
* setDeny
*
* @param User $user User
* @param User $fuser User
* @param Details $details Details
*/
function setDeny($user,$details)
function setDeny($fuser,$details)
{
$now = dol_now();
@ -957,7 +959,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 99)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_statut = 99, fk_user_refuse = ".$user->id.",";
$sql.= " SET ref = '".$this->ref."', fk_statut = 99, fk_user_refuse = ".$fuser->id.",";
$sql.= " date_refuse='".$this->db->idate($now)."',";
$sql.= " detail_refuse='".$this->db->escape($details)."'";
$sql.= " fk_user_approve=NULL,";
@ -965,7 +967,7 @@ class ExpenseReport extends CommonObject
if ($this->db->query($sql))
{
$this->fk_statut = 99;
$this->fk_user_refuse = $user->id;
$this->fk_user_refuse = $fuser->id;
$this->detail_refuse = $details;
$this->date_refuse = $now;
return 1;
@ -985,10 +987,10 @@ class ExpenseReport extends CommonObject
/**
* setPaid
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function setPaid($user)
function setPaid($fuser)
{
$now= dol_now();
@ -996,7 +998,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 6)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_statut = 6, fk_user_paid = ".$user->id.",";
$sql.= " SET fk_statut = 6, fk_user_paid = ".$fuser->id.",";
$sql.= " date_paiement='".$this->db->idate($this->date_paiement)."'";
$sql.= ' WHERE rowid = '.$this->id;
@ -1020,10 +1022,10 @@ class ExpenseReport extends CommonObject
/**
* set_unpaid
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function set_unpaid($user)
function set_unpaid($fuser)
{
if ($this->fk_c_deplacement_statuts != 5)
{
@ -1049,17 +1051,17 @@ class ExpenseReport extends CommonObject
/**
* set_cancel
*
* @param User $user User
* @param User $fuser User
* @param string $detail Detail
* @return int <0 if KO, >0 if OK
*/
function set_cancel($user,$detail)
function set_cancel($fuser,$detail)
{
$this->date_cancel = $this->db->idate(gmmktime());
if ($this->fk_statut != 4)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_statut = 4, fk_user_cancel = ".$user->id;
$sql.= " SET fk_statut = 4, fk_user_cancel = ".$fuser->id;
$sql.= ", date_cancel='".$this->date_cancel."'";
$sql.= " ,detail_cancel='".$this->db->escape($detail)."'";
$sql.= ' WHERE rowid = '.$this->id;
@ -1271,10 +1273,10 @@ class ExpenseReport extends CommonObject
* deleteline
*
* @param int $rowid Row id
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function deleteline($rowid, $user='')
function deleteline($rowid, $fuser='')
{
$this->db->begin();
@ -1299,16 +1301,16 @@ class ExpenseReport extends CommonObject
/**
* periode_existe
*
* @param User $user User
* @param User $fuser User
* @param Date $date_debut Start date
* @param Date $date_fin End date
* @return int <0 if KO, >0 if OK
*/
function periode_existe($user, $date_debut, $date_fin)
function periode_existe($fuser, $date_debut, $date_fin)
{
$sql = "SELECT rowid, date_debut, date_fin";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE fk_user_author = '{$user->id}'";
$sql.= " WHERE fk_user_author = '{$fuser->id}'";
dol_syslog(get_class($this)."::periode_existe sql=".$sql);
$result = $this->db->query($sql);
@ -1617,12 +1619,12 @@ class ExpenseReportLine
/**
* update
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function update($user)
function update($fuser)
{
global $user,$langs,$conf;
global $fuser,$langs,$conf;
$error=0;

View File

@ -107,7 +107,7 @@ print_fiche_titre($langs->trans("ExpensesArea"));
print '<div class="fichecenter"><div class="fichethirdleft">';
print '<table class="noborder" width="100%">';
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("Statistics").'</td>';
print "</tr>\n";

View File

@ -180,6 +180,7 @@ if ($resql)
print_barre_liste($langs->trans("ListTripsAndExpenses"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","",$param,'',$sortfield,$sortorder);
@ -190,7 +191,7 @@ if ($resql)
print_liste_field_titre($langs->trans("TotalVAT"),$_SERVER["PHP_SELF"],"d.total_tva","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("TotalTTC"),$_SERVER["PHP_SELF"],"d.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Statut"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
print '<td class="liste_titre">&nbsp;</td>';
print_liste_field_titre('');
print "</tr>\n";
// Filters

View File

@ -5,6 +5,7 @@
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 201 Charlie Benke <charlies@patas-monkey.com>
*
* 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
@ -248,7 +249,14 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
$prod = new Product($db);
$prod->id=$lines[$i]->fk_product;
$prod->getMultiLangs();
// We show if duration is present on service (so we get it)
$prod->fetch($lines[$i]->fk_product);
if ($prod->duration_value && $prod->duration_unit == 'h' && $conf->global->FICHINTER_USE_SERVICE_DURATION)
{
$durationproduct=$prod->duration_value * 3600 * $lines[$i]->qty;
}
else
$durationproduct=3600;
$outputlangs = $langs;
$newlang='';
if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
@ -277,11 +285,11 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
$date_intervention=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']);
if ($product_type == 1)
{ //service
$duration = 3600;
$duration = $durationproduct;
}
else
{ //product
$duration = 0;
$duration = 0;
}
$predef = '';
@ -1019,7 +1027,7 @@ if ($action == 'create')
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
dol_fiche_head('');
print '<table class="border" width="100%">';
print '<input type="hidden" name="socid" value='.$soc->id.'>';
@ -1125,7 +1133,7 @@ if ($action == 'create')
}
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">';
print '</div>';
@ -1135,7 +1143,7 @@ if ($action == 'create')
else
{
dol_fiche_head('');
print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<table class="border" width="100%">';
print '<tr><td class="fieldrequired">'.$langs->trans("ThirdParty").'</td><td>';
@ -1144,7 +1152,7 @@ if ($action == 'create')
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="hidden" name="action" value="create">';
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">';
@ -1701,7 +1709,6 @@ else if ($id > 0 || ! empty($ref))
if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft">';
//print '<table width="100%"><tr><td width="50%" valign="top">';
/*
* Built documents
@ -1719,12 +1726,14 @@ else if ($id > 0 || ! empty($ref))
//print "<br>\n";
$somethingshown=$formfile->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
/*
* Linked object block
*/
$somethingshown=$object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
//print '</td><td valign="top" width="50%">';
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element
@ -1733,7 +1742,6 @@ else if ($id > 0 || ! empty($ref))
$somethingshown=$formactions->showactions($object,'fichinter',$socid);
print '</div></div></div>';
//print "</td></tr></table>\n";
}
@ -1747,7 +1755,7 @@ else if ($id > 0 || ! empty($ref))
{
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref,'/'));
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file=$fileparams['fullname'];
// Define output language
@ -1774,7 +1782,7 @@ else if ($id > 0 || ! empty($ref))
dol_print_error($db,$result);
exit;
}
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref,'/'));
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file=$fileparams['fullname'];
}

View File

@ -2265,7 +2265,7 @@ elseif (! empty($object->id))
{
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref,'/'));
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file=$fileparams['fullname'];
// Define output language
@ -2292,7 +2292,7 @@ elseif (! empty($object->id))
dol_print_error($db,$result);
exit;
}
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref,'/'));
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+');
$file=$fileparams['fullname'];
}
@ -2763,10 +2763,13 @@ elseif (! empty($object->id))
print $formfile->showdocuments('commande_fournisseur',$comfournref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,0,0,'','','',$object->thirdparty->default_lang);
$somethingshown=$formfile->numoffiles;
/*
* Linked object block
*/
$somethingshown=$object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@ -2412,80 +2412,14 @@ else
print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,40,0,'','','',$societe->default_lang);
$somethingshown=$formfile->numoffiles;
/*
* Linked object block
*/
$somethingshown=$object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
$linktoelem='';
if (empty($somethingshown) && ! empty($conf->fournisseur->enabled))
{
$linktoelem.=($linktoelem?' &nbsp; ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
print '
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#linktoorder").click(function() {
jQuery("#orderlist").toggle();
jQuery("#linktoorder").toggle();
});
});
</script>
';
print '<div id="orderlist" style="display:none">';
$sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_supplier, c.total_ht";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "commande_fournisseur as c";
$sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $societe->id;
$resqlorderlist = $db->query($sql);
if ($resqlorderlist) {
$num = $db->num_rows($resqlorderlist);
$i = 0;
print '<br><form action="" method="POST" name="LinkedOrder">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td class="nowrap"></td>';
print '<td align="center">' . $langs->trans("Ref") . '</td>';
print '<td align="left">' . $langs->trans("RefSupplier") . '</td>';
print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>';
print '<td align="left">' . $langs->trans("Company") . '</td>';
print '</tr>';
while ($i < $num) {
$objp = $db->fetch_object($resqlorderlist);
if ($objp->socid == $societe->id) {
$var = ! $var;
print '<tr ' . $bc [$var] . '>';
print '<td aling="left">';
print '<input type="radio" name="linkedOrder" value=' . $objp->rowid . '>';
print '<td align="center">' . $objp->ref . '</td>';
print '<td>' . $objp->ref_supplier . '</td>';
print '<td>' . price($objp->total_ht) . '</td>';
print '<td>' . $objp->name . '</td>';
print '</td>';
print '</tr>';
}
$i ++;
}
print '</table>';
print '<br><div class="center"><input type="submit" class="button" value="' . $langs->trans('ToLink') . '"> &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
print '</form>';
$db->free($resqlorderlist);
} else {
dol_print_error($db);
}
print '</div>';
}
// Show link to elements
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object,array('supplier_order'));
if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
//print '</td><td valign="top" width="50%">';
//print '<br>';
@ -2509,7 +2443,7 @@ else
{
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref, preg_quote($ref,'/'));
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref, preg_quote($ref,'/').'([^\-])+');
$file=$fileparams['fullname'];
// Define output language
@ -2536,7 +2470,7 @@ else
dol_print_error($db,$result);
exit;
}
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref, preg_quote($ref,'/'));
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref, preg_quote($ref,'/').'([^\-])+');
$file=$fileparams['fullname'];
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
@ -268,7 +268,7 @@ if (empty($user->societe_id))
else $board=$boardloaded[$classe];
$var=!$var;
if ($langfile[$key]) $langs->load($langfile[$key]);
if (!empty($langfile[$key])) $langs->load($langfile[$key]);
$text=$langs->trans($titres[$key]);
print '<a href="'.$links[$key].'" class="nobold nounderline">';
print '<div class="boxstats">';

View File

@ -208,10 +208,14 @@ UPDATE llx_product SET fk_barcode_type = NULL WHERE fk_barcode_type NOT IN (SELE
ALTER TABLE llx_product_price ADD INDEX idx_product_price_fk_user_author (fk_user_author);
UPDATE llx_product_price set fk_user_author = null where fk_user_author = 0;
UPDATE llx_product_price set fk_user_author = null where fk_user_author not in (select rowid from llx_user);
-- drop foreign key for avoid a mysql crash
ALTER TABLE llx_product_price DROP FOREIGN KEY fk_product_price_user_author;
ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
-- fk_product
ALTER TABLE llx_product_price ADD INDEX idx_product_price_fk_product (fk_product);
DELETE from llx_product_price where fk_product NOT IN (SELECT rowid from llx_product);
-- drop foreign key for avoid a mysql crash
ALTER TABLE llx_product_price DROP FOREIGN KEY fk_product_price_product;
ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_commande_fournisseur MODIFY COLUMN date_livraison datetime;

View File

@ -647,12 +647,12 @@ ALTER TABLE llx_actioncomm ADD COLUMN email_sender varchar(256);
ALTER TABLE llx_actioncomm ADD COLUMN email_to varchar(256);
ALTER TABLE llx_actioncomm ADD COLUMN errors_to varchar(256);
-- Recuring events
-- Recurring events
ALTER TABLE llx_actioncomm ADD COLUMN recurid varchar(128);
ALTER TABLE llx_actioncomm ADD COLUMN recurrule varchar(128);
ALTER TABLE llx_actioncomm ADD COLUMN recurdateend datetime;
ALTER TABLE llx_stcomm ADD COLUMN picto varchar(128);
ALTER TABLE llx_c_stcomm ADD COLUMN picto varchar(128);
-- New trigger for Supplier invoice unvalidation
INSERT INTO llx_c_action_trigger (code, label, description, elementtype, rang) VALUES ('BILL_SUPPLIER_UNVALIDATE','Supplier invoice unvalidated','Executed when a supplier invoice status is set back to draft','invoice_supplier',15);

View File

@ -294,3 +294,4 @@ LastUpdated=Last updated
CorrectlyUpdated=Correctly updated
PropalMergePdfProductActualFile=Files use to add into PDF Azur are/is
PropalMergePdfProductChooseFile=Select PDF files
IncludingProductWithTag=Including product with tag

View File

@ -788,10 +788,14 @@ else
$shipment = new Expedition($db);
$shipment->fetch($object->origin_id);
$somethingshown=$shipment->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($shipment);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($shipment);
//if ($linktoelem) print '<br>'.$linktoelem;
}
if ($genallowed && ! $somethingshown) $somethingshown=1;
print '</td><td valign="top" width="50%">';

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2014 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2008 Matteli
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
@ -34,10 +34,10 @@
//@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
// For optional tuning. Enabled if environment variable DOL_TUNING is defined.
// For optional tuning. Enabled if environment variable MAIN_SHOW_TUNING_INFO is defined.
// A call first. Is the equivalent function dol_microtime_float not yet loaded.
$micro_start_time=0;
if (! empty($_SERVER['DOL_TUNING']))
if (! empty($_SERVER['MAIN_SHOW_TUNING_INFO']))
{
list($usec, $sec) = explode(" ", microtime());
$micro_start_time=((float) $usec + (float) $sec);
@ -110,7 +110,7 @@ function test_sql_and_script_inject($val, $type)
}
/**
* Security: Return true if OK, false otherwise.
* Return true if security check on parameters are OK, false otherwise.
*
* @param string $var Variable name
* @param string $type 1=GET, 0=POST, 2=PHP_SELF
@ -1803,7 +1803,7 @@ function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch,$htmlinput
{
global $conf,$langs;
if (!$htmlinputid) {
if (empty($htmlinputid)) {
$htmlinputid = $htmlinputname;
}

View File

@ -292,7 +292,7 @@ else
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("PriceBaseTypeToChange").'</td>'."\n";
print '<td width="60" align="right">'."\n";
print $form->load_PriceBaseType($price_base_type);
print $form->selectPriceBaseType($price_base_type);
print '</td>'."\n";
print '</tr>'."\n";
*/

View File

@ -116,7 +116,7 @@ class ActionsCardProduct
// Price
$this->tpl['price'] = $this->price;
$this->tpl['price_min'] = $this->price_min;
$this->tpl['price_base_type'] = $form->load_PriceBaseType($this->price_base_type, "price_base_type");
$this->tpl['price_base_type'] = $form->selectPriceBaseType($this->price_base_type, "price_base_type");
// VAT
$this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,'');

View File

@ -115,7 +115,7 @@ class ActionsCardService
// Price
$this->tpl['price'] = $this->price;
$this->tpl['price_min'] = $this->price_min;
$this->tpl['price_base_type'] = $form->load_PriceBaseType($this->price_base_type, "price_base_type");
$this->tpl['price_base_type'] = $form->selectPriceBaseType($this->price_base_type, "price_base_type");
// VAT
$this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,'');

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Auguria SARL <info@auguria.org>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
@ -1004,7 +1004,7 @@ else
// PRIX
print '<tr><td>'.$langs->trans("SellingPrice").'</td>';
print '<td><input name="price" size="10" value="'.$object->price.'">';
print $form->select_PriceBaseType($object->price_base_type, "price_base_type");
print $form->selectPriceBaseType($object->price_base_type, "price_base_type");
print '</td></tr>';
// MIN PRICE
@ -1385,7 +1385,7 @@ else
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans("BarcodeType");
print '<td>';
if (($action != 'editbarcodetype') && $user->rights->barcode->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
if (($action != 'editbarcodetype') && ! empty($user->rights->barcode->creer)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($action == 'editbarcodetype')
@ -1406,7 +1406,7 @@ else
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans("BarcodeValue");
print '<td>';
if (($action != 'editbarcode') && $user->rights->barcode->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
if (($action != 'editbarcode') && ! empty($user->rights->barcode->creer)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($action == 'editbarcode')
@ -1461,7 +1461,7 @@ else
print '</td></tr>';
// Batch number management (to batch)
if ($conf->productbatch->enabled) {
if (! empty($conf->productbatch->enabled)) {
print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="2">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
print ajax_object_onoff($object, 'status_batch', 'tobatch', 'ProductStatusOnBatch', 'ProductStatusNotOnBatch');
@ -1552,7 +1552,7 @@ else
}
// Unit
if($conf->global->PRODUCT_USE_UNITS)
if (! empty($conf->global->PRODUCT_USE_UNITS))
{
$unit = $object->getLabelOfUnit();

View File

@ -450,7 +450,7 @@ if ($id || $ref)
print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';
print '<td><input class="flat" name="price" size="8" value="'.(GETPOST('price')?price(GETPOST('price')):(isset($product->fourn_price)?price($product->fourn_price):'')).'">';
print '&nbsp;';
print $form->select_PriceBaseType((GETPOST('price_base_type')?GETPOST('price_base_type'):$product->price_base_type), "price_base_type");
print $form->selectPriceBaseType((GETPOST('price_base_type')?GETPOST('price_base_type'):$product->price_base_type), "price_base_type");
print '</td></tr>';
// Discount qty min

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -43,9 +43,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$langs->load("products");
$langs->load("bills");
$mesg=''; $error=0; $errors=array(); $_error=0;
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$eid = GETPOST('eid', 'int');
// Security check
@ -54,303 +57,302 @@ $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if ($user->societe_id) $socid = $user->societe_id;
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
$object = new Product($db);
if ($id > 0 || ! empty($ref))
{
$object = new Product($db);
$object->fetch($id, $ref);
}
// Clean param
if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5;
$error=0;
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('productpricecard','globalcard'));
/*
* Actions
*/
if (GETPOST("cancel")) $action='';
if ($cancel) $action='';
if ($action == 'update_price' && ! GETPOST("cancel") && ($user->rights->produit->creer || $user->rights->service->creer))
$parameters=array('id'=>$id, 'ref'=>$ref);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
$result = $object->fetch($id);
$error=0;
$maxpricesupplier = $object->min_recommended_price();
$object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression
// MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES))
if ($action == 'update_price' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer))
{
$newprice = '';
$newprice_min = '';
$newpricebase = '';
$newvat = '';
$maxpricesupplier = $object->min_recommended_price();
$object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
// MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
if (isset($_POST ["price_" . $i]))
$newprice = '';
$newprice_min = '';
$newpricebase = '';
$newvat = '';
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
$level = $i;
$newprice = price2num($_POST ["price_" . $i], 'MU');
$newprice_min = price2num($_POST ["price_min_" . $i], 'MU');
$newpricebase = $_POST ["multiprices_base_type_" . $i];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx_" . $i]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx_" . $i]);
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
break; // We found submited price
if (isset($_POST ["price_" . $i]))
{
$level = $i;
$newprice = price2num($_POST ["price_" . $i], 'MU');
$newprice_min = price2num($_POST ["price_min_" . $i], 'MU');
$newpricebase = $_POST ["multiprices_base_type_" . $i];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx_" . $i]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx_" . $i]);
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
break; // We found submited price
}
}
} else {
$level = 0;
$newprice = price2num($_POST ["price"], 'MU');
$newprice_min = price2num($_POST ["price_min"], 'MU');
$newpricebase = $_POST ["price_base_type"];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx"]);
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
}
} else {
$level = 0;
$newprice = price2num($_POST ["price"], 'MU');
$newprice_min = price2num($_POST ["price_min"], 'MU');
$newpricebase = $_POST ["price_base_type"];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx"]);
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
}
if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier)
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='edit_price';
}
if ($newprice < $newprice_min && ! empty($object->fk_price_expression)) {
$newprice = $newprice_min; //Set price same as min, the user will not see the
}
if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0)
{
if ($object->fk_price_expression != 0) {
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);
$price_result = $priceparser->parseProduct($object);
if ($price_result < 0) { //Expression is not valid
$error++;
$action='edit_price';
setEventMessage($priceparser->translatedError(), 'errors');
}
}
if (empty($error) && ! empty($conf->dynamicprices->enabled))
if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier)
{
$ret=$object->setPriceExpression($object->fk_price_expression);
if ($ret < 0)
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='edit_price';
}
if ($newprice < $newprice_min && ! empty($object->fk_price_expression)) {
$newprice = $newprice_min; //Set price same as min, the user will not see the
}
if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0)
{
if ($object->fk_price_expression != 0) {
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);
$price_result = $priceparser->parseProduct($object);
if ($price_result < 0) { //Expression is not valid
$error++;
$action='edit_price';
setEventMessage($priceparser->translatedError(), 'errors');
}
}
if (empty($error) && ! empty($conf->dynamicprices->enabled))
{
$error++;
$action='edit_price';
setEventMessage($object->error, 'errors');
$ret=$object->setPriceExpression($object->fk_price_expression);
if ($ret < 0)
{
$error++;
$action='edit_price';
setEventMessage($object->error, 'errors');
}
}
if (empty($error))
{
$action = '';
setEventMessage($langs->trans("RecordSaved"));
}
} else {
$action = 'edit_price';
setEventMessage($object->error, 'errors');
}
}
if ($action == 'delete' && $user->rights->produit->supprimer)
{
$result = $object->log_price_delete($user, $_GET ["lineid"]);
if ($result < 0) {
setEventMessage($object->error, 'errors');
}
}
/**
* ***************************************************
* Price by quantity
* ***************************************************
*/
if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price, specified as by quantity
$level = GETPOST('level');
$object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1);
}
if ($action == 'edit_price_by_qty') { // Edition d'un prix par quantité
$rowid = GETPOST('rowid');
}
if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par quantité
// Récupération des variables
$rowid = GETPOST('rowid');
$priceid = GETPOST('priceid');
$newprice = price2num(GETPOST("price"), 'MU');
// $newminprice=price2num(GETPOST("price_min"),'MU'); // TODO : Add min price management
$quantity = GETPOST('quantity');
$remise_percent = price2num(GETPOST('remise_percent'));
$remise = 0; // TODO : allow discount by amount when available on documents
if (empty($quantity)) {
$error ++;
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Qty")), 'errors');
}
if (empty($newprice)) {
$error ++;
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Price")), 'errors');
}
if (! $error) {
// Calcul du prix HT et du prix unitaire
if ($object->price_base_type == 'TTC') {
$price = price2num($newprice) / (1 + ($object->tva_tx / 100));
}
$price = price2num($newprice, 'MU');
$unitPrice = price2num($price / $quantity, 'MU');
// Ajout / mise à jour
if ($rowid > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "product_price_by_qty SET";
$sql .= " price='" . $price . "',";
$sql .= " unitprice=" . $unitPrice . ",";
$sql .= " quantity=" . $quantity . ",";
$sql .= " remise_percent=" . $remise_percent . ",";
$sql .= " remise=" . $remise;
$sql .= " WHERE rowid = " . GETPOST('rowid');
$result = $db->query($sql);
} else {
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
$sql .= $priceid . ',' . $price . ',' . $unitPrice . ',' . $quantity . ',' . $remise_percent . ',' . $remise . ')';
$result = $db->query($sql);
}
}
if (empty($error))
}
if ($action == 'delete_price_by_qty') {
$rowid = GETPOST('rowid');
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
$sql .= " WHERE rowid = " . GETPOST('rowid');
$result = $db->query($sql);
}
if ($action == 'delete_all_price_by_qty') {
$priceid = GETPOST('priceid');
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
$sql .= " WHERE fk_product_price = " . $priceid;
$result = $db->query($sql);
}
/**
* ***************************************************
* Price by customer
* ****************************************************
*/
if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
$maxpricesupplier = $object->min_recommended_price();
$update_child_soc = GETPOST('updatechildprice');
// add price by customer
$prodcustprice->fk_soc = GETPOST('socid', 'int');
$prodcustprice->fk_product = $object->id;
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $prodcustprice->price_min<$maxpricesupplier)
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='add_customer_price';
}
if (! $error)
{
$result = $prodcustprice->create($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
}
$action = '';
setEventMessage($langs->trans("RecordSaved"));
}
} else {
$action = 'edit_price';
setEventMessage($object->error, 'errors');
}
}
if ($action == 'delete' && $user->rights->produit->supprimer)
{
$result = $object->log_price_delete($user, $_GET ["lineid"]);
if ($result < 0) {
setEventMessage($object->error, 'errors');
}
}
/**
* ***************************************************
* Price by quantity
* ***************************************************
*/
$error = 0;
if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price, specified as by quantity
$result = $object->fetch($id);
$level = GETPOST('level');
$object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1);
}
if ($action == 'edit_price_by_qty') { // Edition d'un prix par quantité
$rowid = GETPOST('rowid');
}
if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par quantité
$result = $object->fetch($id);
// Récupération des variables
$rowid = GETPOST('rowid');
$priceid = GETPOST('priceid');
$newprice = price2num(GETPOST("price"), 'MU');
// $newminprice=price2num(GETPOST("price_min"),'MU'); // TODO : Add min price management
$quantity = GETPOST('quantity');
$remise_percent = price2num(GETPOST('remise_percent'));
$remise = 0; // TODO : allow discount by amount when available on documents
if (empty($quantity)) {
$error ++;
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Qty")), 'errors');
}
if (empty($newprice)) {
$error ++;
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Price")), 'errors');
}
if (! $error) {
// Calcul du prix HT et du prix unitaire
if ($object->price_base_type == 'TTC') {
$price = price2num($newprice) / (1 + ($object->tva_tx / 100));
}
$price = price2num($newprice, 'MU');
$unitPrice = price2num($price / $quantity, 'MU');
// Ajout / mise à jour
if ($rowid > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "product_price_by_qty SET";
$sql .= " price='" . $price . "',";
$sql .= " unitprice=" . $unitPrice . ",";
$sql .= " quantity=" . $quantity . ",";
$sql .= " remise_percent=" . $remise_percent . ",";
$sql .= " remise=" . $remise;
$sql .= " WHERE rowid = " . GETPOST('rowid');
$result = $db->query($sql);
} else {
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
$sql .= $priceid . ',' . $price . ',' . $unitPrice . ',' . $quantity . ',' . $remise_percent . ',' . $remise . ')';
$result = $db->query($sql);
}
}
}
if ($action == 'delete_price_by_qty') {
$rowid = GETPOST('rowid');
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
$sql .= " WHERE rowid = " . GETPOST('rowid');
$result = $db->query($sql);
}
if ($action == 'delete_all_price_by_qty') {
$priceid = GETPOST('priceid');
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
$sql .= " WHERE fk_product_price = " . $priceid;
$result = $db->query($sql);
}
/**
* ***************************************************
* Price by customer
* ****************************************************
*/
if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$error=0;
$maxpricesupplier = $object->min_recommended_price();
$update_child_soc = GETPOST('updatechildprice');
$result = $object->fetch($id);
// add price by customer
$prodcustprice->fk_soc = GETPOST('socid', 'int');
$prodcustprice->fk_product = $object->id;
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $prodcustprice->price_min<$maxpricesupplier)
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='add_customer_price';
}
if (! $error)
{
$result = $prodcustprice->create($user, 0, $update_child_soc);
if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) {
// Delete price by customer
$prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
setEventMessage($prodcustprice->error, 'mesgs');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
setEventMessage($langs->trans('Delete'), 'errors');
}
$action = '';
}
}
if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) {
// Delete price by customer
$prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user);
if ($action == 'update_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
if ($result < 0) {
setEventMessage($prodcustprice->error, 'mesgs');
} else {
setEventMessage($langs->trans('Delete'), 'errors');
}
$action = '';
}
$maxpricesupplier = $object->min_recommended_price();
if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$update_child_soc = GETPOST('updatechildprice');
$result = $object->fetch($id);
$prodcustprice->fetch(GETPOST('lineid', 'int'));
$error=0;
$maxpricesupplier = $object->min_recommended_price();
// update price by customer
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$update_child_soc = GETPOST('updatechildprice');
$prodcustprice->fetch(GETPOST('lineid', 'int'));
// update price by customer
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
if ($prodcustprice->price_min<$maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='update_customer_price';
}
if ( ! $error)
{
$result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
if ($prodcustprice->price_min<$maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='update_customer_price';
}
$action = '';
if ( ! $error)
{
$result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
}
$action = '';
}
}
}
/*
* View
*/
$form = new Form($db);
if (! empty($id) || ! empty($ref))
$result = $object->fetch($id, $ref);
llxHeader("", "", $langs->trans("CardProduct" . $object->type));
$head = product_prepare_head($object);
@ -687,7 +689,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print $langs->trans('PriceBase');
print '</td>';
print '<td>';
print $form->select_PriceBaseType($object->price_base_type, "price_base_type");
print $form->selectPriceBaseType($object->price_base_type, "price_base_type");
print '</td>';
print '</tr>';
@ -793,7 +795,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
} else {
print '<input name="price_' . $i . '" size="10" value="' . price($object->multiprices ["$i"]) . '">';
}
print $form->select_PriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i);
print $form->selectPriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i);
print '</td></tr>';
// Min price
@ -1010,7 +1012,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print $langs->trans('PriceBase');
print '</td>';
print '<td>';
print $form->select_PriceBaseType($object->price_base_type, "price_base_type");
print $form->selectPriceBaseType($object->price_base_type, "price_base_type");
print '</td>';
print '</tr>';
@ -1094,7 +1096,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print $langs->trans('PriceBase');
print '</td>';
print '<td>';
print $form->select_PriceBaseType($prodcustprice->price_base_type, "price_base_type");
print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type");
print '</td>';
print '</tr>';

View File

@ -258,7 +258,7 @@ if ($resql)
print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Visibility"),$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],'p.fk_statut',"",$param,'align="right"',$sortfield,$sortorder);
print '<td class="liste_titre">&nbsp;</td>';
print_liste_field_titre('');
print "</tr>\n";
print '<tr class="liste_titre">';

View File

@ -41,7 +41,7 @@ $conf->dol_use_jmobile=GETPOST('dol_use_jmobile','int');
// Security check
global $dolibarr_main_demo;
if (empty($dolibarr_main_demo)) accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page',1,1,1);
if (empty($dolibarr_main_demo)) accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page',0,0,1);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$res=$hookmanager->initHooks(array('demo'));

View File

@ -1,54 +0,0 @@
<?php
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2008 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/public/donations/therm.php
* \ingroup donation
* \brief Screen with thermometer
*/
define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
// Security check
if (empty($conf->don->enabled)) accessforbidden('',1,1,1);
/*
* View (output an image)
*/
$dontherm = new Don($db);
$intentValue = $dontherm->sum_donations(1);
$pendingValue = $dontherm->sum_donations(2);
$actualValue = $dontherm->sum_donations(3);
$db->close();
/*
* Graph thermometer
*/
print moneyMeter($actualValue, $pendingValue, $intentValue);

View File

@ -65,7 +65,11 @@ $extrafields = new ExtraFields($db);
* View
*/
llxHeaderVierge($langs->trans("MemberCard"));
$morehead='';
if (! empty($conf->global->MEMBER_PUBLIC_CSS)) $morehead='<link rel="stylesheet" type="text/css" href="'.$conf->global->MEMBER_PUBLIC_CSS.'">';
else $morehead='<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php'.'">';
llxHeaderVierge($langs->trans("MemberCard"), $morehead);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label('adherent');
@ -75,7 +79,7 @@ if ($id > 0)
if ($res < 0) { dol_print_error($db,$object->error); exit; }
$res=$object->fetch_optionals($object->id,$extralabels);
print_titre($langs->trans("MemberCard"));
print_fiche_titre($langs->trans("MemberCard"), '', '');
if (empty($object->public))
{
@ -83,7 +87,7 @@ if ($id > 0)
}
else
{
print '<table class="border" cellspacing="0" width="100%" cellpadding="3">';
print '<table class="public_border" cellspacing="0" width="100%" cellpadding="3">';
print '<tr><td width="15%">'.$langs->trans("Type").'</td><td class="valeur">'.$object->type."</td></tr>\n";
print '<tr><td>'.$langs->trans("Person").'</td><td class="valeur">'.$object->morphy.'</td></tr>';
@ -138,7 +142,7 @@ function llxHeaderVierge($title, $head = "")
print "<title>".$title."</title>\n";
if ($head) print $head."\n";
print "</head>\n";
print "<body>\n";
print '<body class="public_body">'."\n";
}
/**

View File

@ -62,7 +62,7 @@ function llxHeaderVierge($title, $head = "")
print "<title>".$title."</title>\n";
if ($head) print $head."\n";
print "</head>\n";
print "<body>\n";
print '<body class="public_body">'."\n";
}
/**
@ -98,7 +98,13 @@ if (! $sortfield) { $sortfield="lastname"; }
* View
*/
llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"));
$form = new Form($db);
$morehead='';
if (! empty($conf->global->MEMBER_PUBLIC_CSS)) $morehead='<link rel="stylesheet" type="text/css" href="'.$conf->global->MEMBER_PUBLIC_CSS.'">';
else $morehead='<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php'.'">';
llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead);
$sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent";
@ -120,17 +126,16 @@ if ($result)
$param="&statut=$statut&sortorder=$sortorder&sortfield=$sortfield";
print_barre_liste($langs->trans("ListOfValidatedPublicMembers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, '');
print '<table class="noborder" width="100%">';
print '<table class="public_border" width="100%">';
print '<tr class="liste_titre">';
print '<td><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=firstname">'.$langs->trans("Firstname").'</a>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$page.'&sortorder=ASC&sortfield=lastname">'.$langs->trans("Lastname").'</a>';
print ' / <a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></td>'."\n";
print '<tr class="public_liste_titre">';
print '<td><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=firstname">'.dolGetFirstLastname($langs->trans("Firstname"),$langs->trans("Lastname")).'</a></td>';
print '<td><a href="'.$_SERVER["PHP_SELF"].'?page='.$page.'&sortorder=ASC&sortfield=societe">'.$langs->trans("Company").'</a></td>'."\n";
//print_liste_field_titre($langs->trans("DateToBirth"), $_SERVER["PHP_SELF"],"birth",'',$param,$sortfield,$sortorder); // est-ce nécessaire ??
print_liste_field_titre($langs->trans("EMail"), $_SERVER["PHP_SELF"],"email",'',$param,$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Zip"), $_SERVER["PHP_SELF"],"zip","",$param,$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Town"), $_SERVER["PHP_SELF"],"town","",$param,$sortfield,$sortorder);
print "<td>".$langs->trans("Photo")."</td>\n";
print_liste_field_titre($langs->trans("EMail"), $_SERVER["PHP_SELF"],"email",'',$param,'',$sortfield,$sortorder,'public_');
print_liste_field_titre($langs->trans("Zip"), $_SERVER["PHP_SELF"],"zip","",$param,'',$sortfield,$sortorder,'public_');
print_liste_field_titre($langs->trans("Town"), $_SERVER["PHP_SELF"],"town","",$param,'',$sortfield,$sortorder,'public_');
print_liste_field_titre($langs->trans("Photo"), $_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder,'public_');
print "</tr>\n";
$var=True;
@ -139,13 +144,13 @@ if ($result)
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($obj->firstname, $obj->lastname).($objp->societe?' / '.$objp->societe:'').'</a></td>'."\n";
print '<td><a href="public_card.php?id='.$objp->rowid.'">'.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>'."\n";
print '<td>'.$objp->societe.'</td>'."\n";
print '<td>'.$objp->email.'</td>'."\n";
print '<td>'.$objp->zip.'</td>'."\n";
print '<td>'.$objp->town.'</td>'."\n";
if (isset($objp->photo) && $objp->photo != '')
{
$form = new Form($db);
print '<td>';
print $form->showphoto('memberphoto', $objp, 64);
print '</td>'."\n";
@ -165,6 +170,6 @@ else
}
$db->close();
llxFooterVierge();
$db->close();

View File

@ -148,6 +148,39 @@ print_barre_liste('Title of my list', 3, $_SERVER["PHP_SELF"], '', '', '', 'Text
?>
<table class="liste noborder tagtable centpercent" id="tablelines3">
<?php
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('This is a select list for a filter A'). ': ';
$cate_arbo = array('field1'=>'value1a into the select list A','field2'=>'value2a');
$moreforfilter.=$form->selectarray('search_aaa', $cate_arbo, '', 1); // List without js combo
$moreforfilter.='</div>';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('This is a select list for a filter B'). ': ';
$cate_arbo = array('field1'=>'value1b into the select list B','field2'=>'value2b');
$moreforfilter.=$form->selectarray('search_bbb', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo
$moreforfilter.='</div>';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('This is a select list for a filter C'). ': ';
$cate_arbo = array('field1'=>'value1c into the select list C','field2'=>'value2c');
$moreforfilter.=$form->selectarray('search_ccc', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo
$moreforfilter.='</div>';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('This is a select list for a filter D'). ': ';
$cate_arbo = array('field1'=>'value1d into the select list D','field2'=>'value2d');
$moreforfilter.=$form->selectarray('search_ddd', $cate_arbo, '', 1, 0, 0, '', 0, 0, 0, 0, '', 1); // List with js combo
$moreforfilter.='</div>';
if (! empty($moreforfilter))
{
print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="10">';
print $moreforfilter;
print '</td></tr>';
}
?>
<tr class="liste_titre">
<?php print getTitleFieldOfList($langs->trans('title1'),0,$_SERVER["PHP_SELF"],'aaa','','','align="left"',$sortfield,$sortorder); ?>
<?php print getTitleFieldOfList($langs->trans('title2'),0,$_SERVER["PHP_SELF"],'bbb','','','align="right"',$sortfield,$sortorder); ?>

View File

@ -75,7 +75,7 @@ print '<br><br>'."\n";
// Test4d: form->select_thirdparty
print "Test 4d: Select thirdparty<br>\n";
print $form->select_thirdparty(0,'thirdpartytest');
print $form->select_company(0,'thirdpartytest');
print '<br><br>'."\n";

View File

@ -0,0 +1,29 @@
<?php
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/public/theme/common/index.php
* \ingroup core
* \brief A redirect page to an error
* \author Laurent Destailleur
*/
require '../../../master.inc.php';
header("Location: ".DOL_URL_ROOT.'/public/error-404.php');

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -0,0 +1,29 @@
<?php
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/public/theme/index.php
* \ingroup core
* \brief A redirect page to an error
* \author Laurent Destailleur
*/
require '../../master.inc.php';
header("Location: ".DOL_URL_ROOT.'/public/error-404.php');

View File

@ -317,6 +317,7 @@ class Societe extends CommonObject
* @var string
*/
var $note_public;
//! code statut prospect
var $stcomm_id;
var $statut_commercial;
@ -1044,7 +1045,7 @@ class Societe extends CommonObject
$num=$this->db->num_rows($resql);
if ($num > 1)
{
$this->error='Fetch several records found for ref='.$ref;
$this->error='Fetch several records found request';
dol_syslog($this->error, LOG_ERR);
$result = -2;
}
@ -1301,13 +1302,15 @@ class Societe extends CommonObject
* Delete a third party from database and all its dependencies (contacts, rib...)
*
* @param int $id Id of third party to delete
* @param User $user User who ask to delete thirparty
* @param User $fuser User who ask to delete thirparty
* @param int $call_trigger 0=No, 1=yes
* @return int <0 if KO, 0 if nothing done, >0 if OK
* @return int <0 if KO, 0 if nothing done, >0 if OK
*/
function delete($id, $user='', $call_trigger=1)
function delete($id, User $fuser=null, $call_trigger=1)
{
global $langs, $conf;
global $langs, $conf, $user;
if (empty($fuser)) $fuser=$user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -1323,10 +1326,10 @@ class Societe extends CommonObject
$this->db->begin();
// User is mandatory for trigger call
if ($user && $call_trigger)
if ($call_trigger)
{
// Call trigger
$result=$this->call_trigger('COMPANY_DELETE',$user);
$result=$this->call_trigger('COMPANY_DELETE',$fuser);
if ($result < 0) $error++;
// End call triggers
}
@ -1451,7 +1454,8 @@ class Societe extends CommonObject
return 1;
}
else
{
{
dol_syslog($this->error, LOG_ERR);
$this->db->rollback();
return -1;
}

View File

@ -254,7 +254,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print $langs->trans('PriceBase');
print '</td>';
print '<td>';
print $form->select_PriceBaseType($object->price_base_type, "price_base_type");
print $form->selectPriceBaseType($object->price_base_type, "price_base_type");
print '</td>';
print '</tr>';
@ -332,7 +332,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print $langs->trans('PriceBase');
print '</td>';
print '<td>';
print $form->select_PriceBaseType($prodcustprice->price_base_type, "price_base_type");
print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type");
print '</td>';
print '</tr>';

View File

@ -1849,7 +1849,7 @@ else
'name' => 'soc_origin',
'label' => $langs->trans('MergeOriginThirdparty'),
'type' => 'other',
'value' => $form->select_thirdparty('', 'soc_origin', 's.rowid != '.$object->id)
'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id)
)
);

View File

@ -338,7 +338,7 @@ if ($resql)
print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$params,'class="nowrap"',$sortfield,$sortorder);
print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$params,'class="nowrap"',$sortfield,$sortorder);
print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$params,'class="nowrap"',$sortfield,$sortorder);
print '<td></td>';
print_liste_field_titre('');
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$params,'align="right"',$sortfield,$sortorder);
print "</tr>\n";

View File

@ -453,6 +453,10 @@ textarea.centpercent {
height: 28px;
vertical-align: middle;
}
div.divsearchfield {
float: <?php print $left; ?>;
margin-<?php print $right; ?>: 12px;
}
/* Style to move picto into left of button */
/*
@ -1976,9 +1980,12 @@ table.liste td {
/* Pagination */
div.refid {
div.refidpadding {
padding-top: <?php print empty($conf->dol_use_jmobile)?'8':'12'; ?>px;
font-weight: bold;
}
div.refid {
padding-top: <?php print empty($conf->dol_use_jmobile)?'5':'12'; ?>px;
font-weight: bold;
color: #766;
font-size: 120%;
}
@ -3542,6 +3549,18 @@ border-top-right-radius: 6px;
}
/* The theme for public pages */
.public_body {
margin: 20px;
}
.public_border {
border: 1px solid #888;
}
.public_liste_titre {
/* CSS style used for small screen */
.imgopensurveywizard
@ -3553,5 +3572,7 @@ border-top-right-radius: 6px;
.imgopensurveywizard { width:95%; height: auto; }
}
<?php
if (is_object($db)) $db->close();

View File

@ -4,7 +4,7 @@
* Copyright (c) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
* Copyright (C) 2013-2014 Philippe Grand <philippe.grand@atoo-net.com>
@ -1823,6 +1823,7 @@ class User extends CommonObject
{
global $langs, $conf, $db;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
$result = '';
@ -1833,7 +1834,6 @@ class User extends CommonObject
$label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs,'','');
if (! empty($this->login))
$label.= '<br><b>' . $langs->trans('Login') . ':</b> ' . $this->login;
if (! empty($this->email))
$label.= '<br><b>' . $langs->trans("EMail").':</b> '.$this->email;
if (! empty($this->admin))
$label.= '<br><b>' . $langs->trans("Administrator").'</b>: '.yn($this->admin);

View File

@ -173,7 +173,7 @@ else // Open and return file
// This test is to avoid error images when image is not available (for example thumbs).
if (! dol_is_file($original_file))
{
$original_file=DOL_DOCUMENT_ROOT.'/theme/common/nophoto.jpg';
$original_file=DOL_DOCUMENT_ROOT.'/public/theme/common/nophoto.jpg';
/*$error='Error: File '.$_GET["file"].' does not exists or filesystems permissions are not allowed';
dol_print_error(0,$error);
print $error;

View File

@ -272,7 +272,7 @@ function getContact($authentication,$id,$ref_ext)
){
$contact_result_fields =array(
'id' => $contact->id,
'ref_ext' => $contact->ref_ext,
'ref_ext' => $contact->ref_ext,
'lastname' => $contact->lastname,
'firstname' => $contact->firstname,
'address' => $contact->address,
@ -334,7 +334,7 @@ function getContact($authentication,$id,$ref_ext)
else
{
$error++;
$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref_ext='.$ref_ext;
}
}
@ -615,9 +615,15 @@ function updateContact($authentication,$contact)
$error=0;
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
// Check parameters
if (empty($contact['id'])) {
$error++; $errorcode='KO'; $errorlabel="Contact id is mandatory.";
if (empty($contact['id']) && empty($contact['ref_ext'])) {
$error++; $errorcode='KO'; $errorlabel="Contact id or ref_ext is mandatory.";
}
// Check parameters
if (! $error && ($id && $ref_ext))
{
$error++;
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref_ext can't be all provided. You must choose one of them.";
}
if (! $error)
{
@ -626,7 +632,7 @@ function updateContact($authentication,$contact)
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$object=new Contact($db);
$result=$object->fetch($contact['id']);
$result=$object->fetch($contact['id'],0,$contact['ref_ext']);
if (!empty($object->id)) {

View File

@ -102,7 +102,6 @@ $server->wsdl->addComplexType(
'total' => array('name'=>'total','type'=>'xsd:double'),
'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:string'),
// From product
'product_id' => array('name'=>'product_id','type'=>'xsd:int'),
'product_ref' => array('name'=>'product_ref','type'=>'xsd:string'),
@ -160,6 +159,7 @@ $server->wsdl->addComplexType(
'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
'date_validation' => array('name'=>'date_validation','type'=>'xsd:dateTime'),
'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:string'),
'type' => array('name'=>'type','type'=>'xsd:int'),
'total_net' => array('name'=>'type','type'=>'xsd:double'),
'total_vat' => array('name'=>'type','type'=>'xsd:double'),
@ -243,13 +243,37 @@ $server->register(
// Entry values
array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
// Exit values
array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
$ns,
$ns.'#createInvoice',
$styledoc,
$styleuse,
'WS to create an invoice'
);
$server->register(
'createInvoiceFromOrder',
// Entry values
array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
// Exit values
array('result'=>'tns:result','invoice'=>'tns:invoice'),
$ns,
$ns.'#createInvoiceFromOrder',
$styledoc,
$styleuse,
'WS to create an invoice from an order'
);
$server->register(
'updateInvoice',
// Entry values
array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
// Exit values
array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
$ns,
$ns.'#updateInvoice',
$styledoc,
$styleuse,
'WS to update an invoice'
);
/**
@ -299,15 +323,19 @@ function getInvoice($authentication,$id='',$ref='',$ref_ext='')
$linesresp[]=array(
'id'=>$line->rowid,
'type'=>$line->product_type,
'desc'=>dol_htmlcleanlastbr($line->desc),
'total_net'=>$line->total_ht,
'total_vat'=>$line->total_tva,
'total'=>$line->total_ttc,
'vat_rate'=>$line->tva_tx,
'qty'=>$line->qty,
'product_ref'=>$line->product_ref,
'product_label'=>$line->product_label,
'product_desc'=>$line->product_desc,
'desc'=>dol_htmlcleanlastbr($line->desc),
'total_net'=>$line->total_ht,
'total_vat'=>$line->total_tva,
'total'=>$line->total_ttc,
'vat_rate'=>$line->tva_tx,
'qty'=>$line->qty,
'unitprice'=> $line->subprice,
'date_start'=> $line->date_start?dol_print_date($line->date_start,'dayrfc'):'',
'date_end'=> $line->date_end?dol_print_date($line->date_end,'dayrfc'):'',
'product_id'=>$line->fk_product,
'product_ref'=>$line->product_ref,
'product_label'=>$line->product_label,
'product_desc'=>$line->product_desc,
);
$i++;
}
@ -319,9 +347,11 @@ function getInvoice($authentication,$id='',$ref='',$ref_ext='')
'id' => $invoice->id,
'ref' => $invoice->ref,
'ref_ext' => $invoice->ref_ext?$invoice->ref_ext:'', // If not defined, field is not added into soap
'thirdparty_id' => $invoice->socid,
'fk_user_author' => $invoice->user_author?$invoice->user_author:'',
'fk_user_valid' => $invoice->user_valid?$invoice->user_valid:'',
'date' => $invoice->date?dol_print_date($invoice->date,'dayrfc'):'',
'date_due' => $invoice->date_lim_reglement?dol_print_date($invoice->date_lim_reglement,'dayrfc'):'',
'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
'date_validation' => $invoice->date_validation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
'date_modification' => $invoice->datem?dol_print_date($invoice->datem,'dayhourrfc'):'',
@ -331,7 +361,8 @@ function getInvoice($authentication,$id='',$ref='',$ref_ext='')
'total' => $invoice->total_ttc,
'note_private' => $invoice->note_private?$invoice->note_private:'',
'note_public' => $invoice->note_public?$invoice->note_public:'',
'status'=> $invoice->statut,
'status' => $invoice->statut,
'project_id' => $invoic->fk_project,
'close_code' => $invoice->close_code?$invoice->close_code:'',
'close_note' => $invoice->close_note?$invoice->close_note:'',
'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
@ -387,7 +418,7 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
if (! $error && empty($idthirdparty))
{
$error++;
$errorcode='BAD_PARAMETERS'; $errorlabel='Parameter id is not provided';
$errorcode='BAD_PARAMETERS'; $errorlabel='Parameter idthirdparty is not provided';
}
if (! $error)
@ -433,6 +464,10 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
'total'=>$line->total_ttc,
'vat_rate'=>$line->tva_tx,
'qty'=>$line->qty,
'unitprice'=> $line->subprice,
'date_start'=> $line->date_start?dol_print_date($line->date_start,'dayrfc'):'',
'date_end'=> $line->date_end?dol_print_date($line->date_end,'dayrfc'):'',
'product_id'=>$line->fk_product,
'product_ref'=>$line->product_ref,
'product_label'=>$line->product_label,
'product_desc'=>$line->product_desc,
@ -448,7 +483,7 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
'fk_user_valid' => $invoice->user_valid?$invoice->user_valid:'',
'date' => $invoice->date?dol_print_date($invoice->date,'dayrfc'):'',
'date_due' => $invoice->date_lim_reglement?dol_print_date($invoice->date_lim_reglement,'dayrfc'):'',
'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
'date_validation' => $invoice->date_validation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
'date_modification' => $invoice->datem?dol_print_date($invoice->datem,'dayhourrfc'):'',
'type' => $invoice->type,
@ -458,9 +493,10 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
'note_private' => $invoice->note_private?$invoice->note_private:'',
'note_public' => $invoice->note_public?$invoice->note_public:'',
'status'=> $invoice->statut,
'project_id' => $invoic->fk_project,
'close_code' => $invoice->close_code?$invoice->close_code:'',
'close_note' => $invoice->close_note?$invoice->close_note:'',
'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
'lines' => $linesresp
);
}
@ -503,7 +539,8 @@ function createInvoice($authentication,$invoice)
$now=dol_now();
dol_syslog("Function: createInvoiceForThirdParty login=".$authentication['login']);
dol_syslog("Function: createInvoice login=".$authentication['login']." id=".$invoice->id.
", ref=".$invoice->ref.", ref_ext=".$invoice->ref_ext);
if ($authentication['entity']) $conf->entity=$authentication['entity'];
@ -513,27 +550,32 @@ function createInvoice($authentication,$invoice)
$error=0;
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
// Check parameters
if (empty($invoice['id']) && empty($invoice['ref']) && empty($invoice['ref_ext'])) {
$error++; $errorcode='KO'; $errorlabel="Invoice id or ref or ref_ext is mandatory.";
}
if (! $error)
{
$newobject=new Facture($db);
$newobject->socid=$invoice['thirdparty_id'];
$newobject->type=$invoice['type'];
$newobject->ref_ext=$invoice['ref_ext'];
$newobject->date=dol_stringtotime($invoice['date'],'dayrfc');
$newobject->note_private=$invoice['note_private'];
$newobject->note_public=$invoice['note_public'];
$newobject->statut= Facture::STATUS_DRAFT; // We start with status draft
$newobject->fk_project=$invoice['project_id'];
$newobject->date_creation=$now;
$new_invoice=new Facture($db);
$new_invoice->socid=$invoice['thirdparty_id'];
$new_invoice->type=$invoice['type'];
$new_invoice->ref_ext=$invoice['ref_ext'];
$new_invoice->date=dol_stringtotime($invoice['date'],'dayrfc');
$new_invoice->note_private=$invoice['note_private'];
$new_invoice->note_public=$invoice['note_public'];
$new_invoice->statut= Facture::STATUS_DRAFT; // We start with status draft
$new_invoice->fk_project=$invoice['project_id'];
$new_invoice->date_creation=$now;
//take mode_reglement and cond_reglement from thirdparty
$soc = new Societe($db);
$res=$soc->fetch($newobject->socid);
$res=$soc->fetch($new_invoice->socid);
if ($res > 0) {
$newobject->mode_reglement_id = ! empty($invoice['payment_mode_id'])?$invoice['payment_mode_id']:$soc->mode_reglement_id;
$newobject->cond_reglement_id = $soc->cond_reglement_id;
$new_invoice->mode_reglement_id = ! empty($invoice['payment_mode_id'])?$invoice['payment_mode_id']:$soc->mode_reglement_id;
$new_invoice->cond_reglement_id = $soc->cond_reglement_id;
}
else $newobject->mode_reglement_id = $invoice['payment_mode_id'];
else $new_invoice->mode_reglement_id = $invoice['payment_mode_id'];
// Trick because nusoap does not store data with same structure if there is one or several lines
$arrayoflines=array();
@ -556,22 +598,22 @@ function createInvoice($authentication,$invoice)
$newline->date_start=dol_stringtotime($line['date_start']);
$newline->date_end=dol_stringtotime($line['date_end']);
$newline->fk_product=$line['product_id'];
$newobject->lines[]=$newline;
$new_invoice->lines[]=$newline;
}
//var_dump($newobject->date_lim_reglement); exit;
//var_dump($invoice['lines'][0]['type']);
$db->begin();
$result=$newobject->create($fuser,0,dol_stringtotime($invoice['date_due'],'dayrfc'));
$result=$new_invoice->create($fuser,0,dol_stringtotime($invoice['date_due'],'dayrfc'));
if ($result < 0)
{
$error++;
}
if ($invoice['status'] == 1) // We want invoice to have status validated
if (!$error && $invoice['status'] == Facture::STATUS_VALIDATED) // We want invoice to have status validated
{
$result=$newobject->validate($fuser);
$result=$new_invoice->validate($fuser);
if ($result < 0)
{
$error++;
@ -581,14 +623,16 @@ function createInvoice($authentication,$invoice)
if (! $error)
{
$db->commit();
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_invoice->id,
'ref'=>$new_invoice->ref,'ref_ext'=>$new_invoice->ref_ext);
}
else
{
$db->rollback();
$error++;
$errorcode='KO';
$errorlabel=$newobject->error;
$errorlabel=$new_invoice->error;
dol_syslog("Function: createInvoice error while creating".$errorlabel);
}
}
@ -601,5 +645,197 @@ function createInvoice($authentication,$invoice)
return $objectresp;
}
/**
* Create an invoice from an order
*
* @param array $authentication Array of authentication information
* @param string $id_order id of order to copy invoice from
* @param string $ref_order ref of order to copy invoice from
* @param string $ref_ext_order ref_ext of order to copy invoice from
* @param string $id_invoice invoice id
* @param string $ref_invoice invoice ref
* @param string $ref_ext_invoice invoice ref_ext
* @return array Array result
*/
function createInvoiceFromOrder($authentication,$id_order='', $ref_order='', $ref_ext_order='',
$id_invoice='', $ref_invoice='', $ref_ext_invoice='')
{
global $db,$conf,$langs;
$now=dol_now();
dol_syslog("Function: createInvoiceFromOrder login=".$authentication['login']." id=".$id_order.
", ref=".$ref_order.", ref_ext=".$ref_ext_order);
if ($authentication['entity']) $conf->entity=$authentication['entity'];
// Init and check authentication
$objectresp=array();
$errorcode='';$errorlabel='';
$error=0;
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
// Check parameters
if (empty($id_order) && empty($ref_order) && empty($ref_ext_order)) {
$error++; $errorcode='KO'; $errorlabel="order id or ref or ref_ext is mandatory.";
} else if (empty($id_invoice) && empty($ref_invoice) && empty($ref_ext_invoice)) {
$error++; $errorcode='KO'; $errorlabel="invoice id or ref or ref_ext is mandatory.";
}
//////////////////////
if (! $error)
{
$fuser->getrights();
if ($fuser->rights->commande->lire)
{
$order=new Commande($db);
$result=$order->fetch($id,$ref,$ref_ext);
if ($result > 0)
{
// Security for external user
if( $socid && ( $socid != $order->socid) )
{
$error++;
$errorcode='PERMISSION_DENIED'; $errorlabel=$order->socid.'User does not have permission for this request';
}
if(!$error)
{
$newobject=new Facture($db);
$result = $newobject->createFromOrder($order);
if ($result < 0)
{
$error++;
dol_syslog("Webservice server_invoice:: invoice creation from order failed", LOG_ERR);
}
}
}
else
{
$error++;
$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id_order.' nor ref='.$ref_order.' nor ref_ext='.$ref_ext_order;
}
}
else
{
$error++;
$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
}
}
if ($error)
{
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
else
{
$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''),'invoice'=>$newobject);
}
return $objectresp;
}
/**
* Uddate an invoice, only change the state of an invoice
*
* @param array $authentication Array of authentication information
* @param Facture $invoice Invoice
* @return array Array result
*/
function updateInvoice($authentication,$invoice)
{
global $db,$conf,$langs;
dol_syslog("Function: updateInvoice login=".$authentication['login']." id=".$invoice['id'].
", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']);
if ($authentication['entity']) $conf->entity=$authentication['entity'];
// Init and check authentication
$objectresp=array();
$errorcode='';$errorlabel='';
$error=0;
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
// Check parameters
if (empty($invoice['id']) && empty($invoice['ref']) && empty($invoice['ref_ext'])) {
$error++; $errorcode='KO'; $errorlabel="Invoice id or ref or ref_ext is mandatory.";
}
if (! $error)
{
$objectfound=false;
$object=new Facture($db);
$result=$object->fetch($invoice['id'],$invoice['ref'],$invoice['ref_ext'], '');
if (!empty($object->id)) {
$objectfound=true;
$db->begin();
if (isset($invoice['status']))
{
if ($invoice['status'] == Facture::STATUS_DRAFT)
{
$result = $object->set_draft($fuser);
}
if ($invoice['status'] == Facture::STATUS_VALIDATED)
{
$result = $object->validate($fuser);
if ($result >= 0)
{
// Define output language
$outputlangs = $langs;
$order->generateDocument($invoice->modelpdf, $outputlangs);
}
}
if ($invoice['status'] == Facture::STATUS_CLOSED)
{
$result = $object->set_paid($fuser,$invoice->close_code,$invoice->close_note);
}
if ($invoice['status'] == Facture::STATUS_ABANDONED)
$result = $object->set_canceled($fuser,$invoice->close_code,$invoice->close_note);
}
}
if ((! $error) && ($objectfound))
{
$db->commit();
$objectresp=array(
'result'=>array('result_code'=>'OK', 'result_label'=>''),
'id'=>$object->id,
'ref'=>$object->ref,
'ref_ext'=>$object->ref_ext
);
}
elseif ($objectfound)
{
$db->rollback();
$error++;
$errorcode='KO';
$errorlabel=$object->error;
} else {
$error++;
$errorcode='NOT_FOUND';
$errorlabel='Invoice id='.$invoice['id'].' ref='.$invoice['ref'].' ref_ext='.$invoice['ref_ext'].' cannot be found';
}
}
if ($error)
{
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
return $objectresp;
}
// Return the results.
$server->service(file_get_contents("php://input"));

View File

@ -917,7 +917,17 @@ function updateOrder($authentication,$order)
if (isset($order['status']))
{
if ($order['status'] == -1) $result=$object->cancel($fuser);
if ($order['status'] == 1) $result=$object->valid($fuser);
if ($order['status'] == 1)
{
$result=$object->valid($fuser);
if ($result >= 0)
{
// Define output language
$outputlangs = $langs;
$order->generateDocument($order->modelpdf, $outputlangs);
}
}
if ($order['status'] == 0) $result=$object->set_reopen($fuser);
if ($order['status'] == 3) $result=$object->cloture($fuser);
}
@ -951,7 +961,9 @@ function updateOrder($authentication,$order)
$db->commit();
$objectresp=array(
'result'=>array('result_code'=>'OK', 'result_label'=>''),
'id'=>$object->id
'id'=>$object->id,
'ref'=>$object->ref,
'ref_ext'=>$object->ref_ext
);
}
elseif ($objectfound)

View File

@ -258,8 +258,31 @@ $server->register(
'WS to get list of thirdparties id and ref'
);
// Register WSDL
$server->register(
'deleteThirdParty',
// Entry values
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
// Exit values
array('result'=>'tns:result','id'=>'xsd:string'),
$ns,
$ns.'#deleteThirdParty',
$styledoc,
$styleuse,
'WS to delete a thirdparty from its id, ref or ref_ext'
);
// Full methods code
/**
* Get a thirdparty
*
* @param array $authentication Array of authentication information
* @param string $id internal id
* @param string $ref internal reference
* @param string $ref_ext external reference
* @return array Array result
*/
function getThirdParty($authentication,$id='',$ref='',$ref_ext='')
{
global $db,$conf,$langs;
@ -728,5 +751,88 @@ function getListOfThirdParties($authentication,$filterthirdparty)
return $objectresp;
}
/**
* Delete a thirdparty
*
* @param array $authentication Array of authentication information
* @param string $id internal id
* @param string $ref internal reference
* @param string $ref_ext external reference
* @return array Array result
*/
function deleteThirdParty($authentication,$id='',$ref='',$ref_ext='')
{
global $db,$conf,$langs;
dol_syslog("Function: deleteThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
if ($authentication['entity']) $conf->entity=$authentication['entity'];
// Init and check authentication
$objectresp=array();
$errorcode='';$errorlabel='';
$error=0;
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
// Check parameters
if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
{
dol_syslog("Function: deleteThirdParty checkparam");
$error++;
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
}
dol_syslog("Function: deleteThirdParty 1");
if (! $error)
{
$fuser->getrights();
if ($fuser->rights->societe->lire && $fuser->rights->societe->supprimer)
{
$thirdparty=new Societe($db);
$result=$thirdparty->fetch($id,$ref,$ref_ext);
if ($result > 0)
{
$db->begin();
$result=$thirdparty->delete($thirdparty->id, $fuser);
if ($result > 0)
{
$db->commit();
$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''));
}
else
{
$db->rollback();
$error++;
$errorcode='KO';
$errorlabel=$thirdparty->error;
dol_syslog("Function: deleteThirdParty cant delete");
}
}
else
{
$error++;
$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
}
}
else
{
$error++;
$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
}
}
if ($error)
{
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
return $objectresp;
}
// Return the results.
$server->service(file_get_contents("php://input"));

View File

@ -18,9 +18,9 @@
/**
* \file test/phpunit/WebservicesInvoicesTest.php
* \ingroup test
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php
* \remarks To run this script as CLI: phpunit filename.php
*/
global $conf,$user,$langs,$db;
@ -31,10 +31,11 @@ require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
if (empty($user->id)) {
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
if (empty($user->id))
{
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
}
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
@ -44,138 +45,369 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
*
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
{
protected $savconf;
protected $savuser;
protected $savlangs;
protected $savdb;
protected $savconf;
protected $savuser;
protected $savlangs;
protected $savdb;
protected $soapclient;
protected $socid;
protected $ns = 'http://www.dolibarr.org/ns/';
/**
* Constructor
* We save global variables into local variables
*
* @return DateLibTest
*/
function __construct()
{
//$this->sharedFixture
global $conf,$user,$langs,$db;
$this->savconf=$conf;
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
// Set the WebService URL
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
$this->soapclient = new nusoap_client($WS_DOL_URL);
if ($this->soapclient)
{
$this->soapclient->soap_defencoding='UTF-8';
$this->soapclient->decodeUTF8(false);
}
// create a third_party, needed to create an invoice
$societe=new Societe($db);
$societe->ref='';
$societe->name='name';
$societe->ref_ext='209';
$societe->status=1;
$societe->client=1;
$societe->fournisseur=0;
$societe->date_creation=$now;
$societe->tva_assuj=0;
$societe->particulier=0;
$societe->create($user);
$this->socid = $societe->id;
print __METHOD__." societe created id=".$societe->id."\n";
/**
* Constructor
* We save global variables into local variables
*
* @return DateLibTest
*/
function __construct()
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db;
print "\n";
}
// Static methods
public static function setUpBeforeClass()
{
//$this->sharedFixture
global $conf,$user,$langs,$db;
$this->savconf=$conf;
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db;
print "\n";
print __METHOD__."\n";
}
// Static methods
public static function setUpBeforeClass()
{
global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
print __METHOD__."\n";
}
// tear down after class
public static function tearDownAfterClass()
{
global $conf,$user,$langs,$db;
$db->rollback();
global $conf,$user,$langs,$db;
$db->rollback();
print __METHOD__."\n";
print __METHOD__."\n";
}
/**
* Init phpunit tests
*
* @return void
*/
/**
* Init phpunit tests
*
* @return void
*/
protected function setUp()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
print __METHOD__."\n";
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
print __METHOD__."\n";
}
/**
* End phpunit tests
*
* @return void
*/
/**
* End phpunit tests
*
* @return void
*/
protected function tearDown()
{
print __METHOD__."\n";
print __METHOD__."\n";
}
/**
* testWSInvoicesXxx
* testWSInvoicesCreateInvoice
*
* @return int
* @return int invoice created
*/
public function testWSInvoicesXxx()
public function testWSInvoicesCreateInvoice()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
$WS_METHOD = 'getInvoice';
$ns='http://www.dolibarr.org/ns/';
$WS_METHOD = 'createInvoice';
// Set the WebService URL
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
$soapclient = new nusoap_client($WS_DOL_URL);
if ($soapclient) {
$soapclient->soap_defencoding='UTF-8';
$soapclient->decodeUTF8(false);
}
// load societe first
$societe=new Societe($db);
$societe->fetch('', '', '209');
print __METHOD__." societe loaded id=".$societe->id."\n";
$body = array (
"id" => NULL,
"ref" => NULL,
"ref_ext" => "165",
"thirdparty_id" => $societe->id,
"fk_user_author" => NULL,
"fk_user_valid" => NULL,
"date" => "2015-04-19 20:16:53",
"date_due" => "",
"date_creation" => "",
"date_validation" => "",
"date_modification" => "",
"type" => "",
"total_net" => "36.30",
"total_vat" => "6.00",
"total" => "42.30",
"payment_mode_id" => 50,
"note_private" => "Synchronised from Prestashop",
"note_public" => "",
"status" => "1",
"close_code" => NULL ,
"close_note" => NULL,
"project_id" => NULL,
"lines" => array(
array("id" => NULL,
"type" => 0,
"desc" => "Horloge Vinyle Serge",
"vat_rate" => 20,
"qty" => 1,
"unitprice" => "30.000000",
"total_net" => "30.000000",
"total_vat" => "6.00",
"total" => "36.000000",
"date_start" => "",
"date_end" => "",
"payment_mode_id" => "",
"product_id" => "",
"product_ref" => "",
"product_label" => "",
"product_desc" => "" ))
);
// Call the WebService method and store its result in $result.
$authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'entity'=>''
);
// Call the WebService method and store its result in $result.
$authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'entity'=>'');
// Test URL
$result='';
$parameters = array('authentication'=>$authentication,'id'=>1);
print __METHOD__." call method ".$WS_METHOD."\n";
try {
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
} catch(SoapFault $exception) {
echo $exception;
$result=0;
}
if (! $result || ! empty($result['faultstring'])) {
//var_dump($soapclient);
print $soapclient->error_str;
print "\n<br>\n";
print $soapclient->request;
print "\n<br>\n";
print $soapclient->response;
print "\n";
}
// Test URL
$result='';
$parameters = array('authentication'=>$authentication,'invoice'=>$body);
print __METHOD__." call method ".$WS_METHOD."\n";
try {
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,'');
}
catch(SoapFault $exception)
{
echo $exception;
$result=0;
}
if (! $result || ! empty($result['faultstring']))
{
//var_dump($soapclient);
print $this->soapclient->error_str;
print "\n<br>\n";
print $this->soapclient->request;
print "\n<br>\n";
print $this->soapclient->response;
print "\n";
}
print __METHOD__." result=".$result."\n";
$this->assertEquals('OK',$result['result']['result_code']);
print __METHOD__." result=".$result['result']['result_code']."\n";
$this->assertEquals('OK',$result['result']['result_code']);
$this->assertEquals('165', $result['ref_ext']);
return $result;
return $result;
}
/**
* testWSInvoicesGetInvoiceByRefExt
*
* Retrieve an invoice using ref_ext
* @depends testWSInvoicesCreateInvoice
*
* @param array $result Invoice created by create method
* @return array Invoice
*/
public function testWSInvoicesGetInvoiceByRefExt($result)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$WS_METHOD = 'getInvoice';
// Call the WebService method and store its result in $result.
$authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'entity'=>'');
// Test URL
$result='';
$parameters = array('authentication'=>$authentication,'id'=>NULL,'ref'=>NULL,'ref_ext'=>165);
print __METHOD__." call method ".$WS_METHOD."\n";
try {
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,'');
}
catch(SoapFault $exception)
{
echo $exception;
$result=0;
}
if (! $result || ! empty($result['faultstring']))
{
print $this->soapclient->error_str;
print "\n<br>\n";
print $this->soapclient->request;
print "\n<br>\n";
print $this->soapclient->response;
print "\n";
}
print __METHOD__." result=".$result['result']['result_code']."\n";
$this->assertEquals('OK',$result['result']['result_code']);
$this->assertEquals('165', $result['invoice']['ref_ext']);
return $result;
}
/**
* testWSInvoicesUpdateInvoiceByRefExt
*
* Update an invoice using ref_ext
* @depends testWSInvoicesCreateInvoice
*
* @param array $result invoice created by create method
* @return array Invoice
*/
public function testWSInvoicesUpdateInvoiceByRefExt($result)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$WS_METHOD = 'updateInvoice';
// update status to 2
$body = array (
"id" => NULL,
"ref" => NULL,
"ref_ext" => "165",
"thirdparty_id" => "209",
"fk_user_author" => NULL,
"fk_user_valid" => NULL,
"date" => "2015-04-19 20:16:53",
"date_due" => "",
"date_creation" => "",
"date_validation" => "",
"date_modification" => "",
"type" => "",
"total_net" => "36.30",
"total_vat" => "6.00",
"total" => "42.30",
"payment_mode_id" => 50,
"note_private" => "Synchronised from Prestashop",
"note_public" => "",
"status" => "2",
"close_code" => NULL ,
"close_note" => NULL,
"project_id" => NULL,
"lines" => array(
array(
"id" => NULL,
"type" => 0,
"desc" => "Horloge Vinyle Serge",
"vat_rate" => 20,
"qty" => "1",
"unitprice" => "30.000000",
"total_net" => "30.000000",
"total_vat" => "6.00",
"total" => "36.000000",
"date_start" => "",
"date_end" => "",
"payment_mode_id" => "",
"product_id" => "",
"product_ref" => "",
"product_label" => "",
"product_desc" => "" ))
);
// Call the WebService method and store its result in $result.
$authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'entity'=>'');
// Test URL
$result='';
$parameters = array('authentication'=>$authentication,'invoice'=>$body);
print __METHOD__." call method ".$WS_METHOD."\n";
try {
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,'');
}
catch(SoapFault $exception)
{
echo $exception;
$result=0;
}
if (! $result || ! empty($result['faultstring']))
{
print $this->soapclient->error_str;
print "\n<br>\n";
print $this->soapclient->request;
print "\n<br>\n";
print $this->soapclient->response;
print "\n";
}
print __METHOD__." result=".$result['result']['result_code'].$result['result']['result_label']."\n";
$this->assertEquals('OK',$result['result']['result_code']);
$this->assertEquals('165', $result['ref_ext']);
return $result;
}
}

View File

@ -52,6 +52,13 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
protected $savuser;
protected $savlangs;
protected $savdb;
protected $soapclient;
private $_WS_DOL_URL;
private $_ns='http://www.dolibarr.org/ns/';
/**
* Constructor
@ -67,6 +74,16 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
$this->_WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
// Set the WebService URL
print __METHOD__." create nusoap_client for URL=".$this->_WS_DOL_URL."\n";
$this->soapclient = new nusoap_client($this->_WS_DOL_URL);
if ($this->soapclient) {
$this->soapclient->soap_defencoding='UTF-8';
$this->soapclient->decodeUTF8(false);
}
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db;
@ -117,31 +134,114 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
print __METHOD__."\n";
}
/**
* testWSThirdpartycreateThirdParty
*
* @return array thirdparty created
*/
public function testWSThirdpartycreateThirdParty()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$WS_METHOD = 'createThirdParty';
// Call the WebService method and store its result in $result.
$authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'entity'=>'');
$body = array (
"id" => NULL,
"ref" => "name",
"ref_ext" => "12",
"fk_user_author" => NULL,
"status" => NULL,
"client" => 1,
"supplier" => 0,
"customer_code" => "",
"supplier_code" => "",
"customer_code_accountancy" => "",
"supplier_code_accountancy" => "",
"date_creation" => "", // dateTime
"date_modification" => "", // dateTime
"note_private" => "",
"note_public" => "",
"address" => "",
"zip" => "",
"town" => "",
"province_id" => "",
"country_id" => "",
"country_code" => "",
"country" => "",
"phone" => "",
"fax" => "",
"email" => "",
"url" => "",
"profid1" => "",
"profid2" => "",
"profid3" => "",
"profid4" => "",
"profid5" => "",
"profid6" => "",
"capital" => "",
"vat_used" => "",
"vat_number" => ""
);
// Test URL
$result='';
$parameters = array('authentication'=>$authentication, 'thirdparty'=>$body);
print __METHOD__." call method ".$WS_METHOD."\n";
try {
$result = $this->soapclient->call($WS_METHOD,$parameters,$thid->ns,'');
} catch(SoapFault $exception) {
echo $exception;
$result=0;
}
if (! $result || ! empty($result['faultstring'])) {
//var_dump($soapclient);
print $this->soapclient->error_str;
print "\n<br>\n";
print $this->soapclient->request;
print "\n<br>\n";
print $this->soapclient->response;
print "\n";
}
print __METHOD__." result=".$result['result']['result_code']."\n";
$this->assertEquals('OK',$result['result']['result_code']);
$this->assertEquals('name',$result['ref']);
return $result;
}
/**
* testWSThirdpartygetThirdParty
*
* @return int
* testWSThirdpartygetThirdPartyById
*
* Use id to retrieve thirdparty
* @depends testWSThirdpartycreateThirdParty
*
* @param array $result thirdparty created by create method
* @return array thirpdarty updated
*/
public function testWSThirdpartygetThirdParty()
public function testWSThirdpartygetThirdPartyById($result)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$id = $result['id'];
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
$WS_METHOD = 'getThirdParty';
$ns='http://www.dolibarr.org/ns/';
// Set the WebService URL
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
$soapclient = new nusoap_client($WS_DOL_URL);
if ($soapclient) {
$soapclient->soap_defencoding='UTF-8';
$soapclient->decodeUTF8(false);
}
// Call the WebService method and store its result in $result.
$authentication=array(
@ -151,30 +251,150 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
'password'=>'admin',
'entity'=>'');
// Test URL
$result='';
$parameters = array('authentication'=>$authentication, 'id'=>1);
$parameters = array('authentication'=>$authentication, 'id'=>$id);
print __METHOD__." call method ".$WS_METHOD."\n";
try {
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->_ns,'');
} catch(SoapFault $exception) {
echo $exception;
$result=0;
}
if (! $result || ! empty($result['faultstring'])) {
//var_dump($soapclient);
print $soapclient->error_str;
print $this->soapclient->error_str;
print "\n<br>\n";
print $soapclient->request;
print $this->soapclient->request;
print "\n<br>\n";
print $soapclient->response;
print $this->soapclient->response;
print "\n";
}
print __METHOD__." result=".$result."\n";
print __METHOD__." result=".$result['result']['result_code']."\n";
$this->assertEquals('OK',$result['result']['result_code']);
$this->assertEquals($id, $result['thirdparty']['id']);
$this->assertEquals('name', $result['thirdparty']['ref']);
$this->assertEquals('12', $result['thirdparty']['ref_ext']);
$this->assertEquals('0', $result['thirdparty']['status']);
$this->assertEquals('1', $result['thirdparty']['client']);
$this->assertEquals('0', $result['thirdparty']['supplier']);
return $result;
}
/**
* testWSThirdpartygetThirdPartyByRefExt
*
* Use ref_ext to retrieve thirdparty
*
* @depends testWSThirdpartycreateThirdParty
*
* @param array $result thirdparty created by create method
* @return array thirdparty
*/
public function testWSThirdpartygetThirdPartyByRefExt($result)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$id = $result['id'];
$WS_METHOD = 'getThirdParty';
// Call the WebService method and store its result in $result.
$authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'entity'=>'');
// Test URL
$result='';
$parameters = array('authentication'=>$authentication, 'id'=>'', 'ref'=>'', 'ref_ext'=>'12');
print __METHOD__." call method ".$WS_METHOD."\n";
try {
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->_ns,'');
} catch(SoapFault $exception) {
echo $exception;
$result=0;
}
print $this->soapclient->response;
if (! $result || ! empty($result['faultstring'])) {
//var_dump($soapclient);
print $this->soapclient->error_str;
print "\n<br>\n";
print $this->soapclient->request;
print "\n<br>\n";
print $this->soapclient->response;
print "\n";
}
print __METHOD__." result=".$result['result']['result_code']."\n";
$this->assertEquals('OK',$result['result']['result_code']);
$this->assertEquals($id, $result['thirdparty']['id']);
$this->assertEquals('name', $result['thirdparty']['ref']);
$this->assertEquals('12', $result['thirdparty']['ref_ext']);
$this->assertEquals('0', $result['thirdparty']['status']);
$this->assertEquals('1', $result['thirdparty']['client']);
$this->assertEquals('0', $result['thirdparty']['supplier']);
return $result;
}
/**
* testWSThirdpartydeleteThirdParty
*
* @depends testWSThirdpartycreateThirdParty
*
* @param array $result thirdparty created by create method
* @return array thirdparty
*/
public function testWSThirdpartydeleteThirdPartyById($result)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$id = $result['id'];
$WS_METHOD = 'deleteThirdParty';
// Call the WebService method and store its result in $result.
$authentication=array(
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'entity'=>'');
$result='';
$parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'', 'ref_ext'=>'');
print __METHOD__." call method ".$WS_METHOD."\n";
try {
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->_ns,'');
} catch(SoapFault $exception) {
echo $exception;
$result=0;
}
if (! $result || ! empty($result['faultstring'])) {
print $this->soapclient->error_str;
print "\n<br>\n";
print $this->soapclient->request;
print "\n<br>\n";
print $this->soapclient->response;
print "\n";
}
print __METHOD__." result=".$result['result']['result_code']."\n";
$this->assertEquals('OK',$result['result']['result_code']);
return $result;
}
}