Merge remote-tracking branch 'Upstream/develop' into develop-28

This commit is contained in:
aspangaro 2015-06-08 21:33:45 +02:00
commit 592d124f26
50 changed files with 1444 additions and 469 deletions

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>';

View File

@ -2340,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
@ -2365,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>
@ -2334,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
@ -2359,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>
@ -3821,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
@ -3846,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

@ -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

@ -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

@ -4357,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">
@ -4964,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.
@ -4990,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);
@ -5120,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

@ -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

@ -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)

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

@ -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

@ -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

@ -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')))
{

View File

@ -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 = '';
@ -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'];
}

View File

@ -2443,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
@ -2470,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

@ -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

@ -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

@ -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

@ -1045,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;
}

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

@ -452,6 +452,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 */
/*
@ -1974,9 +1978,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%;
}
@ -3541,6 +3548,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
@ -3552,5 +3571,7 @@ border-top-right-radius: 6px;
.imgopensurveywizard { width:95%; height: auto; }
}
<?php
if (is_object($db)) $db->close();

View File

@ -1833,7 +1833,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;
}
}