Merge branch 'develop' of ssh://github.com/Dolibarr/dolibarr into api_dev

This commit is contained in:
nka11 2016-04-18 19:13:06 +02:00
commit 39948968eb
58 changed files with 1269 additions and 427 deletions

View File

@ -256,7 +256,7 @@ $tabfield[21]= "code,label";
$tabfield[22]= "code,label";
$tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[24]= "code,label";
$tabfield[25]= "label,type_template,position,topic,content";
$tabfield[25]= "label,type_template,private,position,topic,content";
$tabfield[26]= "code,label,short_label";
$tabfield[27]= "code,libelle";
$tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country";
@ -293,7 +293,7 @@ $tabfieldvalue[21]= "code,label";
$tabfieldvalue[22]= "code,label";
$tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[24]= "code,label";
$tabfieldvalue[25]= "label,type_template,position,topic,content";
$tabfieldvalue[25]= "label,type_template,private,position,topic,content";
$tabfieldvalue[26]= "code,label,short_label";
$tabfieldvalue[27]= "code,libelle";
$tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country";
@ -644,7 +644,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$ok=0;
setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors');
}
// Clean some parameters
if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0
if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0
@ -1409,7 +1409,7 @@ if ($id)
if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; }
$canbemodified=$iserasable;
if ($obj->code == 'RECEP') $canbemodified=1;
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&';
// Favorite

View File

@ -50,25 +50,11 @@ else if ($action == 'disable_hidemenu')
exit;
}
if ($action == 'activate_layoutmenu')
{
dolibarr_set_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT", '1','chaine',0,'',$conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else if ($action == 'disable_layoutmenu')
{
dolibarr_del_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT",$conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
/*
* View
*/
llxHeader('',$langs->trans("Setup"));
print load_fiche_titre($langs->trans("Menus"),'','title_setup');
@ -119,25 +105,6 @@ else
print "</td>";
print '</tr>';
// Use a flip-hide menu
if (isset($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL > 1)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td colspan="3">'.$langs->trans("MenuUseLayout").'</td>';
print '<td align="center">';
if (empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=activate_layoutmenu">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=disable_layoutmenu">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
}
print "</td>";
print '</tr>';
}
print '</table>';

View File

@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php';
require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
// Translations
$langs->load("multicurrency");
@ -41,10 +42,11 @@ if (! $user->admin) {
// Parameters
$action = GETPOST('action', 'alpha');
/*
* Actions
*/
if (preg_match('/set_(.*)/',$action,$reg))
{
$code=$reg[1];
@ -64,7 +66,7 @@ if (preg_match('/del_(.*)/',$action,$reg))
$code=$reg[1];
if (dolibarr_del_const($db, $code, 0) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
@ -117,6 +119,21 @@ elseif ($action == 'update_currency')
}
}
}
elseif ($action == 'synchronize')
{
$response = GETPOST('response');
$response = json_decode($response);
if ($response->success)
{
MultiCurrency::syncRates($response);
}
else
{
setEventMessages($langs->trans('multicurrency_syncronize_error', $reponse->error->info), null, 'errors');
}
}
$TCurrency = array();
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity;
@ -136,7 +153,7 @@ if ($resql)
* View
*/
$page_name = "MultiCurrency";
$page_name = "MultiCurrencySetup";
llxHeader('', $langs->trans($page_name));
@ -212,42 +229,72 @@ print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_MODIFY_RATE_APPLICATION">';
print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY'));
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_appId").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_CURRENCY_APP_ID">';
print '<input type="text" name="CURRENCY_APP_ID" value="'.$conf->global->MULTICURRENCY_APP_ID.'" size="28" />&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_currencyFromToRate").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_FROM_TO_RATE">';
print '<input type="text" name="MULTICURRENCY_FROM_TO_RATE" value="'.$conf->global->MULTICURRENCY_FROM_TO_RATE.'" size="10" placeholder="USD-EUR-1" />&nbsp;'; // CURRENCY_BASE - CURRENCY_ENTITY - ID_ENTITY
print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY'), $conf->global->MULTICURRENCY_MODIFY_RATE_APPLICATION);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
print '</table>';
print '</form>';
print '<br />';
$var=false;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("CurrencyLayerAccount").'</td>'."\n";
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="100">';
print '<form id="form_sync" action="" method="POST">';
print '<input type="hidden" name="action" value="synchronize" />';
print '<textarea id="response" class="hideobject" name="response"></textarea>';
print $langs->trans("Value").'&nbsp;<input type="button" id="bt_sync" class="button" onclick="javascript:getRates();" value="'.$langs->trans('Synchronize').'" />';
print '</form>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td><a target="_blank" href="https://currencylayer.com">'.$langs->transnoentitiesnoconv("multicurrency_appId").'</a></td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_APP_ID">';
print '<input type="text" name="MULTICURRENCY_APP_ID" value="'.$conf->global->MULTICURRENCY_APP_ID.'" size="28" />&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
/* This property seems not used in code, so i comment it
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_appCurrencySource").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_APP_SOURCE">';
print '<input type="text" name="MULTICURRENCY_APP_SOURCE" value="'.$conf->global->MULTICURRENCY_APP_SOURCE.'" size="10" placeholder="USD" />&nbsp;'; // Default: USD
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_ALTERNATE_SOURCE">';
print '<input type="text" name="MULTICURRENCY_ALTERNATE_SOURCE" value="'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE.'" size="10" placeholder="EUR" />&nbsp;'; // Example: EUR
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
*/
print '</table>';
print '<br />';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
@ -287,6 +334,26 @@ foreach ($TCurrency as &$currency)
print '</table>';
print '
<script type="text/javascript">
function getRates()
{
$("#bt_sync").attr("disabled", true);
var url_sync = "http://apilayer.net/api/live?access_key='.$conf->global->MULTICURRENCY_APP_ID.'&format=1'.(!empty($conf->global->MULTICURRENCY_APP_SOURCE) ? '&source='.$conf->global->MULTICURRENCY_APP_SOURCE : '').'";
$.ajax({
url: url_sync,
dataType: "jsonp"
}).done(function(response) {
$("#response").val(JSON.stringify(response));
$("#form_sync").submit();
});
}
</script>
';
llxFooter();
$db->close();

View File

@ -911,6 +911,7 @@ if (empty($reshook))
unset($_POST['type']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
@ -1040,6 +1041,7 @@ if (empty($reshook))
unset($_POST['productid']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
@ -1325,7 +1327,7 @@ if ($action == 'create')
}
} else {
print '<td colspan="2">';
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 1);
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty');
// reload page to retrieve customer informations
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE))
{
@ -1465,7 +1467,7 @@ if ($action == 'create')
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
$currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency));
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 1);
print '</td></tr>';
}
@ -1978,9 +1980,9 @@ if ($action == 'create')
print '</tr></table>';
print '</td><td colspan="5">';
if ($action == 'editmulticurrencyrate') {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
}
print '</td></tr>';
}

View File

@ -833,6 +833,7 @@ if (empty($reshook))
unset($_POST['type']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
@ -963,6 +964,7 @@ if (empty($reshook))
unset($_POST['productid']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
@ -2205,9 +2207,9 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</tr></table>';
print '</td><td colspan="5">';
if ($action == 'editmulticurrencyrate') {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
}
print '</td></tr>';
}

View File

@ -223,7 +223,7 @@ if ($resql)
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="center">';
$form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1, 8);
$form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1);
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat" name="req_nb" value="'.dol_escape_htmltag($search_req_nb).'" size="2"></td>';
print '<td class="liste_titre">';

View File

@ -1522,6 +1522,7 @@ if (empty($reshook))
unset($_POST['type']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
@ -1682,6 +1683,7 @@ if (empty($reshook))
unset($_POST['productid']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
@ -3516,9 +3518,9 @@ else if ($id > 0 || ! empty($ref))
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editmulticurrencyrate') {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
}
print '</td></tr>';
}

View File

@ -5,6 +5,7 @@
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -214,7 +215,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
*/
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
{
$sql = "SELECT f.ref, f.rowid, f.total_ht, f.tva as total_tva, f.total_ttc, f.type";
$sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type";
$sql.= ", s.nom as name";
$sql.= ", s.rowid as socid";
$sql.= ", s.code_fournisseur";

View File

@ -563,6 +563,18 @@ class Paiement extends CommonObject
}
}
// Add link 'WithdrawalPayment' in bank_url
if (! $error && $label == '(WithdrawalPayment)')
{
$result=$acc->add_url_line(
$bank_line_id,
$this->id_prelevement,
DOL_URL_ROOT.'/compta/prelevement/card.php?id=',
$this->num_paiement,
'withdraw'
);
}
if (! $error && ! $notrigger)
{
// Appel des triggers

View File

@ -462,6 +462,7 @@ class BonPrelevement extends CommonObject
$paiement->amounts = $amounts;
$paiement->paiementid = 3; //
$paiement->num_paiement = $this->ref ;
$paiement->id_prelevement = $this->id ;
$paiement_id = $paiement->create($user);
if ($paiement_id < 0)

View File

@ -621,6 +621,7 @@ if (empty($reshook))
unset($_POST['type']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);

View File

@ -902,7 +902,7 @@ class Form
* @param string $selected Preselected type
* @param string $htmlname Name of field in form
* @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)')
* @param string $showempty Add an empty field (Can be '1' or text to use on empty line like 'SelectThirdParty')
* @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty')
* @param int $showtype Show third party type in combolist (customer, prospect or supplier)
* @param int $forcecombo Force to use combo box
* @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
@ -3779,7 +3779,7 @@ class Form
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
print '<tr><td>';
print $this->selectMultiCurrency($selected,$htmlname);
print $this->selectMultiCurrency($selected, $htmlname, 1);
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
@ -3797,11 +3797,13 @@ class Form
* @param string $page Page
* @param double $rate Current rate
* @param string $htmlname Name of select html field
* @param string $currency Currency code to explain the rate
* @return void
*/
function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx')
function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx', $currency='')
{
global $langs;
global $langs, $mysoc, $conf;
if ($htmlname != "none")
{
print '<form method="POST" action="'.$page.'">';
@ -3816,7 +3818,15 @@ class Form
}
else
{
print !empty($rate) ? price(price2num($rate), 1, $langs) : 1;
if (! empty($rate))
{
print price($rate, 1, $langs, 1, 0);
if ($currency && $rate != 1) print ' &nbsp; ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')';
}
else
{
print 1;
}
}
}
@ -4030,17 +4040,17 @@ class Form
* @param integer $useempty 1=Add empty line
* @return string
*/
function selectMultiCurrency($selected='',$htmlname='multicurrency_code', $useempty=0)
function selectMultiCurrency($selected='', $htmlname='multicurrency_code', $useempty=0)
{
global $db,$conf,$langs,$user;
$langs->loadCacheCurrencies('');
$langs->loadCacheCurrencies(''); // Load ->cache_currencies
$TCurrency = array();
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
$sql.= " WHERE entity IN ('".getEntity('mutlicurrency')."')";
$resql = $db->query($sql);
if ($resql)
{
while ($obj = $db->fetch_object($resql)) $TCurrency[$obj->code] = $obj->code;
@ -4048,14 +4058,14 @@ class Form
$out='';
$out.= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($useempty) $out .= '<option value="">&nbsp;</option>';
if ($useempty) $out .= '<option value="'.$conf->currency.'"'.((empty($selected) || $selected == $conf->currency)?' selected="selected"':'').'>'.$langs->cache_currencies[$conf->currency]['label'].'</option>';
if (count($TCurrency) > 0)
{
foreach ($langs->cache_currencies as $code_iso => $currency)
{
if (isset($TCurrency[$code_iso]))
{
if (!empty($selected) && $selected == $code_iso) $out.= '<option value="'.$code_iso.'" selected>';
if (!empty($selected) && $selected == $code_iso) $out.= '<option value="'.$code_iso.'" selected="selected">';
else $out.= '<option value="'.$code_iso.'">';
$out.= $currency['label'];
@ -4063,6 +4073,7 @@ class Form
$out.= '</option>';
}
}
}
$out.= '</select>';

View File

@ -334,7 +334,7 @@ class FormMail extends Form
$out.= ' &nbsp; ';
$out.= '</div>';
}
$out.= '<table class="border" width="100%">'."\n";
@ -876,13 +876,13 @@ class FormMail extends Form
{
$ret=array();
$sql = "SELECT rowid, label, topic, content, lang";
$sql = "SELECT rowid, label, topic, content, lang, position";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
$sql.= " WHERE type_template='".$this->db->escape($type_template)."'";
$sql.= " AND entity IN (".getEntity("c_email_templates").")";
$sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")";
if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
$sql.= $this->db->order("lang,label","ASC");
$sql.= $this->db->order("position,lang,label","ASC");
//print $sql;
$resql = $this->db->query($sql);
@ -896,7 +896,7 @@ class FormMail extends Form
$line->id=$obj->rowid;
$line->label=$obj->label;
$line->topic=$obj->topic;
$line->content=$obj->lacontentbel;
$line->content=$obj->content;
$line->lang=$obj->lang;
$this->lines_model[]=$line;
}

View File

@ -188,7 +188,7 @@ class FormProjets
continue;
}
$labeltoshow=dol_trunc($obj->ref,18).' - '.$obj->title;
$labeltoshow=dol_trunc($obj->ref,18);
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$labeltoshow.=' '.dol_trunc($obj->title,$maxlength);

View File

@ -1040,6 +1040,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$langs->load("withdrawals");
$langs->load("banks");
$langs->load("bills");
$langs->load('categories');
// Bank-Caisse
if (! empty($conf->banque->enabled))

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012-2016 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,6 +49,7 @@ class ImportCsv extends ModeleImports
var $separator;
var $file; // Path of file
var $handle; // Handle fichier
var $cacheconvert=array(); // Array to cache list of value found after a convertion
@ -85,76 +86,6 @@ class ImportCsv extends ModeleImports
if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db);
}
/**
* getDriverId
*
* @return string Id
*/
function getDriverId()
{
return $this->id;
}
/**
* getDriverLabel
*
* @return string Label
*/
function getDriverLabel()
{
return $this->label;
}
/**
* getDriverDesc
*
* @return string Description
*/
function getDriverDesc()
{
return $this->desc;
}
/**
* getDriverExtension
*
* @return string Driver suffix
*/
function getDriverExtension()
{
return $this->extension;
}
/**
* getDriverVersion
*
* @return string Driver version
*/
function getDriverVersion()
{
return $this->version;
}
/**
* getDriverLabel
*
* @return string Label of external lib
*/
function getLibLabel()
{
return $this->label_lib;
}
/**
* getLibVersion
*
* @return string Version of external lib
*/
function getLibVersion()
{
return $this->version_lib;
}
/**
* Output header of an example file for this format
@ -236,6 +167,19 @@ class ImportCsv extends ModeleImports
return $ret;
}
/**
* Return nb of records. File must be closed.
*
* @param string $file Path of filename
* @return int <0 if KO, >=0 if OK
*/
function import_get_nb_of_lines($file)
{
return dol_count_nb_of_line($file);
}
/**
* Input header line from file
*
@ -319,7 +263,7 @@ class ImportCsv extends ModeleImports
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]...
* @param Object $objimport Object import (contains objimport->import_tables_array, objimport->import_fields_array, objimport->import_convertvalue_array, ...)
* @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...)
* @param int $maxfields Max number of fields to use
* @param string $importid Import key
* @return int <0 if KO, >0 if OK
@ -401,7 +345,7 @@ class ImportCsv extends ModeleImports
// Make some tests on $newval
// Is it a required field ?
if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ($newval==''))
if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval==''))
{
$this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key);
$this->errors[$error]['type']='NOTNULL';
@ -420,7 +364,13 @@ class ImportCsv extends ModeleImports
|| $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel'
)
{
if (! is_numeric($newval) && $newval != '') // If value into input import file is not a numeric, we apply the function defined into descriptor
// New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess.
$isidorref='id';
if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) $isidorref='ref';
$newval=preg_replace('/^(id|ref):/i','',$newval); // Remove id: or ref: that was used to force if field is id or ref
//print 'Val is now '.$newval.' and is type '.$isidorref."<br>\n";
if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor
{
$file=$objimport->array_import_convertvalue[0][$val]['classfile'];
$class=$objimport->array_import_convertvalue[0][$val]['class'];

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012-2016 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,6 +49,7 @@ class Importxlsx extends ModeleImports
var $separator;
var $file; // Path of file
var $handle; // Handle fichier
var $cacheconvert=array(); // Array to cache list of value found after a convertion
@ -72,100 +73,29 @@ class Importxlsx extends ModeleImports
// this is used as an extension from the example file code, so we have to put xlsx here !!!
$this->id='xlsx'; // Same value as xxx in file name export_xxx.modules.php
$this->label='Excel'; // Label of driver
$this->desc=$langs->trans("ExcelFormatDesc",$this->separator,$this->enclosure,$this->escape);
$this->label='Excel 2007'; // Label of driver
$this->desc=$langs->trans("Excel2007FormatDesc");
$this->extension='xlsx'; // Extension for generated file by this driver
$this->picto='mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...)
$this->version='1.0'; // Driver version
// If driver use an external library, put its name here
require_once PHPEXCEL_PATH.'PHPExcel.php';
require_once PHPEXCEL_PATH.'PHPExcel.php';
require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive
{
if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive
{
$langs->load("errors");
$this->error=$langs->trans('ErrorPHPNeedModule','zip');
return -1;
}
$this->label_lib='PhpExcel';
$this->version_lib='1.8.0';
}
$this->label_lib='PhpExcel';
$this->version_lib='1.8.0';
$this->datatoimport=$datatoimport;
if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db);
}
// Those Get methods should all be in the parent class !!!
/**
* getDriverId
*
* @return string Id
*/
function getDriverId()
{
return $this->id;
}
/**
* getDriverLabel
*
* @return string Label
*/
function getDriverLabel()
{
return $this->label;
}
/**
* getDriverDesc
*
* @return string Description
*/
function getDriverDesc()
{
return $this->desc;
}
/**
* getDriverExtension
*
* @return string Driver suffix
*/
function getDriverExtension()
{
return $this->extension;
}
/**
* getDriverVersion
*
* @return string Driver version
*/
function getDriverVersion()
{
return $this->version;
}
/**
* getDriverLabel
*
* @return string Label of external lib
*/
function getLibLabel()
{
return $this->label_lib;
}
/**
* getLibVersion
*
* @return string Version of external lib
*/
function getLibVersion()
{
return $this->version_lib;
}
/**
* Output header of an example file for this format
*
@ -276,9 +206,32 @@ class Importxlsx extends ModeleImports
$reader = new PHPExcel_Reader_Excel2007();
$this->workbook = $reader->load($file);
$this->record = 1;
$this->file = $file;
return $ret;
}
/**
* Return nb of records. File must be closed.
*
* @param string $file Path of filename
* @return int <0 if KO, >=0 if OK
*/
function import_get_nb_of_lines($file)
{
$reader = new PHPExcel_Reader_Excel2007();
$this->workbook = $reader->load($file);
$rowcount = $this->workbook->getActiveSheet()->getHighestDataRow();
$this->workbook->disconnectWorksheets();
unset($this->workbook);
return $rowcount;
}
/**
* Input header line from file
*
@ -336,7 +289,7 @@ class Importxlsx extends ModeleImports
*
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
* @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]...
* @param Object $objimport Object import (contains objimport->import_tables_array, objimport->import_fields_array, objimport->import_convertvalue_array, ...)
* @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...)
* @param int $maxfields Max number of fields to use
* @param string $importid Import key
* @return int <0 if KO, >0 if OK
@ -419,7 +372,7 @@ class Importxlsx extends ModeleImports
// Make some tests on $newval
// Is it a required field ?
if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ($newval==''))
if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval == ''))
{
$this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key);
$this->errors[$error]['type']='NOTNULL';
@ -438,7 +391,13 @@ class Importxlsx extends ModeleImports
|| $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel'
)
{
if (! is_numeric($newval) && $newval != '') // If value into input import file is not a numeric, we apply the function defined into descriptor
// New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess.
$isidorref='id';
if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) $isidorref='ref';
$newval=preg_replace('/^(id|ref):/i','',$newval); // Remove id: or ref: that was used to force if field is id or ref
//print 'Val is now '.$newval.' and is type '.$isidorref."<br>\n";
if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor
{
$file=$objimport->array_import_convertvalue[0][$val]['classfile'];
$class=$objimport->array_import_convertvalue[0][$val]['class'];
@ -645,7 +604,8 @@ class Importxlsx extends ModeleImports
}
if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$user->id;
$sql.=')';
print($sql);
//print($sql).'<br>';
dol_syslog("import_csv.modules", LOG_DEBUG);
//print '> '.join(',',$arrayrecord);

View File

@ -59,6 +59,78 @@ class ModeleImports
{
}
/**
* getDriverId
*
* @return string Id
*/
function getDriverId()
{
return $this->id;
}
/**
* getDriverLabel
*
* @return string Label
*/
function getDriverLabel()
{
return $this->label;
}
/**
* getDriverDesc
*
* @return string Description
*/
function getDriverDesc()
{
return $this->desc;
}
/**
* getDriverExtension
*
* @return string Driver suffix
*/
function getDriverExtension()
{
return $this->extension;
}
/**
* getDriverVersion
*
* @return string Driver version
*/
function getDriverVersion()
{
return $this->version;
}
/**
* getDriverLabel
*
* @return string Label of external lib
*/
function getLibLabel()
{
return $this->label_lib;
}
/**
* getLibVersion
*
* @return string Version of external lib
*/
function getLibVersion()
{
return $this->version_lib;
}
/**
* Charge en memoire et renvoie la liste des modeles actifs
*

View File

@ -45,6 +45,7 @@ class modCategorie extends DolibarrModules
$this->numero = 1780;
$this->family = "technic";
$this->module_position = 20;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Gestion des categories (produits, clients, fournisseurs...)";
@ -53,7 +54,7 @@ class modCategorie extends DolibarrModules
$this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 2;
$this->special = 0;
$this->picto = 'category';
// Data directories to create when module is enabled

View File

@ -45,7 +45,7 @@ class modDocumentGeneration extends DolibarrModules
$this->numero = 1520;
$this->family = "technic";
$this->module_position = 10000;
$this->module_position = 80;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Direct mail document generation";

View File

@ -44,7 +44,7 @@ class modExport extends DolibarrModules
$this->numero = 240;
$this->family = "technic";
$this->module_position = 520;
$this->module_position = 72;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Outils d'exports de donnees Dolibarr (via un assistant)";

View File

@ -45,6 +45,7 @@ class modFckeditor extends DolibarrModules
$this->numero = 2000;
$this->family = "technic";
$this->module_position = 20;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Editeur WYSIWYG";

View File

@ -44,7 +44,7 @@ class modImport extends DolibarrModules
$this->numero = 250;
$this->family = "technic";
$this->module_position = 510;
$this->module_position = 70;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Outils d'imports de donnees Dolibarr (via un assistant)";

View File

@ -44,6 +44,7 @@ class modLabel extends DolibarrModules
$this->numero = 60;
$this->family = "technic";
$this->module_position = 80;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Gestion des etiquettes";

View File

@ -52,9 +52,9 @@ class modMultiCurrency extends DolibarrModules
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "financial";
$this->family = "technic";
// Module position in the family
$this->module_position = 555;
$this->module_position = 40;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));

View File

@ -194,8 +194,12 @@ class modStock extends DolibarrModules
$this->import_convertvalue_array[$r]=array(
'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'),
'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label')
);
$this->import_examplevalues_array[$r]=array(
'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10"
);
$this->import_examplevalues_array[$r]=array('ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10"
$this->import_run_sql_after_array[$r]=array( // Because we may change data that are denormalized, we must update dernormalized data after.
'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);'
);
}

View File

@ -46,7 +46,7 @@ class modWebsites extends DolibarrModules
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "portal";
$this->module_position = 20;
$this->module_position = 50;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Enable the public website with CMS features";

View File

@ -145,6 +145,10 @@ class mod_syslog_sentry extends LogHandler implements LogHandlerInterface
*/
public function export($content)
{
if (! $this->isActive()) {
return;
}
global $conf;
$dsn = $conf->global->SYSLOG_SENTRY_DSN;
$client = new Raven_Client(

View File

@ -32,7 +32,7 @@
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande')))
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande')))
{
$usemargins=1;
}
@ -196,11 +196,17 @@ else {
{
$parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int'));
$reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
if (!empty($hookmanager->resPrint)) {
print $hookmanager->resPrint;
}
}
if (is_object($hookmanager) && ! empty($senderissupplier))
{
$parameters=array('htmlname'=>'addproduct');
$reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action);
if (!empty($hookmanager->resPrint)) {
print $hookmanager->resPrint;
}
}
@ -429,18 +435,12 @@ if (! empty($usemargins) && $user->rights->margins->creer)
jQuery(document).ready(function() {
<?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
$('#addline').click(function (e) {
return checkFreeLine(e, "np_marginRate");
});
$("input[name='np_marginRate']:first").blur(function(e) {
return checkFreeLine(e, "np_marginRate");
});
<?php
}
if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
$('#addline').click(function (e) {
return checkFreeLine(e, "np_markRate");
});
$("input[name='np_markRate']:first").blur(function(e) {
return checkFreeLine(e, "np_markRate");
});
@ -506,7 +506,7 @@ jQuery(document).ready(function() {
$("#select_type").change(function()
{
setforfree();
if (jQuery('#select_type').val() >= 0)
if (jQuery('#select_type').val() >= 0)
{
/* focus work on a standard textarea but not if field was replaced with CKEDITOR */
jQuery('#dp_desc').focus();
@ -645,7 +645,7 @@ jQuery(document).ready(function() {
?>
/* To set focus */
if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0)
if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0)
{
/* focus work on a standard textarea but not if field was replaced with CKEDITOR */
jQuery('#dp_desc').focus();

View File

@ -329,9 +329,6 @@ if (! empty($conf->margin->enabled))
if (! empty($conf->global->DISPLAY_MARGIN_RATES) && !empty($conf->global->MARGIN_RESET_HT_FROM_MARGIN_FIELD))
{
?>
$('#savelinebutton').click(function (e) {
return checkEditLine(e, "np_marginRate");
});
/* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'.
$("input[name='np_marginRate']:first").blur(function(e) {
return checkEditLine(e, "np_marginRate");
@ -341,9 +338,6 @@ if (! empty($conf->margin->enabled))
if (! empty($conf->global->DISPLAY_MARK_RATES) && !empty($conf->global->MARGIN_RESET_HT_FROM_MARGIN_FIELD))
{
?>
$('#savelinebutton').click(function (e) {
return checkEditLine(e, "np_markRate");
});
/* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'.
$("input[name='np_markRate']:first").blur(function(e) {
return checkEditLine(e, "np_markRate");
@ -356,6 +350,7 @@ if (! empty($conf->margin->enabled))
/* If margin rate field empty, do nothing. */
/* Force content of price_ht to 0 or if a discount is set, recalculate it from margin rate */
/* TODO This function seems no more used */
function checkEditLine(e, npRate)
{
var buying_price = $("input[name='buying_price']:first");

View File

@ -707,7 +707,7 @@ class ProductFournisseur extends Product
{
global $langs;
$langs->load("suppliers");
$out=($showunitprice?price($this->fourn_unitprice).' '.$langs->trans("HT").' &nbsp; (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':'');
$out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").' &nbsp; (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':'');
return $out;
}

View File

@ -472,6 +472,7 @@ if (empty($reshook))
unset($_POST['remise_percent']);
unset($_POST['pu']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['label']);
@ -2027,9 +2028,9 @@ elseif (! empty($object->id))
print '</tr></table>';
print '</td><td colspan="5">';
if ($action == 'editmulticurrencyrate') {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
}
print '</td></tr>';
}

View File

@ -243,7 +243,7 @@ if (! empty($conf->fournisseur->enabled))
/*
* List of users allowed
*/
$sql = "SELECT u.rowid, u.lastname, u.firstname";
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.email";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u,";
$sql.= " ".MAIN_DB_PREFIX."user_rights as ur";
$sql.= ", ".MAIN_DB_PREFIX."rights_def as rd";
@ -276,6 +276,7 @@ if ($resql)
$userstatic->id=$obj->rowid;
$userstatic->lastname=$obj->lastname;
$userstatic->firstname=$obj->firstname;
$userstatic->email=$obj->email;
print $userstatic->getNomUrl(1);
print '</td>';
print "</tr>\n";

View File

@ -830,6 +830,7 @@ if (empty($reshook))
unset($_POST['remise_percent']);
unset($_POST['pu']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['label']);
@ -2053,9 +2054,9 @@ else
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editmulticurrencyrate') {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
}
print '</td></tr>';
}
@ -2350,7 +2351,11 @@ else
// Delete
if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
if ($object->getSommePaiement()) {
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecausePayments") . '">' . $langs->trans('Delete') . '</a></div>';
} else {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
}
print '</div>';
print '<br>';

View File

@ -345,7 +345,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<input type="hidden" name="socid" value="'.$obj->socid.'">';
print '<input type="hidden" name="societe" value="'.$obj->name.'">';
dol_fiche_head('');
dol_fiche_head(null);
print '<table class="border" width="100%">';
@ -377,6 +377,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '</table>';
dol_fiche_end();
$parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas);
$reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
@ -527,10 +528,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$preselectedchoice=$addwarning?'no':'yes';
print '<br>';
if (!empty($totalpayment)) $text=$langs->trans('ConfirmSupplierPayment',$totalpayment,$langs->trans("Currency".$conf->currency));
if (!empty($totalpayment)) $text=$langs->trans('ConfirmSupplierPayment',price($totalpayment),$langs->trans("Currency".$conf->currency));
if (!empty($multicurrency_totalpayment))
{
$text.='<br />'.$langs->trans('ConfirmSupplierPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency"));
$text.='<br>'.$langs->trans('ConfirmSupplierPayment',price($multicurrency_totalpayment),$langs->trans("paymentInInvoiceCurrency"));
}
if (GETPOST('closepaidinvoices'))
{

View File

@ -33,12 +33,18 @@ class Import
var $array_import_code;
var $array_import_label;
var $array_import_tables;
var $array_import_tables_creator;
var $array_import_fields;
var $array_import_fieldshidden;
var $array_import_entities;
var $array_import_regex;
var $array_import_examplevalues;
var $array_import_convertvalue;
var $array_import_run_sql_after;
var $error;
var $errors;
/**
* Constructor
@ -137,7 +143,7 @@ class Import
$this->array_import_label[$i]=$module->getImportDatasetLabel($r);
// Array of tables to import (key=alias, value=tablename)
$this->array_import_tables[$i]=$module->import_tables_array[$r];
// Array of tables creator field to import (key=alias, value=creator field)
// Array of tables creator field to import (key=alias, value=creator field name)
$this->array_import_tables_creator[$i]=(isset($module->import_tables_creator_array[$r])?$module->import_tables_creator_array[$r]:'');
// Array of fields to import (key=field, value=label)
$this->array_import_fields[$i]=$module->import_fields_array[$r];
@ -151,6 +157,8 @@ class Import
$this->array_import_examplevalues[$i]=$module->import_examplevalues_array[$r];
// Tableau des regles de conversion d'une valeur depuis une autre source (cle=champ, valeur=tableau des regles)
$this->array_import_convertvalue[$i]=(isset($module->import_convertvalue_array[$r])?$module->import_convertvalue_array[$r]:'');
// Sql request to run after import
$this->array_import_run_sql_after[$i]=(isset($module->import_run_sql_after_array[$r])?$module->import_run_sql_after_array[$r]:'');
// Module
$this->array_import_module[$i]=$module;

View File

@ -1142,6 +1142,7 @@ if ($step == 5 && $datatoimport)
// Load source fields in input file
$fieldssource=array();
$result=$obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport,$langs);
if ($result >= 0)
{
// Read first line
@ -1156,8 +1157,7 @@ if ($step == 5 && $datatoimport)
$obj->import_close_file();
}
// TODO, remove this, since it only works for csv
$nboflines=dol_count_nb_of_line($conf->import->dir_temp.'/'.$filetoimport);
$nboflines=$obj->import_get_nb_of_lines($conf->import->dir_temp.'/'.$filetoimport);
$param='&leftmenu=import&format='.$format.'&datatoimport='.$datatoimport.'&filetoimport='.urlencode($filetoimport).'&nboflines='.$nboflines.'&separator='.urlencode($separator).'&enclosure='.urlencode($enclosure);
$param2 = $param; // $param2 = $param without excludefirstline and endatlinenb
@ -1415,6 +1415,25 @@ if ($step == 5 && $datatoimport)
print $langs->trans("ErrorFailedToOpenFile",$pathfile);
}
$error=0;
// Run the sql after import if defined
//var_dump($objimport->array_import_run_sql_after[0]);
if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
{
$i=0;
foreach($objimport->array_import_run_sql_after[0] as $sqlafterimport)
{
$i++;
$resqlafterimport=$db->query($sqlafterimport);
if (! $resqlafterimport)
{
$arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport));
$error++;
}
}
}
$db->rollback(); // We force rollback because this was just a simulation.
// Show OK
@ -1740,8 +1759,31 @@ if ($step == 6 && $datatoimport)
}
if (count($arrayoferrors) > 0) $db->rollback(); // We force rollback because this was errors.
else $db->commit(); // We can commit if no errors.
else
{
$error=0;
// Run the sql after import if defined
//var_dump($objimport->array_import_run_sql_after[0]);
if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
{
$i=0;
foreach($objimport->array_import_run_sql_after[0] as $sqlafterimport)
{
$i++;
$resqlafterimport=$db->query($sqlafterimport);
if (! $resqlafterimport)
{
$arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport));
$error++;
}
}
}
if (! $error) $db->commit(); // We can commit if no errors.
else $db->rollback();
}
dol_fiche_end();

View File

@ -2217,7 +2217,7 @@ class soap_transport_http extends nusoap_base {
}
$this->use_curl = $use_curl;
preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
if (isset($rev[1])) $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
$this->setHeader('User-Agent', $this->title.'/'.$this->version.(isset($rev[1])?' ('.$rev[1].')':''));
}
/**

View File

@ -190,8 +190,7 @@ CREATE TABLE llx_multicurrency_rate
rowid integer AUTO_INCREMENT PRIMARY KEY,
date_sync datetime DEFAULT NULL,
rate double NOT NULL DEFAULT 0,
fk_multicurrency integer NOT NULL,
entity integer NOT NULL DEFAULT 1
fk_multicurrency integer NOT NULL
) ENGINE=innodb;
ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer;
@ -383,3 +382,4 @@ ALTER TABLE llx_product_fournisseur_price ADD supplier_reputation varchar(10) NU
-- Delete old deprecated field
ALTER TABLE llx_product_stock DROP COLUMN pmp;
ALTER TABLE llx_societe ADD COLUMN fk_shipping_method_id integer;

View File

@ -22,6 +22,5 @@ CREATE TABLE llx_multicurrency_rate
rowid integer AUTO_INCREMENT PRIMARY KEY,
date_sync datetime DEFAULT NULL,
rate double NOT NULL DEFAULT 0,
fk_multicurrency integer NOT NULL,
entity integer DEFAULT 1
fk_multicurrency integer NOT NULL
) ENGINE=innodb;

View File

@ -103,5 +103,6 @@ create table llx_societe
webservices_key varchar(128), -- supplier webservice key
fk_multicurrency integer,
multicurrency_code varchar(255)
multicurrency_code varchar(255),
fk_shipping_method_id integer
)ENGINE=innodb;

View File

@ -99,6 +99,7 @@ AntiVirusParamExample= Example for ClamWin: --database="C:\Program Files (x86)\C
ComptaSetup=Accounting module setup
UserSetup=User management setup
MenuSetup=Menu management setup
MultiCurrencySetup=Multi-currency setup
MenuLimits=Limits and accuracy
MenuIdParent=Parent menu ID
DetailMenuIdParent=ID of parent menu (empty for a top menu)

View File

@ -5,7 +5,7 @@ PrinterUpdated=Printer %s updated
PrinterDeleted=Printer %s deleted
TestSentToPrinter=Test Sent To Printer %s
ReceiptPrinter=Receipt printers
ReceiptPrinterDesc=Setup of printers
ReceiptPrinterDesc=Setup of receipt printers
ReceiptPrinterTemplateDesc=Setup of Templates
ReceiptPrinterTypeDesc=Description of Receipt Printer's type
ReceiptPrinterProfileDesc=Description of Receipt Printer's Profile

View File

@ -1033,13 +1033,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui.css'.($ext?'?'.$ext:'').'">'."\n"; // JQuery
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/tiptip/tipTip.css'.($ext?'?'.$ext:'').'">'."\n"; // Tooltip
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css'.($ext?'?'.$ext:'').'">'."\n"; // JNotify
/*if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) || (defined('REQUIRE_JQUERY_FILEUPLOAD') && constant('REQUIRE_JQUERY_FILEUPLOAD'))) // jQuery fileupload
{
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/css/jquery.fileupload-ui.css'.($ext?'?'.$ext:'').'">'."\n";
}*/
if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES) || (defined('REQUIRE_JQUERY_DATATABLES') && constant('REQUIRE_JQUERY_DATATABLES'))) // jQuery datatables
{
//print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/css/jquery.dataTables.css'.($ext?'?'.$ext:'').'">'."\n";
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/media/css/jquery.dataTables.min.css'.($ext?'?'.$ext:'').'">'."\n";
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extensions/Buttons/css/buttons.dataTables.min.css'.($ext?'?'.$ext:'').'">'."\n";
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extensions/ColReorder/css/colReorder.dataTables.min.css'.($ext?'?'.$ext:'').'"></script>'."\n";
@ -1131,11 +1126,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd.0.6.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tiptip/jquery.tipTip.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
// jQuery Layout
if (empty($conf->dol_use_jmobile) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) || defined('REQUIRE_JQUERY_LAYOUT'))
{
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/layout/jquery.layout.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
}
// jQuery jnotify
if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY'))
{
@ -1374,60 +1364,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
if ($conf->use_javascript_ajax)
{
if (empty($conf->dol_use_jmobile) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))
{
print '<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("body").layout(layoutSettings);
});
var layoutSettings = {
name: "mainlayout",
defaults: {
useStateCookie: true,
size: "auto",
resizable: false,
//paneClass: "none",
//resizerClass: "resizer",
//togglerClass: "toggler",
//buttonClass: "button",
//contentSelector: ".content",
//contentIgnoreSelector: "span",
togglerTip_open: "Close This Pane",
togglerTip_closed: "Open This Pane",
resizerTip: "Resize This Pane",
fxSpeed: "fast"
},
west: {
paneClass: "leftContent",
//spacing_closed: 14,
//togglerLength_closed: 14,
//togglerAlign_closed: "auto",
//togglerLength_open: 0,
// effect defaults - overridden on some panes
//slideTrigger_open: "mouseover",
initClosed: '.(empty($conf->dol_optimize_smallscreen)?'false':'true').',
fxName: "drop",
fxSpeed: "fast",
fxSettings: { easing: "" }
},
north: {
paneClass: "none",
resizerClass: "none",
togglerClass: "none",
spacing_open: 0,
togglerLength_open: 0,
togglerLength_closed: -1,
slidable: false,
fxName: "none",
fxSpeed: "fast"
},
center: {
paneSelector: "#mainContent"
}
}
</script>' . "\n";
}
// Raven.js for client-side Sentry logging support
if (array_key_exists('mod_syslog_sentry', $conf->loghandlers) && ! empty($conf->global->SYSLOG_SENTRY_DSN))
{
@ -1448,8 +1384,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
*/
print "\n".'<!-- Start top horizontal -->'."\n";
if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '<div class="ui-layout-north"> <!-- Begin top layout -->'."\n";
if (empty($conf->dol_hide_topmenu))
{
print '<div class="side-nav-vert"><div id="id-top">';
@ -1579,11 +1513,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
//unset($form);
}
if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "</div><!-- End top layout -->\n";
print '<div style="clear: both;"></div>';
print "<!-- End top horizontal menu -->\n\n";
if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '<div id="id-container">';
if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '<div id="id-container">';
}
@ -1616,8 +1549,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra
// Instantiate hooks of thirdparty module
$hookmanager->initHooks(array('searchform','leftblock'));
if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n".'<!-- Begin left layout -->'."\n".'<div class="ui-layout-west">'."\n";
else print "\n".'<!-- Begin id-left -->'."\n".'<div class="side-nav"><div id="id-left">'."\n";
print "\n".'<!-- Begin id-left -->'."\n".'<div class="side-nav"><div id="id-left">'."\n";
print "\n";
@ -1779,8 +1711,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra
$reshook=$hookmanager->executeHooks('printLeftBlock',$parameters); // Note that $action and $object may have been modified by some hooks
print $hookmanager->resPrint;
if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '</div> <!-- End left layout -->'."\n";
else print '</div></div> <!-- end id-left -->'; // End div id="id-left"
print '</div></div> <!-- end id-left -->'; // End div id="id-left"
}
print "\n";
@ -1800,7 +1731,6 @@ function main_area($title='')
{
global $conf, $langs;
if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '<div id="mainContent"><div class="ui-layout-center"> <!-- begin main layout -->'."\n";
if (empty($conf->dol_hide_leftmenu)) print '<div id="id-right">';
print "\n";
@ -1944,7 +1874,6 @@ if (! function_exists("llxFooter"))
print '</div> <!-- End div class="fiche" -->'."\n";
if (! empty($conf->dol_use_jmobile)) print '</div>'; // end data-role="page"
if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '</div></div> <!-- end main layout -->'."\n";
if (empty($conf->dol_hide_leftmenu)) print '</div> <!-- End div id-right -->'; // End div id-right
print "\n";
@ -1953,7 +1882,7 @@ if (! function_exists("llxFooter"))
printCommonFooter($zone);
//var_dump($langs); // Uncommment to see the property _tab_loaded to see which language file were loaded
if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '</div> <!-- End div id-container -->'."\n"; // End div container
if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '</div> <!-- End div id-container -->'."\n"; // End div container
if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent;

View File

@ -118,7 +118,7 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta
$marge_tx_ret='';
$marque_tx_ret='';
if ($fk_pa > 0) {
if ($fk_pa > 0 && empty($paht)) {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$product = new ProductFournisseur($db);
if ($product->fetch_product_fournisseur_price($fk_pa))

View File

@ -208,7 +208,7 @@ class MultiCurrency extends CommonObject
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::fetch ' . join(',', $this->errors), LOG_ERR);
return - 1;
return -1;
}
}
@ -383,7 +383,7 @@ class MultiCurrency extends CommonObject
*
* @param double $rate rate value
*
* @return bool false if KO, true if OK
* @return int -1 if KO, 1 if OK
*/
public function addRate($rate)
{
@ -402,6 +402,40 @@ class MultiCurrency extends CommonObject
}
}
/**
* Try get label of code in llx_currency then add rate
*
* @param string $code currency code
* @param double $rate new rate
*
* @return int -1 if KO, 1 if OK, 2 if label found and OK
*/
function addRateFromDolibarr($code, $rate)
{
global $db, $user;
$currency = new MultiCurrency($db);
$currency->code = $code;
$currency->name = $code;
$sql = 'SELECT label FROM '.MAIN_DB_PREFIX.'c_currencies WHERE code_iso = "'.$db->escape($code).'"';
$resql = $db->query($sql);
if ($resql && ($line = $db->fetch_object($resql)))
{
$currency->name = $line->label;
}
if ($currency->create($user) > 0)
{
$currency->addRate($rate);
if (!empty($line)) return 2;
else return 1;
}
return -1;
}
/**
* Update rate in database
*
@ -471,7 +505,9 @@ class MultiCurrency extends CommonObject
{
$sql = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)';
// FIXME Is this comptible with SQL ?
$sql.= ' WHERE m.code = "'.$db->escape($code).'" AND mc.date_sync >= ALL (SELECT date_sync FROM '.MAIN_DB_PREFIX.'multicurrency_rate)';
$sql.= " AND m.entity IN '".getEntity('multicurrency', 1)."'";
$resql = $db->query($sql);
if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate);
else return array(0, 1);
@ -520,6 +556,66 @@ class MultiCurrency extends CommonObject
return false;
}
/**
* With free account we can't set source then recalcul all rates to force another source
*
* @param stdClass $TRate Object containing all currencies rates
* @return -1 if KO, 0 if nothing, 1 if OK
*/
public static function recalculRates(&$TRate)
{
global $conf;
if (!empty($conf->global->MULTICURRENCY_ALTERNATE_SOURCE))
{
$alternate_source = 'USD'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE;
if (!empty($TRate->{$alternate_source}))
{
$coef = $TRate->USDUSD / $TRate->{$alternate_source};
foreach ($TRate as $attr => &$rate)
{
$rate *= $coef;
}
return 1;
}
return -1; // Alternate souce not found
}
return 0; // Nothing to do
}
/**
* Sync rates from api
*
* @param array $response array of reponse from api to sync dolibarr rates
*/
public static function syncRates($response)
{
global $db,$conf;
$TRate = $response->quotes;
$timestamp = $response->timestamp;
if (self::recalculRates($TRate) >= 0)
{
foreach ($TRate as $currency_code => $rate)
{
$code = substr($currency_code, 3, 3);
$obj = new MultiCurrency($db);
if ($obj->fetch(null, $code) > 0)
{
$obj->updateRate($rate);
}
else
{
self::addRateFromDolibarr($code, $rate);
}
}
}
}
}
/**
@ -713,7 +809,7 @@ class CurrencyRate extends CommonObjectLine
if ($error) {
$this->db->rollback();
return - 1 * $error;
return -1 * $error;
} else {
$this->db->commit();

View File

@ -361,7 +361,7 @@ if ($id > 0 || ! empty($ref))
}
print '</td>';
$totalline=price2num($value['nb'] * $product_fourn->fourn_unitprice, 'MT');
$totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT');
$total+=$totalline;
print '<td align="right">';
print ($notdefined?'':($value['nb']> 1 ? $value['nb'].'x' : '').price($product_fourn->fourn_unitprice,'','',0,0,-1,$conf->currency));

View File

@ -407,8 +407,7 @@ $langs->load("orders");
$langs->load("proposals");
$langs->load("margins");
//print load_fiche_titre($langs->trans("Profit"),'','title_accountancy');
print '<div class="center">'.img_picto("", "title_accountancy").' '.$langs->trans("Profit").'</div><br>';
print load_fiche_titre($langs->trans("Profit"), '', 'title_accountancy');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';

View File

@ -1903,7 +1903,7 @@ else
'name' => 'soc_origin',
'label' => $langs->trans('MergeOriginThirdparty'),
'type' => 'other',
'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 1, 0, 0, array(), 0, 'minwidth200')
'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200')
)
);

View File

@ -717,6 +717,7 @@ if (empty($reshook))
unset($_POST['type']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
@ -841,6 +842,7 @@ if (empty($reshook))
unset($_POST['productid']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
@ -1089,7 +1091,7 @@ if ($action == 'create')
print '<table class="border" width="100%">';
// Reference
print '<tr><td class="fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>';
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>';
// Third party
print '<tr>';
@ -1419,7 +1421,7 @@ if ($action == 'create')
$linkback = '<a href="' . DOL_URL_ROOT . '/supplier_proposal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
// Ref
print '<tr><td>' . $langs->trans('Ref') . '</td><td colspan="5">';
print '<tr><td class="titlefield">' . $langs->trans('Ref') . '</td><td colspan="5">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print '</td></tr>';
@ -1469,7 +1471,7 @@ if ($action == 'create')
// Payment mode
print '<tr>';
print '<td width="25%">';
print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
@ -1519,18 +1521,18 @@ if ($action == 'create')
}
// Multicurrency
if (! empty($conf->multicurrency->enabled))
if ( empty($conf->multicurrency->enabled))
{
// Multicurrency code
print '<tr>';
print '<td width="25%">';
print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print fieldLabel('Currency','multicurrency_code');
print '</td>';
if ($action != 'editmulticurrencycode' && ! empty($object->brouillon))
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
print '</tr></table>';
print '</td><td colspan="5">';
print '</td><td colspan="3">';
if ($action == 'editmulticurrencycode') {
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code');
} else {
@ -1540,18 +1542,18 @@ if ($action == 'create')
// Multicurrency rate
print '<tr>';
print '<td width="25%">';
print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print fieldLabel('Rate','multicurrency_tx');
print '</td>';
if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon))
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
print '</tr></table>';
print '</td><td colspan="5">';
print '</td><td colspan="3">';
if ($action == 'editmulticurrencyrate') {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
}
print '</td></tr>';
}
@ -1561,7 +1563,7 @@ if ($action == 'create')
// Outstanding Bill
print '<tr><td>';
print $langs->trans('OutstandingBill');
print '</td><td align=right colspan=3>';
print '</td><td align=right colspan="3">';
print price($soc->get_OutstandingBill()) . ' / ';
print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency);
print '</td>';
@ -1589,17 +1591,22 @@ if ($action == 'create')
}
// Other attributes
$cols = 3;
$cols = 2;
if (empty($conf->margin->enabled)) $cols++;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
// Amount HT
print '<tr><td height="10" width="25%">' . $langs->trans('AmountHT') . '</td>';
print '<td align="right" class="nowrap"><b>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
print '<td></td>';
print '<tr><td height="10">' . $langs->trans('AmountHT') . '</td>';
print '<td class="nowrap" colspan="'.$colspan.'"><b>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
// Margin Infos
if (! empty($conf->margin->enabled)) {
print '<td valign="top" width="50%" rowspan="4">';
$rowspan=4;
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) $rowspan++;
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) $rowspan++;
if (!empty($conf->multicurrency->enabled)) $rowspan+=3;
print '<td valign="top" rowspan="'.$rowspan.'">';
$formmargin->displayMarginInfos($object);
print '</td>';
}
@ -1607,48 +1614,48 @@ if ($action == 'create')
// Amount VAT
print '<tr><td height="10">' . $langs->trans('AmountVAT') . '</td>';
print '<td align="right" class="nowrap">' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td></td></tr>';
print '<td class="nowrap" colspan="'.$colspan.'">' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
// Amount Local Taxes
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1
{
print '<tr><td height="10">' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
print '<td align="right" class="nowrap">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td></td></tr>';
print '<td class="nowrap" colspan="'.$colspan.'">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
}
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2
{
print '<tr><td height="10">' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
print '<td align="right" class="nowrap">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td></td></tr>';
print '<td class="nowrap" colspan="'.$colspan.'">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
}
// Amount TTC
print '<tr><td height="10">' . $langs->trans('AmountTTC') . '</td>';
print '<td align="right" class="nowrap">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '<td></td></tr>';
print '<td class="nowrap" colspan="'.$colspan.'">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
if (!empty($conf->multicurrency->enabled))
{
// Multicurrency Amount HT
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '<td class="nowrap" colspan="'.$colspan.'">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '<td class="nowrap" colspan="'.$colspan.'">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '<td class="nowrap" colspan="'.$colspan.'">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Statut
print '<tr><td height="10">' . $langs->trans('Status') . '</td><td align="left" colspan="2">' . $object->getLibStatut(4) . '</td></tr>';
print '<tr><td height="10">' . $langs->trans('Status') . '</td><td align="left">' . $object->getLibStatut(4) . '</td></tr>';
print '</table><br>';

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

View File

@ -646,7 +646,7 @@ td.showDragHandle {
div.fiche {
margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:((empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'6':'20'):'24')); ?>px;
margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:($dol_hide_leftmenu?'6':'20')); ?>px;
margin-<?php print $right; ?>: <?php print (GETPOST("optioncss") == 'print'?8:(empty($conf->dol_optimize_smallscreen)?'12':'6')); ?>px;
<?php if (! empty($conf->dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?>
}
@ -683,7 +683,7 @@ div.ficheaddleft {
@media only screen and (max-width: 900px)
{
div.fiche {
margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:((empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'6':'20'):'24')); ?>px;
margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:($dol_hide_leftmenu?'6':'20')); ?>px;
margin-<?php print $right; ?>: <?php print (GETPOST("optioncss") == 'print'?8:6); ?>px;
<?php if (! empty($conf->dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?>
}
@ -1021,6 +1021,10 @@ div.mainmenu.tools {
background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/tools.png',1) ?>);
}
div.mainmenu.websites {
background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/externalsite.png',1) ?>);
}
<?php
// Add here more div for other menu entries. moduletomainmenu=array('module name'=>'name of class for div')
@ -1040,7 +1044,8 @@ foreach($conf->modules as $val)
$mainmenuusedarray=array_unique(explode(',',$mainmenuused));
$generic=1;
$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices');
// Put here list of menu entries when the div.mainmenu.menuentry was previously defined
$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites');
foreach($mainmenuusedarray as $val)
{
if (empty($val) || in_array($val,$divalreadydefined)) continue;

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

View File

@ -699,7 +699,7 @@ td.showDragHandle {
div.fiche {
margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:((empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'4':'20'):'24')); ?>px;
margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:($dol_hide_leftmenu?'4':'20')); ?>px;
margin-<?php print $right; ?>: <?php print (GETPOST("optioncss") == 'print'?8:(empty($conf->dol_optimize_smallscreen)?'16':'4')); ?>px;
<?php if (! empty($conf->dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?>
margin-bottom: 15px;
@ -737,7 +737,7 @@ div.ficheaddleft {
@media only screen and (max-width: 900px)
{
div.fiche {
margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:((empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'4':'20'):'24')); ?>px;
margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:($dol_hide_leftmenu?'4':'20')); ?>px;
margin-<?php print $right; ?>: <?php print (GETPOST("optioncss") == 'print'?8:16); ?>px;
<?php if (! empty($conf->dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?>
margin-bottom: 15px;
@ -1072,6 +1072,10 @@ div.mainmenu.tools {
background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/tools.png',1) ?>);
}
div.mainmenu.websites {
background-image: url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/menus/externalsite.png',1) ?>);
}
<?php
// Add here more div for other menu entries. moduletomainmenu=array('module name'=>'name of class for div')
@ -1091,7 +1095,8 @@ foreach($conf->modules as $val)
$mainmenuusedarray=array_unique(explode(',',$mainmenuused));
$generic=1;
$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices');
// Put here list of menu entries when the div.mainmenu.menuentry was previously defined
$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites');
foreach($mainmenuusedarray as $val)
{
if (empty($val) || in_array($val,$divalreadydefined)) continue;

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -201,7 +202,9 @@ if ($search_login != '') $sql.= natural_search("u.login", $search_login);
if ($search_lastname != '') $sql.= natural_search("u.lastname", $search_lastname);
if ($search_firstname != '') $sql.= natural_search("u.firstname", $search_firstname);
if ($search_gender != '' && $search_gender != '-1') $sql.= " AND u.gender = '".$search_gender."'";
if ($search_employee >= 0) $sql.= natural_search("u.employee", $search_employee);
if (is_numeric($search_employee) && $search_employee >= 0) {
$sql .= ' AND u.employee = '.(int) $search_employee;
}
if ($search_accountancy_code != '') $sql.= natural_search("u.accountancy_code", $search_accountancy_code);
if ($search_email != '') $sql.= natural_search("u.email", $search_email);
if ($search_statut != '' && $search_statut >= 0) $sql.= " AND (u.statut=".$search_statut.")";

View File

@ -0,0 +1,640 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) ---Put here your own copyright and developer email---
*
* 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 websites/website.class.php
* \ingroup websites
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* Put some comments here
*/
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
/**
* Class Website
*
* Put here description of your class
* @see CommonObject
*/
class Website extends CommonObject
{
/**
* @var string Id to identify managed objects
*/
public $element = 'website';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'website';
/**
* @var WebsiteLine[] Lines
*/
public $lines = array();
/**
*/
public $entity;
public $shortname;
public $description;
public $status;
public $date_creation = '';
public $date_modification = '';
public $tms = '';
/**
*/
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
public function __construct(DoliDB $db)
{
$this->db = $db;
return 1;
}
/**
* Create object into database
*
* @param User $user User that creates
* @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, Id of created object if OK
*/
public function create(User $user, $notrigger = false)
{
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
// Clean parameters
if (isset($this->entity)) {
$this->entity = trim($this->entity);
}
if (isset($this->shortname)) {
$this->shortname = trim($this->shortname);
}
if (isset($this->description)) {
$this->description = trim($this->description);
}
if (isset($this->status)) {
$this->status = trim($this->status);
}
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
$sql.= 'entity,';
$sql.= 'shortname,';
$sql.= 'description,';
$sql.= 'status,';
$sql.= 'date_creation,';
$sql.= 'date_modification';
$sql .= ') VALUES (';
$sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).',';
$sql .= ' '.(! isset($this->shortname)?'NULL':"'".$this->db->escape($this->shortname)."'").',';
$sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").',';
$sql .= ' '.(! isset($this->status)?'NULL':$this->status).',';
$sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").',';
$sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'");
$sql .= ')';
$this->db->begin();
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action to call a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
//if ($result < 0) $error++;
//// End call triggers
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return $this->id;
}
}
/**
* Load object in memory from the database
*
* @param int $id Id object
* @param string $ref Ref
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function fetch($id, $ref = null)
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.entity,";
$sql .= " t.shortname,";
$sql .= " t.description,";
$sql .= " t.status,";
$sql .= " t.date_creation,";
$sql .= " t.date_modification,";
$sql .= " t.tms";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
if (null !== $ref) {
$sql .= ' WHERE t.ref = ' . '\'' . $ref . '\'';
} else {
$sql .= ' WHERE t.rowid = ' . $id;
}
$resql = $this->db->query($sql);
if ($resql) {
$numrows = $this->db->num_rows($resql);
if ($numrows) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->entity = $obj->entity;
$this->shortname = $obj->shortname;
$this->description = $obj->description;
$this->status = $obj->status;
$this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_modification = $this->db->jdate($obj->date_modification);
$this->tms = $this->db->jdate($obj->tms);
}
$this->db->free($resql);
if ($numrows) {
return 1;
} else {
return 0;
}
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.entity,";
$sql .= " t.shortname,";
$sql .= " t.description,";
$sql .= " t.status,";
$sql .= " t.date_creation,";
$sql .= " t.date_modification,";
$sql .= " t.tms";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new WebsiteLine();
$line->id = $obj->rowid;
$line->entity = $obj->entity;
$line->shortname = $obj->shortname;
$line->description = $obj->description;
$line->status = $obj->status;
$line->date_creation = $this->db->jdate($obj->date_creation);
$line->date_modification = $this->db->jdate($obj->date_modification);
$line->tms = $this->db->jdate($obj->tms);
$this->lines[] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*
* @param User $user User that modifies
* @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function update(User $user, $notrigger = false)
{
$error = 0;
dol_syslog(__METHOD__, LOG_DEBUG);
// Clean parameters
if (isset($this->entity)) {
$this->entity = trim($this->entity);
}
if (isset($this->shortname)) {
$this->shortname = trim($this->shortname);
}
if (isset($this->description)) {
$this->description = trim($this->description);
}
if (isset($this->status)) {
$this->status = trim($this->status);
}
// Check parameters
// Put here code to add a control on parameters values
// Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
$sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").',';
$sql .= ' shortname = '.(isset($this->shortname)?"'".$this->db->escape($this->shortname)."'":"null").',';
$sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").',';
$sql .= ' status = '.(isset($this->status)?$this->status:"null").',';
$sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').',';
$sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').',';
$sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'");
$sql .= ' WHERE rowid=' . $this->id;
$this->db->begin();
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
if (!$error && !$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
//// End call triggers
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user User that deletes
* @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function delete(User $user, $notrigger = false)
{
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
$this->db->begin();
if (!$error) {
if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
//// End call triggers
}
}
if (!$error) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
$sql .= ' WHERE rowid=' . $this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Load an object from its id and create a new one in database
*
* @param int $fromid Id of object to clone
*
* @return int New id of clone
*/
public function createFromClone($fromid)
{
dol_syslog(__METHOD__, LOG_DEBUG);
global $user;
$error = 0;
$object = new Website($this->db);
$this->db->begin();
// Load source object
$object->fetch($fromid);
// Reset object
$object->id = 0;
// Clear fields
// ...
// Create clone
$result = $object->create($user);
// Other options
if ($result < 0) {
$error ++;
$this->errors = $object->errors;
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
// End
if (!$error) {
$this->db->commit();
return $object->id;
} else {
$this->db->rollback();
return - 1;
}
}
/**
* Return a link to the user card (with optionaly the picto)
* Use this->id,this->lastname, this->firstname
*
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to
* @param integer $notooltip 1=Disable tooltip
* @param int $maxlen Max length of visible user name
* @param string $morecss Add more css on link
* @return string String with URL
*/
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
{
global $langs, $conf, $db;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
$result = '';
$companylink = '';
$label = '<u>' . $langs->trans("MyModule") . '</u>';
$label.= '<div width="100%">';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$link = '<a href="'.DOL_URL_ROOT.'/websites/card.php?id='.$this->id.'"';
$link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
$link.= '>';
$linkend='</a>';
if ($withpicto)
{
$result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result.=' ';
}
$result.= $link . $this->ref . $linkend;
return $result;
}
/**
* Retourne le libelle du status d'un user (actif, inactif)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->status,$mode);
}
/**
* Renvoi le libelle d'un status donne
*
* @param int $status Id status
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status
*/
function LibStatut($status,$mode=0)
{
global $langs;
if ($mode == 0)
{
$prefix='';
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
if ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
}
if ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
if ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
}
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
*
* @return void
*/
public function initAsSpecimen()
{
$this->id = 0;
$this->entity = '';
$this->shortname = '';
$this->description = '';
$this->status = '';
$this->date_creation = '';
$this->date_modification = '';
$this->tms = '';
}
}
/**
* Class WebsiteLine
*/
class WebsiteLine
{
/**
* @var int ID
*/
public $id;
/**
* @var mixed Sample line property 1
*/
public $entity;
public $shortname;
public $description;
public $status;
public $date_creation = '';
public $date_modification = '';
public $tms = '';
/**
* @var mixed Sample line property 2
*/
}

View File

@ -21,8 +21,49 @@
* \brief Page to setup the module Website
*/
/**
* Show HTML header HTML + BODY + Top menu + left menu + DIV
*
* @param string $head Optionnal head lines
* @param string $title HTML title
* @param string $help_url Url links to help page
* Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage
* For other external page: http://server/url
* @param string $target Target to use on links
* @param int $disablejs More content into html header
* @param int $disablehead More content into html header
* @param array $arrayofjs Array of complementary js files
* @param array $arrayofcss Array of complementary css files
* @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails)
* @return void
*/
function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='')
{
global $conf;
// html header
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
// top menu and left menu area
if (empty($conf->dol_hide_topmenu))
{
top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url);
}
if (empty($conf->dol_hide_leftmenu))
{
left_menu('', $help_url, '', '', 1, $title, 1);
}
// main area
//main_area($title);
}
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
$langs->load("admin");
$langs->load("other");
@ -36,7 +77,7 @@ $conf->dol_hide_leftmenu = 1;
$website='website1';
$object=new Website($db);
/*
@ -75,12 +116,21 @@ $form = new Form($db);
$help_url='';
llxHeader('',$langs->trans("WebsiteSetup"),$help_url);
llxHeader('', $langs->trans("WebsiteSetup"), $help_url);
$style=' style="padding-top: 4px; padding-left: 10px; border-bottom: 1px solid #888; height: 20px; vertical-align: middle; margin-bottom: 5px;"';
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("WebsiteSetup"),$linkback,'title_setup');
print '<div class="websiteselection centpercent"'.$style.'>';
// Loop on each sites
$tmp = $object->fetchAll();
foreach($object->lines as $websitearray)
{
var_dump($websitearray);
}
print '</div>';
$head = array();
@ -95,10 +145,6 @@ if ($_SESSION['website_mode'] == 'edit')
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
dol_fiche_head($head, 'general', $langs->trans("Page").': '.$langs->trans("Home"), 0, 'globe');
print load_fiche_titre($langs->trans("SEO"),'','');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>';
@ -152,8 +198,6 @@ if ($_SESSION['website_mode'] == 'edit')
$doleditor=new DolEditor('WEBSITE_FOOTER',$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60);
$doleditor->Create();
dol_fiche_end();
print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
print '</form>';