2
0
forked from Wavyzz/dolibarr

Fix: carriage return

This commit is contained in:
Regis Houssin
2012-07-26 17:45:47 +02:00
parent c55eabeaff
commit 51ccb33964
52 changed files with 1603 additions and 1601 deletions

View File

@@ -51,11 +51,11 @@ $object = new Address($db);
* Actions
*/
// Cancel
if (GETPOST("cancel") && ! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
// Cancel
if (GETPOST("cancel") && ! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
if ($action == 'add' || $action == 'update')
@@ -80,7 +80,7 @@ if ($action == 'add' || $action == 'update')
{
if (! empty($backtopage))
{
Header("Location: ".$backtopage);
Header("Location: ".$backtopage);
exit;
}
else if ($origin == 'commande')
@@ -93,10 +93,10 @@ if ($action == 'add' || $action == 'update')
Header("Location: ../comm/propal/contact.php?action=editdelivery_adress&socid=".$socid."&id=".$originid);
exit;
}
elseif ($origin == 'shipment')
{
Header("Location: ../expedition/fiche.php?id=".$originid);
exit;
elseif ($origin == 'shipment')
{
Header("Location: ../expedition/fiche.php?id=".$originid);
exit;
}
else
{
@@ -118,10 +118,10 @@ if ($action == 'add' || $action == 'update')
if ($result >= 0)
{
if (! empty($backtopage))
{
Header("Location: ".$backtopage);
exit;
if (! empty($backtopage))
{
Header("Location: ".$backtopage);
exit;
}
else if ($origin == 'commande')
{
@@ -286,10 +286,10 @@ if ($action == 'create')
print '<br><center>';
print '<input type="submit" class="button" value="'.$langs->trans('Add').'">';
if (! empty($backtopage))
{
print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
if (! empty($backtopage))
{
print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
}
print '</center>'."\n";
@@ -384,10 +384,10 @@ elseif ($action == 'edit')
print '</table><br>';
print '<center>';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '<center>';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</center>';
print '</form>';

View File

@@ -87,14 +87,14 @@ if ($action == 'setcustomeraccountancycode')
if ($action == 'setconditions' && $user->rights->societe->creer)
{
$object->fetch($id);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// mode de reglement
if ($action == 'setmode' && $user->rights->societe->creer)
{
$object->fetch($id);
$result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
$result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// assujetissement a la TVA
@@ -796,10 +796,10 @@ if ($id > 0)
show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
// Addresses list
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB))
{
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
// Addresses list
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB))
{
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))

View File

@@ -547,60 +547,60 @@ if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"
// Action confirmation validation
if ($action == 'confirm_valid' && $confirm == 'yes')
{
if ($object->fetch($id) >= 0)
{
$object->valid($user);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
dol_print_error($db);
{
if ($object->fetch($id) >= 0)
{
$object->valid($user);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
dol_print_error($db);
}
}
// Resend
if ($action == 'confirm_reset' && $confirm == 'yes')
{
if ($object->fetch($id) >= 0)
{
$db->begin();
$result=$object->valid($user);
if ($result > 0)
{
$result=$object->reset_targets_status($user);
}
if ($result > 0)
{
$db->commit();
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
$mesg=$object->error;
$db->rollback();
}
}
else
{
dol_print_error($db);
{
if ($object->fetch($id) >= 0)
{
$db->begin();
$result=$object->valid($user);
if ($result > 0)
{
$result=$object->reset_targets_status($user);
}
if ($result > 0)
{
$db->commit();
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
$mesg=$object->error;
$db->rollback();
}
}
else
{
dol_print_error($db);
}
}
// Action confirmation suppression
if ($action == 'confirm_delete' && $confirm == 'yes')
{
$object->fetch($id);
if ($object->delete($object->id))
{
Header("Location: liste.php");
exit;
{
$object->fetch($id);
if ($object->delete($object->id))
{
Header("Location: liste.php");
exit;
}
}

View File

@@ -87,7 +87,7 @@ $result = restrictedArea($user, $module, $objectid, $dbtable);
$object = new Propal($db);
// Load object
if ($id > 0 || ! empty($ref))
if ($id > 0 || ! empty($ref))
{
$ret=$object->fetch($id, $ref);
}
@@ -154,29 +154,29 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->prop
// Remove line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propale->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($lineid);
// reorder lines
if ($result) $object->line_order(true);
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($lineid);
// reorder lines
if ($result) $object->line_order(true);
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
@@ -248,18 +248,18 @@ else if ($action == 'set_ref_client' && $user->rights->propale->creer)
$object->set_ref_client($user, $_POST['ref_client']);
}
else if ($action == 'setnote_public' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
else if ($action == 'setnote_public' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
else if ($action == 'setnote' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
// Create proposal
@@ -952,21 +952,21 @@ else if ($action == 'builddoc' && $user->rights->propale->creer)
}
}
// Remove file in doc form
else if ($action == 'remove_file')
{
if ($object->fetch($id))
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$object->fetch_thirdparty();
$langs->load("other");
$upload_dir = $conf->propal->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
// Remove file in doc form
else if ($action == 'remove_file')
{
if ($object->fetch($id))
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$object->fetch_thirdparty();
$langs->load("other");
$upload_dir = $conf->propal->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}
// Set project
@@ -1066,63 +1066,63 @@ else if ($action == 'down' && $user->rights->propale->creer)
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
if ($action == 'addcontact' && $user->rights->propale->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
if ($action == 'addcontact' && $user->rights->propale->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// Bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->propale->creer)
{
if ($object->fetch($id) > 0)
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->propale->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
dol_print_error($db);
}
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// Bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->propale->creer)
{
if ($object->fetch($id) > 0)
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->propale->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
dol_print_error($db);
}
}
}
@@ -1561,19 +1561,19 @@ if ($id > 0 || ! empty($ref))
print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$blocname = 'notes';
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
@@ -1905,9 +1905,9 @@ else
{
$sql.= " AND p.ref LIKE '%".$db->escape(trim($search_ref))."%'";
}
if ($search_refcustomer)
{
$sql.= " AND p.ref_client LIKE '%".$db->escape(trim($search_refcustomer))."%'";
if ($search_refcustomer)
{
$sql.= " AND p.ref_client LIKE '%".$db->escape(trim($search_refcustomer))."%'";
}
if ($search_societe)
{
@@ -1980,8 +1980,8 @@ else
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="16" name="search_societe" value="'.$search_societe.'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" size="10" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">';
print '<td class="liste_titre">';
print '<input class="flat" size="10" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">';
print '</td>';
print '<td class="liste_titre" colspan="1" align="center">';
print $langs->trans('Month').': <input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
@@ -2049,8 +2049,8 @@ else
print '</td>';
// Customer ref
print '<td nowrap="nowrap">';
print $objp->ref_client;
print '<td nowrap="nowrap">';
print $objp->ref_client;
print '</td>';
// Date propale

View File

@@ -969,7 +969,7 @@ class Propal extends CommonObject
$sql.= ", p.fk_cond_reglement";
$sql.= ", p.fk_mode_reglement";
$sql.= ", c.label as statut_label";
$sql.= ", ca.code as availability_code, ca.label as availability";
$sql.= ", ca.code as availability_code, ca.label as availability";
$sql.= ", dr.code as demand_reason_code, dr.label as demand_reason";
$sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc";
$sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement";

View File

@@ -110,11 +110,11 @@ else if ($action == 'deletecontact' && $user->rights->propale->creer)
}
}
else if ($action == 'setaddress' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->setDeliveryAddress($_POST['fk_address']);
if ($result < 0) dol_print_error($db,$object->error);
else if ($action == 'setaddress' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->setDeliveryAddress($_POST['fk_address']);
if ($result < 0) dol_print_error($db,$object->error);
}
@@ -174,27 +174,27 @@ if ($id > 0 || ! empty($ref))
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
// Delivery address
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
{
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdelivery_address')
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id);
}
else
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id);
}
print '</td></tr>';
// Delivery address
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
{
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdelivery_address')
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id);
}
else
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id);
}
print '</td></tr>';
}
print "</table>";

View File

@@ -1,225 +1,225 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/comm/propal/document.php
* \ingroup propale
* \brief Page de gestion des documents attaches a une proposition commerciale
*/
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
$langs->load('compta');
$langs->load('other');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
$id = GETPOST('id','int');
$ref = GETPOST('ref','alpha');
$mesg='';
if (isset($_SESSION['DolMessage']))
{
$mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']);
}
// Security check
if ($user->societe_id)
{
$action='';
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'propale', $id, 'propal');
// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
$object = new Propal($db);
$object->fetch($id,$ref);
if ($object->id > 0)
{
$object->fetch_thirdparty();
}
/*
* Actions
*/
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($object->id > 0)
{
$object->fetch_thirdparty();
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
if (dol_mkdir($upload_dir) >= 0)
{
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
{
// Create small thumbs for image (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
}
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}
}
// Delete
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id > 0)
{
$langs->load("other");
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
if ($object->id > 0)
{
$upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
$head = propal_prepare_head($object);
dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder".'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>';
// Ref client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
print $object->ref_client;
print '</td>';
print '</tr>';
// Customer
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
dol_htmloutput_mesg($mesg,$mesgs);
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
if ($ret == 'html') print '<br>';
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'propal',$param);
}
else
{
print $langs->trans("UnkownError");
}
$db->close();
llxFooter();
?>
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/comm/propal/document.php
* \ingroup propale
* \brief Page de gestion des documents attaches a une proposition commerciale
*/
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
$langs->load('compta');
$langs->load('other');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
$id = GETPOST('id','int');
$ref = GETPOST('ref','alpha');
$mesg='';
if (isset($_SESSION['DolMessage']))
{
$mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']);
}
// Security check
if ($user->societe_id)
{
$action='';
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'propale', $id, 'propal');
// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
$object = new Propal($db);
$object->fetch($id,$ref);
if ($object->id > 0)
{
$object->fetch_thirdparty();
}
/*
* Actions
*/
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($object->id > 0)
{
$object->fetch_thirdparty();
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
if (dol_mkdir($upload_dir) >= 0)
{
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
{
// Create small thumbs for image (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
}
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
else // Known error
{
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
}
}
}
}
}
// Delete
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id > 0)
{
$langs->load("other");
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
if ($object->id > 0)
{
$upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
$head = propal_prepare_head($object);
dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder".'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>';
// Ref client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
print $object->ref_client;
print '</td>';
print '</tr>';
// Customer
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
dol_htmloutput_mesg($mesg,$mesgs);
/*
* Confirmation suppression fichier
*/
if ($action == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
if ($ret == 'html') print '<br>';
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object);
// List of document
$param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'propal',$param);
}
else
{
print $langs->trans("UnkownError");
}
$db->close();
llxFooter();
?>

View File

@@ -184,14 +184,14 @@ if ($conf->propal->enabled)
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]>";
$propalstatic->id=$obj->rowid;
$propalstatic->ref=$obj->ref;
$propalstatic->id=$obj->rowid;
$propalstatic->ref=$obj->ref;
print '<td nowrap="nowrap">'.$propalstatic->getNomUrl(1).'</td>';
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
print '<td>'.$companystatic->getNomUrl(1,'customer',24).'</td>';
print '</tr>';
@@ -265,10 +265,10 @@ if ($resql)
print '</td>';
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datec),'day').'</td>';
@@ -340,10 +340,10 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
print "</td>";
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
$companystatic->client=$obj->client;
$companystatic->canvas=$obj->canvas;
print '<td align="left">'.$companystatic->getNomUrl(1,'customer',44).'</td>'."\n";
print '<td align="right">';

View File

@@ -47,18 +47,18 @@ $object = new Propal($db);
/* Actions */
/******************************************************************************/
if ($action == 'setnote_public' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
if ($action == 'setnote_public' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}

View File

@@ -923,13 +923,13 @@ class Commande extends CommonObject
$this->note_public = $object->note_public;
$this->origin = $object->element;
$this->origin_id = $object->id;
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
{
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
$this->origin_id = $object->id;
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
{
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
$ret = $this->create($user);
@@ -939,7 +939,7 @@ class Commande extends CommonObject
// Actions hooked (by external module)
if (! is_object($hookmanager))
{
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('orderdao'));
@@ -2069,16 +2069,16 @@ class Commande extends CommonObject
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
if ($this->db->query($sql) )
{
if (! empty($conf->propal->enabled) && ! empty($conf->global->PROPALE_CLASSIFIED_INVOICED_WITH_ORDER))
{
if (! empty($conf->propal->enabled) && ! empty($conf->global->PROPALE_CLASSIFIED_INVOICED_WITH_ORDER))
{
$this->fetchObjectLinked('','propal',$this->id,$this->element);
if (! empty($this->linkedObjects))
{
foreach($this->linkedObjects['propal'] as $element)
{
$ret=$element->classer_facturee();
}
}
if (! empty($this->linkedObjects))
{
foreach($this->linkedObjects['propal'] as $element)
{
$ret=$element->classer_facturee();
}
}
}
return 1;
}

View File

@@ -106,10 +106,10 @@ else if ($action == 'deletecontact' && $user->rights->commande->creer)
}
}
else if ($action == 'setaddress' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->setDeliveryAddress($_POST['fk_address']);
else if ($action == 'setaddress' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->setDeliveryAddress($_POST['fk_address']);
}
/*
@@ -173,27 +173,27 @@ if ($id > 0 || ! empty($ref))
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
// Delivery address
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
{
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdelivery_address')
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id);
}
else
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id);
}
print '</td></tr>';
// Delivery address
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
{
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdelivery_address')
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id);
}
else
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id);
}
print '</td></tr>';
}
print "</table>";

View File

@@ -40,11 +40,11 @@ $confirm = GETPOST('confirm');
$id = GETPOST('id','int');
$ref = GETPOST('ref');
$mesg='';
if (isset($_SESSION['DolMessage']))
{
$mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']);
$mesg='';
if (isset($_SESSION['DolMessage']))
{
$mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']);
}
// Security check
@@ -130,7 +130,7 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes')
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}

View File

@@ -81,10 +81,10 @@ $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
$object=new Facture($db);
// Load object
if ($id > 0 || ! empty($ref))
{
$ret=$object->fetch($id, $ref);
// Load object
if ($id > 0 || ! empty($ref))
{
$ret=$object->fetch($id, $ref);
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
@@ -166,37 +166,37 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fact
// Delete line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($_GET['lineid'], $user);
if ($result > 0)
{
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
if ($result >= 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
}
}
else
{
$mesg='<div clas="error">'.$object->error.'</div>';
$action='';
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($_GET['lineid'], $user);
if ($result > 0)
{
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
if ($result >= 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
}
}
else
{
$mesg='<div clas="error">'.$object->error.'</div>';
$action='';
}
}
@@ -317,18 +317,18 @@ else if ($action == 'set_ref_client' && $user->rights->facture->creer)
$object->set_ref_client($_POST['ref_client']);
}
else if ($action == 'setnote_public' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
else if ($action == 'setnote_public' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
// Classify to validated
@@ -1513,81 +1513,81 @@ else if ($action == 'builddoc') // En get ou en post
}
}
// Remove file in doc form
else if ($action == 'remove_file')
{
if ($object->fetch($id))
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$object->fetch_thirdparty();
$langs->load("other");
$upload_dir = $conf->facture->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
// Remove file in doc form
else if ($action == 'remove_file')
{
if ($object->fetch($id))
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$object->fetch_thirdparty();
$langs->load("other");
$upload_dir = $conf->facture->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
if ($action == 'addcontact' && $user->rights->facture->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
if ($action == 'addcontact' && $user->rights->facture->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->facture->creer)
{
if ($object->fetch($id))
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->facture->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
dol_print_error($db);
}
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->facture->creer)
{
if ($object->fetch($id))
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->facture->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
dol_print_error($db);
}
}
}
@@ -2825,22 +2825,22 @@ else
print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
/*

View File

@@ -256,30 +256,30 @@ class Facture extends CommonObject
$error++;
}
// TODO mutualiser
if ($origin == 'commande')
{
// On recupere les differents contact interne et externe
// TODO mutualiser
if ($origin == 'commande')
{
// On recupere les differents contact interne et externe
$order = new Commande($this->db);
$order->id = $origin_id;
// On recupere le commercial suivi propale
$order->id = $origin_id;
// On recupere le commercial suivi propale
$this->userid = $order->getIdcontact('internal', 'SALESREPFOLL');
if ($this->userid)
{
//On passe le commercial suivi commande en commercial suivi paiement
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
}
// On recupere le contact client facturation commande
$this->contactid = $order->getIdcontact('external', 'BILLING');
if ($this->contactid)
{
//On passe le contact client facturation commande en contact client facturation
$this->add_contact($this->contactid[0], 'BILLING', 'external');
}
if ($this->userid)
{
//On passe le commercial suivi commande en commercial suivi paiement
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
}
// On recupere le contact client facturation commande
$this->contactid = $order->getIdcontact('external', 'BILLING');
if ($this->contactid)
{
//On passe le contact client facturation commande en contact client facturation
$this->add_contact($this->contactid[0], 'BILLING', 'external');
}
}
}
}
@@ -674,11 +674,11 @@ class Facture extends CommonObject
$this->origin = $object->element;
$this->origin_id = $object->id;
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
{
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
{
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
$ret = $this->create($user);
@@ -1237,32 +1237,32 @@ class Facture extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
// On efface le repertoire de pdf provisoire
$ref = dol_sanitizeFileName($this->ref);
if ($conf->facture->dir_output)
{
$dir = $conf->facture->dir_output . "/" . $ref;
$file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf";
if (file_exists($file)) // We must delete all files before deleting directory
{
// On efface le repertoire de pdf provisoire
$ref = dol_sanitizeFileName($this->ref);
if ($conf->facture->dir_output)
{
$dir = $conf->facture->dir_output . "/" . $ref;
$file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf";
if (file_exists($file)) // We must delete all files before deleting directory
{
$ret=dol_delete_preview($this);
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
$this->db->rollback();
return 0;
}
}
if (file_exists($dir))
{
if (! dol_delete_dir_recursive($dir)) // For remove dir and meta
{
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
$this->db->rollback();
return 0;
}
}
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
$this->db->rollback();
return 0;
}
}
if (file_exists($dir))
{
if (! dol_delete_dir_recursive($dir)) // For remove dir and meta
{
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
$this->db->rollback();
return 0;
}
}
}
$this->db->commit();

View File

@@ -35,7 +35,7 @@ $langs->load("companies");
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref = GETPOST('ref');
$socid=GETPOST('socid','int');
$socid=GETPOST('socid','int');
$action=GETPOST('action','alpha');
// Security check
@@ -166,9 +166,9 @@ if ($id > 0 || ! empty($ref))
print '</div>';
print '<br>';
// Contacts lines
print '<br>';
// Contacts lines
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
}
else

View File

@@ -43,11 +43,11 @@ $confirm = GETPOST('confirm');
$id = GETPOST('facid','int');
$ref = GETPOST('ref');
$mesg='';
if (isset($_SESSION['DolMessage']))
{
$mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']);
$mesg='';
if (isset($_SESSION['DolMessage']))
{
$mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']);
}
// Security check

View File

@@ -31,9 +31,9 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php');
$langs->load("companies");
$langs->load("bills");
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref=GETPOST('ref','alpha');
$socid=GETPOST('socid','int');
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref=GETPOST('ref','alpha');
$socid=GETPOST('socid','int');
$action=GETPOST('action','alpha');
// Security check

View File

@@ -57,7 +57,7 @@ header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
switch ($_SERVER['REQUEST_METHOD']) {
case 'OPTIONS':
case 'OPTIONS':
break;
case 'HEAD':
case 'GET':

View File

@@ -90,7 +90,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
$module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
{
$module = $regs[1];
$module = $regs[1];
$subelement = $regs[2];
}

View File

@@ -30,9 +30,9 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
$field = GETPOST('field','alpha',2);
$element = GETPOST('element','alpha',2);
$table_element = GETPOST('table_element','alpha',2);
$field = GETPOST('field','alpha',2);
$element = GETPOST('element','alpha',2);
$table_element = GETPOST('table_element','alpha',2);
$fk_element = GETPOST('fk_element','alpha',2);
/*
@@ -132,11 +132,11 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
}
else
{
$module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
{
$module = $regs[1];
$subelement = $regs[2];
$module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
{
$module = $regs[1];
$subelement = $regs[2];
}
dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php');

View File

@@ -49,12 +49,12 @@ if (! empty($id) && ! empty($action) && ! empty($htmlname))
$soc->fetch($id);
$return=array();
$return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true);
$return['num'] = $form->num;
$return['error'] = $form->error;
$return=array();
$return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true);
$return['num'] = $form->num;
$return['error'] = $form->error;
echo json_encode($return);
}

View File

@@ -865,93 +865,93 @@ abstract class CommonObject
}
}
/**
* Change the payments methods
*
* @param int $id Id of new payment method
* @return int >0 if OK, <0 if KO
*/
function setPaymentMethods($id)
{
dol_syslog(get_class($this).'::setPaymentMethods('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
{
// TODO uniformize field name
$fieldname = 'fk_mode_reglement';
if ($this->element == 'societe') $fieldname = 'mode_reglement';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id;
$sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql))
{
/**
* Change the payments methods
*
* @param int $id Id of new payment method
* @return int >0 if OK, <0 if KO
*/
function setPaymentMethods($id)
{
dol_syslog(get_class($this).'::setPaymentMethods('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
{
// TODO uniformize field name
$fieldname = 'fk_mode_reglement';
if ($this->element == 'societe') $fieldname = 'mode_reglement';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id;
$sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql))
{
$this->mode_reglement_id = $id;
$this->mode_reglement = $id; // for compatibility
return 1;
}
else
{
dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut;
return -2;
}
$this->mode_reglement = $id; // for compatibility
return 1;
}
else
{
dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut;
return -2;
}
}
/**
* Change the payments terms
*
* @param int $id Id of new payment terms
* @return int >0 if OK, <0 if KO
*/
function setPaymentTerms($id)
{
dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
/**
* Change the payments terms
*
* @param int $id Id of new payment terms
* @return int >0 if OK, <0 if KO
*/
function setPaymentTerms($id)
{
dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
{
// TODO uniformize field name
$fieldname = 'fk_cond_reglement';
if ($this->element == 'societe') $fieldname = 'cond_reglement';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id;
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id;
$sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql))
{
if ($this->db->query($sql))
{
$this->cond_reglement_id = $id;
$this->cond_reglement = $id; // for compatibility
return 1;
}
else
{
dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut;
return -2;
}
$this->cond_reglement = $id; // for compatibility
return 1;
}
else
{
dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut;
return -2;
}
}
/**
* Define delivery address
*
* @param int $id Address id
* @return int <0 si ko, >0 si ok
*/
function setDeliveryAddress($id)
/**
* Define delivery address
*
* @param int $id Address id
* @return int <0 si ko, >0 si ok
*/
function setDeliveryAddress($id)
{
$fieldname = 'fk_adresse_livraison';
if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address';
@@ -962,14 +962,14 @@ abstract class CommonObject
if ($this->db->query($sql))
{
$this->fk_delivery_address = $id;
return 1;
return 1;
}
else
{
$this->error=$this->db->error();
dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error);
return -1;
}
}
}
/**
@@ -1854,18 +1854,18 @@ abstract class CommonObject
$sql.= " WHERE rowid=".$elementId;
dol_syslog(get_class($this)."::setStatut sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
{
if ($this->db->query($sql))
{
$this->db->commit();
$this->statut = $status;
return 1;
}
else
{
$this->statut = $status;
return 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
}
@@ -2148,35 +2148,35 @@ abstract class CommonObject
return $nb;
}
/**
/**
* Set extra parameters
*
* @return void
*/
function setExtraParameters()
* @return void
*/
function setExtraParameters()
{
$this->db->begin();
$extraparams = (! empty($this->extraparams) ? json_encode($this->extraparams) : null);
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET extraparams = ".(! empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null");
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::setExtraParameters ".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
else
{
$this->db->commit();
return 1;
}
dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::setExtraParameters ".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
else
{
$this->db->commit();
return 1;
}
}

View File

@@ -213,28 +213,28 @@ class Conf
//var_dump($this->modules);
//var_dump($this->modules_parts);
// Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
{
global $mc;
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
if ($ret) $mc = new ActionsMulticompany($db);
// Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
{
global $mc;
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
if ($ret) $mc = new ActionsMulticompany($db);
}
// Second or others levels object
$this->propal->cloture = (object) array();
$this->propal->cloture = (object) array();
$this->propal->facturation = (object) array();
$this->commande->client = (object) array();
$this->commande->client = (object) array();
$this->commande->fournisseur = (object) array();
$this->facture->client = (object) array();
$this->facture->client = (object) array();
$this->facture->fournisseur = (object) array();
$this->fournisseur->commande = (object) array();
$this->fournisseur->commande = (object) array();
$this->fournisseur->facture = (object) array();
$this->contrat->services = (object) array();
$this->contrat->services->inactifs = (object) array();
$this->contrat->services = (object) array();
$this->contrat->services->inactifs = (object) array();
$this->contrat->services->expires = (object) array();
$this->adherent->cotisation = (object) array();
$this->bank->rappro = (object) array();
$this->bank->rappro = (object) array();
$this->bank->cheque = (object) array();
// Clean some variables
@@ -268,7 +268,7 @@ class Conf
// Define default dir_output and dir_temp for directories of modules
foreach($this->modules as $module)
{
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
$this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp");
// For backward compatibility
$this->$module->dir_output = $rootfordata."/".$module;
@@ -284,14 +284,14 @@ class Conf
$this->admin->dir_temp=$rootfordata.'/admin/temp';
// For user storage
$this->user->multidir_output = array($this->entity => $rootfordata."/users");
$this->user->multidir_output = array($this->entity => $rootfordata."/users");
$this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
// For backward compatibility
$this->user->dir_output=$rootforuser."/users";
$this->user->dir_temp=$rootforuser."/users/temp";
// For propal storage
$this->propal->dir_output=$rootforuser."/propale";
// For propal storage
$this->propal->dir_output=$rootforuser."/propale";
$this->propal->dir_temp=$rootforuser."/propale/temp";
// Exception: Some dir are not the name of module. So we keep exception here
@@ -314,9 +314,9 @@ class Conf
$this->service->multidir_output=array($this->entity => $rootfordata."/produit");
$this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
// For backward compatibility
$this->product->dir_output=$rootfordata."/produit";
$this->product->dir_temp =$rootfordata."/produit/temp";
$this->service->dir_output=$rootfordata."/produit";
$this->product->dir_output=$rootfordata."/produit";
$this->product->dir_temp =$rootfordata."/produit/temp";
$this->service->dir_output=$rootfordata."/produit";
$this->service->dir_temp =$rootfordata."/produit/temp";
// Module contrat
@@ -436,10 +436,10 @@ class Conf
if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php';
elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php';
// Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
// Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
{
if (is_object($mc)) $mc->setValues($this);
if (is_object($mc)) $mc->setValues($this);
}
}
}

View File

@@ -66,9 +66,9 @@ class FileUpload
$pathname = 'compta/facture';
$dir_output=$conf->$element->dir_output;
}
elseif ($element == 'project') {
elseif ($element == 'project') {
$element = $pathname = 'projet';
$dir_output=$conf->$element->dir_output;
$dir_output=$conf->$element->dir_output;
}
elseif ($element == 'fichinter') {
$element='ficheinter';
@@ -109,11 +109,11 @@ class FileUpload
'accept_file_types' => '/.+$/i',
// The maximum number of files for the upload directory:
'max_number_of_files' => null,
// Image resolution restrictions:
'max_width' => null,
'max_height' => null,
'min_width' => 1,
'min_height' => 1,
// Image resolution restrictions:
'max_width' => null,
'max_height' => null,
'min_width' => 1,
'min_height' => 1,
// Set the following option to false to enable resumable uploads:
'discard_aborted_uploads' => true,
'image_versions' => array(
@@ -132,7 +132,7 @@ class FileUpload
'thumbnail' => array(
'upload_dir' => $dir_output . '/' . $object->ref . '/thumbs/',
'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object->ref.'/thumbs/',
'max_width' => 80,
'max_width' => 80,
'max_height' => 80
)
)
@@ -146,14 +146,14 @@ class FileUpload
*
*/
protected function getFullUrl() {
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
return
($https ? 'https://' : 'http://').
(!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
($https && $_SERVER['SERVER_PORT'] === 443 ||
$_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))).
substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
return
($https ? 'https://' : 'http://').
(!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
($https && $_SERVER['SERVER_PORT'] === 443 ||
$_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))).
substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
}
/**
@@ -161,13 +161,13 @@ class FileUpload
*
* @param unknown_type $file
*/
protected function set_file_delete_url($file) {
$file->delete_url = $this->_options['script_url']
.'?file='.rawurlencode($file->name).'&fk_element='.$this->_fk_element.'&element='.$this->_element;
$file->delete_type = $this->_options['delete_type'];
if ($file->delete_type !== 'DELETE') {
$file->delete_url .= '&_method=DELETE';
}
protected function set_file_delete_url($file) {
$file->delete_url = $this->_options['script_url']
.'?file='.rawurlencode($file->name).'&fk_element='.$this->_fk_element.'&element='.$this->_element;
$file->delete_type = $this->_options['delete_type'];
if ($file->delete_type !== 'DELETE') {
$file->delete_url .= '&_method=DELETE';
}
}
/**
@@ -256,9 +256,9 @@ class FileUpload
$file->error = $error;
return false;
}
if (!$file->name) {
$file->error = 'missingFileName';
return false;
if (!$file->name) {
$file->error = 'missingFileName';
return false;
}
if (!preg_match($this->_options['accept_file_types'], $file->name)) {
$file->error = 'acceptFileTypes';
@@ -308,10 +308,10 @@ class FileUpload
*
* @param unknown_type $matches
*/
protected function upcount_name_callback($matches) {
$index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
$ext = isset($matches[2]) ? $matches[2] : '';
return ' ('.$index.')'.$ext;
protected function upcount_name_callback($matches) {
$index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
$ext = isset($matches[2]) ? $matches[2] : '';
return ' ('.$index.')'.$ext;
}
/**
@@ -319,13 +319,13 @@ class FileUpload
*
* @param unknown_type $name
*/
protected function upcount_name($name) {
return preg_replace_callback(
'/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/',
array($this, 'upcount_name_callback'),
$name,
1
);
protected function upcount_name($name) {
return preg_replace_callback(
'/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/',
array($this, 'upcount_name_callback'),
$name,
1
);
}
/**
@@ -335,22 +335,22 @@ class FileUpload
* @param unknown_type $type
* @param unknown_type $index
*/
protected function trim_file_name($name, $type, $index) {
// Remove path information and dots around the filename, to prevent uploading
// into different directories or replacing hidden system files.
// Also remove control characters and spaces (\x00..\x20) around the filename:
$file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
// Add missing file extension for known image types:
if (strpos($file_name, '.') === false &&
preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
$file_name .= '.'.$matches[1];
}
if ($this->_options['discard_aborted_uploads']) {
while(is_file($this->_options['upload_dir'].$file_name)) {
$file_name = $this->upcount_name($file_name);
}
}
return $file_name;
protected function trim_file_name($name, $type, $index) {
// Remove path information and dots around the filename, to prevent uploading
// into different directories or replacing hidden system files.
// Also remove control characters and spaces (\x00..\x20) around the filename:
$file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
// Add missing file extension for known image types:
if (strpos($file_name, '.') === false &&
preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
$file_name .= '.'.$matches[1];
}
if ($this->_options['discard_aborted_uploads']) {
while(is_file($this->_options['upload_dir'].$file_name)) {
$file_name = $this->upcount_name($file_name);
}
}
return $file_name;
}
/**
@@ -359,8 +359,8 @@ class FileUpload
* @param unknown_type $file
* @param unknown_type $index
*/
protected function handle_form_data($file, $index) {
// Handle form data, e.g. $_REQUEST['description'][$index]
protected function handle_form_data($file, $index) {
// Handle form data, e.g. $_REQUEST['description'][$index]
}
/**
@@ -368,33 +368,33 @@ class FileUpload
*
* @param unknown_type $file_path
*/
protected function orient_image($file_path) {
$exif = @exif_read_data($file_path);
if ($exif === false) {
return false;
}
$orientation = intval(@$exif['Orientation']);
if (!in_array($orientation, array(3, 6, 8))) {
return false;
}
$image = @imagecreatefromjpeg($file_path);
switch ($orientation) {
case 3:
$image = @imagerotate($image, 180, 0);
break;
case 6:
$image = @imagerotate($image, 270, 0);
break;
case 8:
$image = @imagerotate($image, 90, 0);
break;
default:
return false;
}
$success = imagejpeg($image, $file_path);
// Free up memory (imagedestroy does not delete files):
@imagedestroy($image);
return $success;
protected function orient_image($file_path) {
$exif = @exif_read_data($file_path);
if ($exif === false) {
return false;
}
$orientation = intval(@$exif['Orientation']);
if (!in_array($orientation, array(3, 6, 8))) {
return false;
}
$image = @imagecreatefromjpeg($file_path);
switch ($orientation) {
case 3:
$image = @imagerotate($image, 180, 0);
break;
case 6:
$image = @imagerotate($image, 270, 0);
break;
case 8:
$image = @imagerotate($image, 90, 0);
break;
default:
return false;
}
$success = imagejpeg($image, $file_path);
// Free up memory (imagedestroy does not delete files):
@imagedestroy($image);
return $success;
}
/**
@@ -417,42 +417,42 @@ class FileUpload
$file->type = $type;
if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->_options['upload_dir']) >= 0) {
$this->handle_form_data($file, $index);
$file_path = $this->_options['upload_dir'].$file->name;
$append_file = !$this->_options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
$file_path = $this->_options['upload_dir'].$file->name;
$append_file = !$this->_options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
clearstatcache();
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
// multipart/formdata uploads (POST method uploads)
if ($append_file) {
file_put_contents(
$file_path,
fopen($uploaded_file, 'r'),
FILE_APPEND
);
} else {
dol_move_uploaded_file($uploaded_file, $file_path, 1);
}
} else {
// Non-multipart uploads (PUT method support)
file_put_contents(
$file_path,
fopen('php://input', 'r'),
$append_file ? FILE_APPEND : 0
);
}
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
// multipart/formdata uploads (POST method uploads)
if ($append_file) {
file_put_contents(
$file_path,
fopen($uploaded_file, 'r'),
FILE_APPEND
);
} else {
dol_move_uploaded_file($uploaded_file, $file_path, 1);
}
} else {
// Non-multipart uploads (PUT method support)
file_put_contents(
$file_path,
fopen('php://input', 'r'),
$append_file ? FILE_APPEND : 0
);
}
$file_size = filesize($file_path);
if ($file_size === $file->size) {
$file->url = $this->_options['upload_url'].rawurlencode($file->name);
foreach($this->_options['image_versions'] as $version => $options)
{
if ($this->create_scaled_image($file->name, $options))
{
$tmp=explode('.',$file->name);
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
}
}
} else if ($this->_options['discard_aborted_uploads']) {
unlink($file_path);
$file->error = 'abort';
if ($file_size === $file->size) {
$file->url = $this->_options['upload_url'].rawurlencode($file->name);
foreach($this->_options['image_versions'] as $version => $options)
{
if ($this->create_scaled_image($file->name, $options))
{
$tmp=explode('.',$file->name);
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
}
}
} else if ($this->_options['discard_aborted_uploads']) {
unlink($file_path);
$file->error = 'abort';
}
$file->size = $file_size;
$this->set_file_delete_url($file);
@@ -485,14 +485,14 @@ class FileUpload
*/
public function post()
{
if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
return $this->delete();
if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
return $this->delete();
}
$upload = isset($_FILES[$this->_options['param_name']]) ?
$_FILES[$this->_options['param_name']] : null;
$info = array();
if ($upload && is_array($upload['tmp_name'])) {
// param_name is an array identifier like "files[]",
// param_name is an array identifier like "files[]",
// $_FILES is a multi-dimensional array:
foreach ($upload['tmp_name'] as $index => $value) {
$info[] = $this->handle_file_upload(
@@ -505,7 +505,7 @@ class FileUpload
);
}
} elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) {
// param_name is a single object identifier like "file",
// param_name is a single object identifier like "file",
// $_FILES is a one-dimensional array:
$info[] = $this->handle_file_upload(
isset($upload['tmp_name']) ? $upload['tmp_name'] : null,
@@ -523,11 +523,11 @@ class FileUpload
}
header('Vary: Accept');
$json = json_encode($info);
$redirect = isset($_REQUEST['redirect']) ?
stripslashes($_REQUEST['redirect']) : null;
if ($redirect) {
header('Location: '.sprintf($redirect, rawurlencode($json)));
return;
$redirect = isset($_REQUEST['redirect']) ?
stripslashes($_REQUEST['redirect']) : null;
if ($redirect) {
header('Location: '.sprintf($redirect, rawurlencode($json)));
return;
}
if (isset($_SERVER['HTTP_ACCEPT']) &&
(strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) {

View File

@@ -285,12 +285,12 @@ class Form
if (! empty($tmp[2])) $savemethod=$tmp[2];
if (! empty($tmp[3])) $button_only=true;
}
else if (preg_match('/^textarea/',$inputType))
{
$tmp=explode(':',$inputType);
else if (preg_match('/^textarea/',$inputType))
{
$tmp=explode(':',$inputType);
$inputType=$tmp[0];
if (! empty($tmp[1])) $rows=$tmp[1];
if (! empty($tmp[2])) $cols=$tmp[2];
if (! empty($tmp[1])) $rows=$tmp[1];
if (! empty($tmp[2])) $cols=$tmp[2];
}
else if (preg_match('/^ckeditor/',$inputType))
{
@@ -669,6 +669,7 @@ class Form
$sql.= " FROM ".MAIN_DB_PREFIX ."societe as s";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id;
if ($filter) $sql.= " AND ".$filter;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY nom ASC";
@@ -790,20 +791,20 @@ class Form
}
}
/**
* Return list of all contacts (for a third party or all)
*
* @param int $socid Id ot third party or 0 for all
* @param string $selected Id contact pre-selectionne
* @param string $htmlname Name of HTML field ('none' for a not editable field)
* @param int $showempty 0=no empty value, 1=add an empty value
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param string $showfunction Add function into label
* @param string $moreclass Add more class to class style
* @return int <0 if KO, Nb of contact in list if OK
*/
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='')
/**
* Return list of all contacts (for a third party or all)
*
* @param int $socid Id ot third party or 0 for all
* @param string $selected Id contact pre-selectionne
* @param string $htmlname Name of HTML field ('none' for a not editable field)
* @param int $showempty 0=no empty value, 1=add an empty value
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param string $showfunction Add function into label
* @param string $moreclass Add more class to class style
* @return int <0 if KO, Nb of contact in list if OK
*/
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='')
{
print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass);
return $this->num;
@@ -978,6 +979,7 @@ class Form
{
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
}
if (! empty($user->societe_id)) $sql.= " AND u.fk_societe = ".$user->societe_id;
if (is_array($exclude) && $excludeUsers) $sql.= " AND u.rowid NOT IN ('".$excludeUsers."')";
if (is_array($include) && $includeUsers) $sql.= " AND u.rowid IN ('".$includeUsers."')";
$sql.= " ORDER BY u.name ASC";
@@ -2774,50 +2776,50 @@ class Form
print $this->selectcurrency($selected,$htmlname);
}
/**
* Load into the cache all currencies
*
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/
function load_cache_currencies()
{
/**
* Load into the cache all currencies
*
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/
function load_cache_currencies()
{
global $langs;
$langs->load("dict");
if (count($this->cache_currencies)) return 0; // Cache deja charge
$langs->load("dict");
if (count($this->cache_currencies)) return 0; // Cache deja charge
$sql = "SELECT code_iso, label, unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE active = 1";
$sql.= " ORDER BY code_iso ASC";
dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
$i++;
$i++;
}
array_multisort($label, SORT_ASC, $this->cache_currencies);
return $num;
}
else
{
dol_print_error($this->db);
return -1;
}
return $num;
}
else
{
dol_print_error($this->db);
return -1;
}
}
/**
@@ -2882,32 +2884,32 @@ class Form
print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type);
}
/**
/**
* Load into the cache vat rates of a country
*
* @param string $country_code Country code
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
* @param string $country_code Country code
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/
function load_cache_vatrates($country_code)
function load_cache_vatrates($country_code)
{
global $langs;
if (count($this->cache_vatrates)) return 0; // Cache deja charge
$sql = "SELECT DISTINCT t.taux, t.recuperableonly";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE t.fk_pays = p.rowid";
$sql.= " AND t.active = 1";
$sql.= " AND p.code IN (".$country_code.")";
$sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
if ($num)
{
for ($i = 0; $i < $num; $i++)
$sql = "SELECT DISTINCT t.taux, t.recuperableonly";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE t.fk_pays = p.rowid";
$sql.= " AND t.active = 1";
$sql.= " AND p.code IN (".$country_code.")";
$sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
if ($num)
{
for ($i = 0; $i < $num; $i++)
{
$obj = $this->db->fetch_object($resql);
$this->cache_vatrates[$i]['txtva'] = $obj->taux;
@@ -2927,7 +2929,7 @@ class Form
{
$this->error = '<font class="error">'.$this->db->error().'</font>';
return -2;
}
}
}
/**
@@ -3023,32 +3025,32 @@ class Form
if ($num > 0)
{
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{
$defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod);
$defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod);
}
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{
$defaulttx = $this->cache_vatrates[$num-1]['txtva'];
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{
$defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod);
$defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod);
}
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{
$defaulttx = $this->cache_vatrates[$num-1]['txtva'];
}
if (! $options_only) $return.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
foreach ($this->cache_vatrates as $rate)
{
$return.= '<option value="'.$rate['txtva'];
$return.= $rate['nprtva'] ? '*': '';
$return.= '<option value="'.$rate['txtva'];
$return.= $rate['nprtva'] ? '*': '';
$return.= '"';
if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr)
{
$return.= ' selected="selected"';
}
$return.= '>'.vatrate($rate['libtva']);
}
$return.= '>'.vatrate($rate['libtva']);
$return.= $rate['nprtva'] ? ' *': '';
$return.= '</option>';
@@ -3439,79 +3441,79 @@ class Form
return $out;
}
/**
* Show a multiselect form from an array.
*
/**
* Show a multiselect form from an array.
*
* @param string $htmlname Name of select
* @param array $array Array with key+value
* @param array $array Array with key+value
* @param array $selected Preselected keys
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
* @param int $value_as_key 1 to use value as key
* @param string $option Valeur de l'option en fonction du type choisi
* @param int $translate Translate and encode value
* @return string HTML multiselect string
*/
function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0)
{
* @param int $translate Translate and encode value
* @return string HTML multiselect string
*/
function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0)
{
global $conf, $langs;
$out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n";
if (is_array($array) && ! empty($array))
$out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n";
if (is_array($array) && ! empty($array))
{
if ($value_as_key) $array=array_combine($array, $array);
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && is_array($selected) && ! empty($selected))
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && is_array($selected) && ! empty($selected))
{
foreach ($selected as $selected_value)
{
foreach($array as $key => $value)
{
if ($selected_value == $key)
{
$value=$array[$selected_value];
$out.= '<option value="'.$key.'" selected="selected">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n";
unset($array[$key]);
if ($selected_value == $key)
{
$value=$array[$selected_value];
$out.= '<option value="'.$key.'" selected="selected">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n";
unset($array[$key]);
}
}
}
if (! empty($array))
{
foreach ($array as $key => $value)
foreach ($array as $key => $value)
{
$out.= '<option value="'.$key.'">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n";
$out.= '<option value="'.$key.'">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n";
}
}
}
else
{
foreach ($array as $key => $value)
{
$out.= '<option value="'.$key.'"';
if (is_array($selected) && ! empty($selected) && in_array($key, $selected))
{
$out.= ' selected="selected"';
}
$out.= '>';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n";
foreach ($array as $key => $value)
{
$out.= '<option value="'.$key.'"';
if (is_array($selected) && ! empty($selected) && in_array($key, $selected))
{
$out.= ' selected="selected"';
}
$out.= '>';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n";
}
}
}
$out.= '</select>'."\n";
return $out;
}
}
$out.= '</select>'."\n";
return $out;
}

View File

@@ -805,7 +805,7 @@ class FormFile
// Max file size
$max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize);
// Include main
// Include main
include(DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php');
// Include template

View File

@@ -450,17 +450,17 @@ class FormOther
}
}
/**
* Output a HTML code to select a color
*
* @param string $set_color Pre-selected color
* @param string $prefix Name of HTML field
* @param string $form_name Name of form
* @param int $showcolorbox 1=Show color code and color box, 0=Show only color code
* @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813')
* @return void
*/
function select_color($set_color='', $prefix='f_color', $form_name='objForm', $showcolorbox=1, $arrayofcolors='')
/**
* Output a HTML code to select a color
*
* @param string $set_color Pre-selected color
* @param string $prefix Name of HTML field
* @param string $form_name Name of form
* @param int $showcolorbox 1=Show color code and color box, 0=Show only color code
* @param array $arrayofcolors Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813')
* @return void
*/
function select_color($set_color='', $prefix='f_color', $form_name='objForm', $showcolorbox=1, $arrayofcolors='')
{
print $this->selectColor($set_color, $prefix, $form_name, $showcolorbox, $arrayofcolors);
}

View File

@@ -725,11 +725,11 @@ function activateModule($value,$withdeps=1)
$num = count($objMod->depends);
for ($i = 0; $i < $num; $i++)
{
foreach ($modulesdir as $dir)
foreach ($modulesdir as $dir)
{
if (file_exists($dir.$objMod->depends[$i].".class.php"))
{
activateModule($objMod->depends[$i]);
if (file_exists($dir.$objMod->depends[$i].".class.php"))
{
activateModule($objMod->depends[$i]);
}
}
}
@@ -741,11 +741,11 @@ function activateModule($value,$withdeps=1)
$num = count($objMod->conflictwith);
for ($i = 0; $i < $num; $i++)
{
foreach ($modulesdir as $dir)
foreach ($modulesdir as $dir)
{
if (file_exists($dir.$objMod->conflictwith[$i].".class.php"))
{
unActivateModule($objMod->conflictwith[$i],0);
if (file_exists($dir.$objMod->conflictwith[$i].".class.php"))
{
unActivateModule($objMod->conflictwith[$i],0);
}
}
}
@@ -1126,16 +1126,16 @@ function form_constantes($tableau)
print '</table>';
}
/**
* Add document model used by doc generator
*
/**
* Add document model used by doc generator
*
* @param string $name Model name
* @param string $type Model type
* @param string $label Model label
* @param string $description Model description
* @return int <0 if KO, >0 if OK
*/
function addDocumentModel($name, $type, $label='', $description='')
* @param string $type Model type
* @param string $label Model label
* @param string $description Model description
* @return int <0 if KO, >0 if OK
*/
function addDocumentModel($name, $type, $label='', $description='')
{
global $db, $conf;
@@ -1148,51 +1148,51 @@ function addDocumentModel($name, $type, $label='', $description='')
$sql.= ")";
dol_syslog("admin.lib::addDocumentModel sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
$resql=$db->query($sql);
if ($resql)
{
$db->commit();
return 1;
}
else
{
return 1;
}
else
{
dol_print_error($db);
$db->rollback();
return -1;
}
$db->rollback();
return -1;
}
}
/**
* Delete document model used by doc generator
*
* @param string $name Model name
* @param string $type Model type
* @return int <0 if KO, >0 if OK
*/
function delDocumentModel($name, $type)
{
/**
* Delete document model used by doc generator
*
* @param string $name Model name
* @param string $type Model type
* @return int <0 if KO, >0 if OK
*/
function delDocumentModel($name, $type)
{
global $db, $conf;
$db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$db->escape($name)."'";
$sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
dol_syslog("admin.lib::delDocumentModel sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
$sql.= " AND entity = ".$conf->entity;
dol_syslog("admin.lib::delDocumentModel sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
$db->commit();
return 1;
}
else
{
return 1;
}
else
{
dol_print_error($db);
$db->rollback();
return -1;
}
$db->rollback();
return -1;
}
}
?>

View File

@@ -595,99 +595,99 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
return $i;
}
/**
* Show html area for list of addresses
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Database handler
* @param Object $object Third party object
* @param string $backtopage Url to go once address is created
* @return void
*/
function show_addresses($conf,$langs,$db,$object,$backtopage='')
{
global $user;
/**
* Show html area for list of addresses
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Database handler
* @param Object $object Third party object
* @param string $backtopage Url to go once address is created
* @return void
*/
function show_addresses($conf,$langs,$db,$object,$backtopage='')
{
global $user;
global $bc;
require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php");
require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php");
$addressstatic = new Address($db);
$num = $addressstatic->fetch_lines($object->id);
$buttoncreate='';
if ($user->rights->societe->creer)
{
$buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n";
}
print "\n";
print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,'');
print "\n".'<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
$num = $addressstatic->fetch_lines($object->id);
$buttoncreate='';
if ($user->rights->societe->creer)
{
$buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n";
}
print "\n";
print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,'');
print "\n".'<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("CompanyName").'</td>';
print '<td>'.$langs->trans("Town").'</td>';
print '<td>'.$langs->trans("Country").'</td>';
print '<td>'.$langs->trans("Tel").'</td>';
print '<td>'.$langs->trans("Fax").'</td>';
print "<td>&nbsp;</td>";
print "</tr>";
if ($num > 0)
{
$var=true;
foreach ($addressstatic->lines as $address)
{
$var = !$var;
print "<tr ".$bc[$var].">";
print '<td>'.$langs->trans("Tel").'</td>';
print '<td>'.$langs->trans("Fax").'</td>';
print "<td>&nbsp;</td>";
print "</tr>";
if ($num > 0)
{
$var=true;
foreach ($addressstatic->lines as $address)
{
$var = !$var;
print "<tr ".$bc[$var].">";
print '<td>';
$addressstatic->id = $address->id;
$addressstatic->label = $address->label;
print $addressstatic->getNomUrl(1);
print '</td>';
$addressstatic->label = $address->label;
print $addressstatic->getNomUrl(1);
print '</td>';
print '<td>'.$address->name.'</td>';
print '<td>'.$address->town.'</td>';
$img=picto_from_langcode($address->country_code);
print '<td>'.($img?$img.' ':'').$address->country.'</td>';
// Lien click to dial
print '<td>';
print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL');
print '</td>';
print '<td>';
print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX');
print '</td>';
if ($user->rights->societe->creer)
{
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&amp;id='.$address->id.'&amp;socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'">';
print img_edit();
print '</a></td>';
}
print "</tr>\n";
}
}
else
{
//print "<tr ".$bc[$var].">";
//print '<td>'.$langs->trans("NoAddressYetDefined").'</td>';
//print "</tr>\n";
}
print "\n</table>\n";
print "<br>\n";
return $num;
print '<td>'.($img?$img.' ':'').$address->country.'</td>';
// Lien click to dial
print '<td>';
print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL');
print '</td>';
print '<td>';
print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX');
print '</td>';
if ($user->rights->societe->creer)
{
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&amp;id='.$address->id.'&amp;socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'">';
print img_edit();
print '</a></td>';
}
print "</tr>\n";
}
}
else
{
//print "<tr ".$bc[$var].">";
//print '<td>'.$langs->trans("NoAddressYetDefined").'</td>';
//print "</tr>\n";
}
print "\n</table>\n";
print "<br>\n";
return $num;
}
/**

View File

@@ -39,11 +39,11 @@ function contract_prepare_head($object)
$head[$h][2] = 'card';
$h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans("ContactsAddresses");
$head[$h][2] = 'contact';
$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans("ContactsAddresses");
$head[$h][2] = 'contact';
$h++;
}
@@ -53,11 +53,11 @@ function contract_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'contract');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note';
$head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note';
$h++;
}

View File

@@ -43,11 +43,11 @@ function fichinter_prepare_head($object)
$head[$h][2] = 'card';
$h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('InterventionContact');
$head[$h][2] = 'contact';
$head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('InterventionContact');
$head[$h][2] = 'contact';
$h++;
}
@@ -65,11 +65,11 @@ function fichinter_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note';
$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note';
$h++;
}

View File

@@ -614,15 +614,15 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
{
if (is_object($object))
{
$object->src_file=$dest_file;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf);
if ($result < 0) {
$error++; $errors=$interface->errors;
}
$object->src_file=$dest_file;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf);
if ($result < 0) {
$error++; $errors=$interface->errors;
}
// Fin appel triggers
}
else

View File

@@ -41,11 +41,11 @@ function facturefourn_prepare_head($object)
$head[$h][2] = 'card';
$h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$h++;
}
@@ -55,11 +55,11 @@ function facturefourn_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note';
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note';
$h++;
}
@@ -107,11 +107,11 @@ function ordersupplier_prepare_head($object)
$h++;
}
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$h++;
}
@@ -121,11 +121,11 @@ function ordersupplier_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Notes");
$head[$h][2] = 'note';
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Notes");
$head[$h][2] = 'note';
$h++;
}

View File

@@ -4008,36 +4008,36 @@ function colorArrayToHex($arraycolor,$colorifnotfound='888888')
if (! is_array($arraycolor)) return $colorifnotfound;
return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]);
}
/**
* Convert a currency code into its symbol
*
* @param string $currency_code Currency code
* @return string Currency symbol encoded into UTF8
*/
function getCurrencySymbol($currency_code)
{
global $db, $form;
$currency_sign = '';
if (! is_object($form)) $form = new Form($db);
$form->load_cache_currencies();
if (function_exists("mb_convert_encoding") && is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
{
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
{
/**
* Convert a currency code into its symbol
*
* @param string $currency_code Currency code
* @return string Currency symbol encoded into UTF8
*/
function getCurrencySymbol($currency_code)
{
global $db, $form;
$currency_sign = '';
if (! is_object($form)) $form = new Form($db);
$form->load_cache_currencies();
if (function_exists("mb_convert_encoding") && is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
{
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
{
$currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES');
}
}
else
{
$currency_sign = $currency_code;
}
return $currency_sign;
}
}
else
{
$currency_sign = $currency_code;
}
return $currency_sign;
}
if (! function_exists('getmypid'))

View File

@@ -146,7 +146,7 @@ function dol_print_object_info($object)
$deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
//$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
$deltadateforuser=round($deltadateforclient-$deltadateforserver);
//print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
//print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
// Import key
if (isset($object->import_key))

View File

@@ -40,11 +40,11 @@ function facture_prepare_head($object)
$head[$h][2] = 'compta';
$h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$h++;
}
@@ -71,11 +71,11 @@ function facture_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note';
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note';
$h++;
}

View File

@@ -25,60 +25,60 @@
if (! function_exists('json_encode'))
{
/**
* Implement json_encode for PHP that does not support it
*
* @param mixed $elements PHP Object to json encode
* @return string Json encoded string
*/
function json_encode($elements)
/**
* Implement json_encode for PHP that does not support it
*
* @param mixed $elements PHP Object to json encode
* @return string Json encoded string
*/
function json_encode($elements)
{
return dol_json_encode($elements);
}
}
/**
* Implement json_encode for PHP that does not support it
*
* @param mixed $elements PHP Object to json encode
* @return string Json encoded string
*/
function dol_json_encode($elements)
{
$num = count($elements);
// determine type
if (is_numeric(key($elements)))
{
// indexed (list)
$output = '[';
for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i)
{
if (is_array($elements[$i])) $output.= json_encode($elements[$i]);
else $output .= _val($elements[$i]);
if($i !== $last) $output.= ',';
}
$output.= ']';
}
else
{
// associative (object)
$output = '{';
$last = $num - 1;
$i = 0;
foreach($elements as $key => $value)
{
$output .= '"'.$key.'":';
if (is_array($value)) $output.= json_encode($value);
else $output .= _val($value);
if ($i !== $last) $output.= ',';
++$i;
}
$output.= '}';
}
// return
return $output;
/**
* Implement json_encode for PHP that does not support it
*
* @param mixed $elements PHP Object to json encode
* @return string Json encoded string
*/
function dol_json_encode($elements)
{
$num = count($elements);
// determine type
if (is_numeric(key($elements)))
{
// indexed (list)
$output = '[';
for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i)
{
if (is_array($elements[$i])) $output.= json_encode($elements[$i]);
else $output .= _val($elements[$i]);
if($i !== $last) $output.= ',';
}
$output.= ']';
}
else
{
// associative (object)
$output = '{';
$last = $num - 1;
$i = 0;
foreach($elements as $key => $value)
{
$output .= '"'.$key.'":';
if (is_array($value)) $output.= json_encode($value);
else $output .= _val($value);
if ($i !== $last) $output.= ',';
++$i;
}
$output.= '}';
}
// return
return $output;
}
/**
@@ -189,69 +189,69 @@ function _val($val)
if (! function_exists('json_decode'))
{
/**
* Implement json_decode for PHP that does not support it
*
* @param string $json Json encoded to PHP Object or Array
* @param bool $assoc False return an object, true return an array
* @return mixed Object or Array
*/
function json_decode($json, $assoc=false)
/**
* Implement json_decode for PHP that does not support it
*
* @param string $json Json encoded to PHP Object or Array
* @param bool $assoc False return an object, true return an array
* @return mixed Object or Array
*/
function json_decode($json, $assoc=false)
{
return dol_json_decode($json, $assoc);
}
}
/**
* Implement json_decode for PHP that does not support it
*
* @param string $json Json encoded to PHP Object or Array
* @param bool $assoc False return an object, true return an array
* @return mixed Object or Array
*/
function dol_json_decode($json, $assoc=false)
{
$comment = false;
$strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length
for ($i=0; $i<$strLength; $i++)
{
if (! $comment)
{
if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
else if ($json[$i] == ':') $out.= ' => ';
else $out.=$json[$i];
}
else $out.= $json[$i];
if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
}
$out=_unval($out);
// Return an array
/**
* Implement json_decode for PHP that does not support it
*
* @param string $json Json encoded to PHP Object or Array
* @param bool $assoc False return an object, true return an array
* @return mixed Object or Array
*/
function dol_json_decode($json, $assoc=false)
{
$comment = false;
$strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length
for ($i=0; $i<$strLength; $i++)
{
if (! $comment)
{
if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
else if ($json[$i] == ':') $out.= ' => ';
else $out.=$json[$i];
}
else $out.= $json[$i];
if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
}
$out=_unval($out);
// Return an array
if ($out != '') eval('$array = '.$out.';');
else $array=array();
// Return an object
if (! $assoc)
{
if (! empty($array))
{
$object = false;
foreach ($array as $key => $value)
{
$object->{$key} = $value;
}
return $object;
}
return false;
}
return $array;
else $array=array();
// Return an object
if (! $assoc)
{
if (! empty($array))
{
$object = false;
foreach ($array as $key => $value)
{
$object->{$key} = $value;
}
return $object;
}
return false;
}
return $array;
}
/**

View File

@@ -68,11 +68,11 @@ function commande_prepare_head($object)
$h++;
}
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$h++;
}
@@ -91,11 +91,11 @@ function commande_prepare_head($object)
$head[$h][2] = 'documents';
$h++;
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note';
$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note';
$h++;
}

View File

@@ -714,7 +714,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
}
}
/**
/**
* Show linked objects for PDF generation
*
* @param PDF &$pdf Object PDF
@@ -728,8 +728,8 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
* @param string $default_font_size Font size
* @param HookManager $hookmanager Hook manager object
* @return void
*/
function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false)
*/
function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false)
{
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs,$hookmanager);
if (! empty($linkedobjects))
@@ -743,14 +743,14 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al
if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"]))
{
$posy+=3;
$pdf->SetXY($posx,$posy);
$posy+=3;
$pdf->SetXY($posx,$posy);
$pdf->MultiCell($w, $h, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', $align);
}
}
}
return $pdf->getY();
return $pdf->getY();
}
/**
@@ -1354,26 +1354,26 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false)
*/
function pdf_getCurrencySymbol(&$pdf, $currency_code)
{
global $db, $form;
$currency_sign = '';
if (! is_object($form)) $form = new Form($db);
$form->load_cache_currencies();
if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
{
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
{
$currency_sign.= $pdf->unichr($unicode);
}
}
else
{
$currency_sign = $currency_code;
}
global $db, $form;
$currency_sign = '';
if (! is_object($form)) $form = new Form($db);
$form->load_cache_currencies();
if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
{
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
{
$currency_sign.= $pdf->unichr($unicode);
}
}
else
{
$currency_sign = $currency_code;
}
return $currency_sign;
}
@@ -1417,25 +1417,25 @@ function pdf_getLinkedObjects($object,$outputlangs,$hookmanager=false)
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs);
}
}
else if ($objecttype == 'contrat')
{
$outputlangs->load('contracts');
$num=count($objects);
for ($i=0;$i<$num;$i++)
else if ($objecttype == 'contrat')
{
$outputlangs->load('contracts');
$num=count($objects);
for ($i=0;$i<$num;$i++)
{
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref);
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date_contrat,'day','',$outputlangs);
}
}
}
}
// For add external linked objects
if (is_object($hookmanager))
{
$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
$action='';
$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
$action='';
$hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
}

View File

@@ -65,9 +65,9 @@ function propal_prepare_head($object)
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$h++;
}

View File

@@ -379,9 +379,9 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
}
else
{
$sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
}
}

View File

@@ -164,12 +164,12 @@ function dol_loginfunction($langs,$conf,$mysoc)
global $dolibarr_main_demo,$db;
global $smartphone,$hookmanager;
// Instantiate hooks of thirdparty module only if not already define
if (! is_object($hookmanager))
{
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($db);
}
// Instantiate hooks of thirdparty module only if not already define
if (! is_object($hookmanager))
{
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($db);
}
$hookmanager->initHooks(array('mainloginpage'));
$langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang'));
@@ -239,8 +239,8 @@ function dol_loginfunction($langs,$conf,$mysoc)
}
// Execute hook getLoginPageOptions
// Should be an array with differents options in $hookmanager->resArray
$parameters=array('entity' => $_POST['entity']);
// Should be an array with differents options in $hookmanager->resArray
$parameters=array('entity' => $_POST['entity']);
$hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks
// Login

View File

@@ -47,13 +47,13 @@ function shipping_prepare_head($object)
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)
{
// delivery link
// delivery link
$object->fetchObjectLinked($object->id,$object->element);
if (! empty($object->linkedObjectsIds['delivery'][0]))
{
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
$head[$h][1] = $langs->trans("DeliveryCard");
$head[$h][2] = 'delivery';
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
$head[$h][1] = $langs->trans("DeliveryCard");
$head[$h][2] = 'delivery';
$h++;
}
}

View File

@@ -1370,7 +1370,7 @@ abstract class DolibarrModules
{
foreach($this->module_parts as $key => $value)
{
// If entity is defined
// If entity is defined
if (is_array($value) && isset($value['entity'])) $entity = $value['entity'];
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

View File

@@ -300,7 +300,7 @@ class pdf_edison extends ModelePDFCommandes
// Actions on extra fields (by external module or standard code)
if (! is_object($hookmanager))
{
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
@@ -651,7 +651,7 @@ class pdf_edison extends ModelePDFCommandes
$posy+=1;
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager);
}

View File

@@ -929,8 +929,8 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
$posy+=2;
$posy+=2;
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);

View File

@@ -982,9 +982,9 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
}
$posy+=2;
// Show list of linked objects
$posy+=2;
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
if ($showaddress)

View File

@@ -417,13 +417,13 @@ function thirdparty_doc_create($db, &$object, $message, $modele, $outputlangs)
{
$outputlangs->charset_output=$sav_charset_output;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
return 1;

View File

@@ -42,7 +42,7 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$langs->load("products");
$langs->load("other");
$id=GETPOST('id','int');
$id=GETPOST('id','int');
$action=GETPOST('action','alpha');
$modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service';
$original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):'';
@@ -65,12 +65,12 @@ if (! $accessallowed)
}
$object = new Product($db);
if ($id > 0)
{
if ($id > 0)
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db,'Failed to load object');
$dir=$conf->product->multidir_output[$object->entity]; // By default
if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity];
$dir=$conf->product->multidir_output[$object->entity]; // By default
if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity];
if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity];
}

View File

@@ -16,17 +16,17 @@
*
*/
$module = $object->element;
$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page
// Special cases
if ($module == 'propal') { $permission=$user->rights->propale->creer; }
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
$module = $object->element;
$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page
// Special cases
if ($module == 'propal') { $permission=$user->rights->propale->creer; }
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
$companystatic=new Societe($db);
$contactstatic=new Contact($db);
$contactstatic=new Contact($db);
$userstatic=new User($db);
?>
@@ -73,8 +73,8 @@ $userstatic=new User($db);
<?php if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) { ?>
<td>
<?php
$events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
$events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
print $form->select_company($object->socid,'socid','',1,0,0,$events);
?>
</td>
@@ -113,12 +113,12 @@ $userstatic=new User($db);
<?php $var=true; ?>
<?php
foreach(array('internal','external') as $source) {
$tab = $object->liste_contact(-1,$source);
$num=count($tab);
$i = 0;
while ($i < $num) {
foreach(array('internal','external') as $source) {
$tab = $object->liste_contact(-1,$source);
$num=count($tab);
$i = 0;
while ($i < $num) {
$var = !$var;
?>
@@ -129,36 +129,36 @@ $userstatic=new User($db);
</td>
<td align="left">
<?php
if ($tab[$i]['socid'] > 0)
{
$companystatic->fetch($tab[$i]['socid']);
echo $companystatic->getNomUrl(1);
}
if ($tab[$i]['socid'] < 0)
{
echo $conf->global->MAIN_INFO_SOCIETE_NOM;
}
if (! $tab[$i]['socid'])
{
echo '&nbsp;';
if ($tab[$i]['socid'] > 0)
{
$companystatic->fetch($tab[$i]['socid']);
echo $companystatic->getNomUrl(1);
}
if ($tab[$i]['socid'] < 0)
{
echo $conf->global->MAIN_INFO_SOCIETE_NOM;
}
if (! $tab[$i]['socid'])
{
echo '&nbsp;';
}
?>
</td>
<td>
<?php
if ($tab[$i]['source']=='internal')
{
$userstatic->id=$tab[$i]['id'];
$userstatic->lastname=$tab[$i]['lastname'];
$userstatic->firstname=$tab[$i]['firstname'];
echo $userstatic->getNomUrl(1);
}
if ($tab[$i]['source']=='external')
{
$contactstatic->id=$tab[$i]['id'];
$contactstatic->lastname=$tab[$i]['lastname'];
$contactstatic->firstname=$tab[$i]['firstname'];
echo $contactstatic->getNomUrl(1);
if ($tab[$i]['source']=='internal')
{
$userstatic->id=$tab[$i]['id'];
$userstatic->lastname=$tab[$i]['lastname'];
$userstatic->firstname=$tab[$i]['firstname'];
echo $userstatic->getNomUrl(1);
}
if ($tab[$i]['source']=='external')
{
$contactstatic->id=$tab[$i]['id'];
$contactstatic->lastname=$tab[$i]['lastname'];
$contactstatic->firstname=$tab[$i]['firstname'];
echo $contactstatic->getNomUrl(1);
}
?>
</td>

View File

@@ -35,7 +35,7 @@ print '<!-- Includes for JQuery (Ajax library) -->'."\n";
if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" />'."\n"; // JQuery
// JQuery. Must be before other includes
$ext='.js';
$ext='.js';
if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) $ext='.jgz';
print '<!-- Includes JS for JQuery -->'."\n";
if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js"></script>'."\n";

View File

@@ -111,37 +111,37 @@ class InterfacePaypalWorkflow
}
else
{
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
$soc = new Societe($this->db);
// Parse element/subelement (ex: project_task)
$element = $path = $filename = $object->source;
if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
{
$element = $path = $regs[1];
$filename = $regs[2];
}
// For compatibility
if ($element == 'order') {
$path = $filename = 'commande';
}
if ($element == 'invoice') {
$path = 'compta/facture'; $filename = 'facture';
}
dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
$classname = ucfirst($filename);
$obj = new $classname($this->db);
$ret = $obj->fetch('',$object->ref);
if ($ret < 0) return -1;
// Add payer id
$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
// Add transaction id
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
$soc = new Societe($this->db);
// Parse element/subelement (ex: project_task)
$element = $path = $filename = $object->source;
if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
{
$element = $path = $regs[1];
$filename = $regs[2];
}
// For compatibility
if ($element == 'order') {
$path = $filename = 'commande';
}
if ($element == 'invoice') {
$path = 'compta/facture'; $filename = 'facture';
}
dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
$classname = ucfirst($filename);
$obj = new $classname($this->db);
$ret = $obj->fetch('',$object->ref);
if ($ret < 0) return -1;
// Add payer id
$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
// Add transaction id
$obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
}