33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
45$langs->loadLangs(array(
'other',
'products'));
51$action =
GETPOST(
'action',
'aZ09');
52$confirm =
GETPOST(
'confirm',
'alpha');
55$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
56$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
58 $socid = $user->socid;
62$hookmanager->initHooks(array(
'productdocuments'));
66$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
67$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
69if (empty($page) || $page == -1) {
72$offset = $limit * $page;
79 $sortfield =
"position_name";
84if ($id > 0 || !empty($ref)) {
85 $result =
$object->fetch($id, $ref);
87 if (isModEnabled(
"product")) {
88 $upload_dir = $conf->product->multidir_output[
$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object,
'product');
89 } elseif (isModEnabled(
"service")) {
90 $upload_dir = $conf->service->multidir_output[
$object->entity].
'/'.
get_exdir(0, 0, 0, 1, $object,
'product');
94 if (isModEnabled(
"product")) {
95 $upload_dirold = $conf->product->multidir_output[
$object->entity].
'/'.substr(substr(
"000".
$object->id, -2), 1, 1).
'/'.substr(substr(
"000".
$object->id, -2), 0, 1).
'/'.
$object->id.
"/photos";
97 $upload_dirold = $conf->service->multidir_output[
$object->entity].
'/'.substr(substr(
"000".
$object->id, -2), 1, 1).
'/'.substr(substr(
"000".
$object->id, -2), 0, 1).
'/'.
$object->id.
"/photos";
102$modulepart =
'produit';
106 if (
$object->type == $object::TYPE_PRODUCT) {
109 if (
$object->type == $object::TYPE_SERVICE) {
113 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
123$parameters = array(
'id'=>$id);
124$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
129if (empty($reshook)) {
132 if ($action ==
'confirm_deletefile' && $confirm ==
'yes' && $permissiontoadd) {
134 $urlfile =
GETPOST(
'urlfile',
'alpha');
135 $filename = basename($urlfile);
137 $filetomerge->fk_product =
$object->id;
138 $filetomerge->file_name = $filename;
139 $result = $filetomerge->delete_by_file($user);
147 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
150if ($action ==
'filemerge' && $permissiontoadd) {
151 $is_refresh =
GETPOST(
'refresh');
152 if (empty($is_refresh)) {
153 $filetomerge_file_array =
GETPOST(
'filetoadd');
155 $filetomerge_file_array =
GETPOST(
'filetoadd');
158 $lang_id =
GETPOST(
'lang_id',
'aZ09');
165 $result = $filetomerge->delete_by_product($user,
$object->id, $lang_id);
167 $result = $filetomerge->delete_by_product($user,
$object->id);
174 if (is_array($filetomerge_file_array)) {
175 foreach ($filetomerge_file_array as $filetomerge_file) {
176 $filetomerge->fk_product =
$object->id;
177 $filetomerge->file_name = $filetomerge_file;
180 $filetomerge->lang = $lang_id;
183 $result = $filetomerge->create($user);
197$form =
new Form($db);
199$title = $langs->trans(
'ProductServiceCard');
203 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Documents');
204 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
207 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Documents');
208 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
211llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-card_document');
216 $titre = $langs->trans(
"CardProduct".
$object->type);
221 $parameters = array();
222 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
223 print $hookmanager->resPrint;
229 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ? SORT_DESC : SORT_ASC), 1);
232 $filearrayold =
dol_dir_list($upload_dirold,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ? SORT_DESC : SORT_ASC), 1);
233 $filearray = array_merge($filearray, $filearrayold);
237 foreach ($filearray as $key => $file) {
238 $totalsize += $file[
'size'];
242 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
243 $object->next_prev_filter =
"fk_product_type = ".((int)
$object->type);
246 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
250 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref');
252 print
'<div class="fichecenter">';
254 print
'<div class="underbanner clearboth"></div>';
255 print
'<table class="border tableforfield centpercent">';
257 print
'<tr><td class="titlefield">'.$langs->trans(
"NbOfAttachedFiles").
'</td><td colspan="3">'.count($filearray).
'</td></tr>';
258 print
'<tr><td>'.$langs->trans(
"TotalSizeOfAttachedFiles").
'</td><td colspan="3">'.
dol_print_size($totalsize, 1, 1).
'</td></tr>';
262 print
'<div class="clearboth"></div>';
266 $param =
'&id='.$object->id;
267 include DOL_DOCUMENT_ROOT.
'/core/tpl/document_actions_post_headers.tpl.php';
275 $lang_id =
GETPOST(
'lang_id',
'aZ09');
276 $result = $filetomerge->fetch_by_product(
$object->id, $lang_id);
278 $result = $filetomerge->fetch_by_product(
$object->id);
281 $form =
new Form($db);
284 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'\.meta$',
'name', SORT_ASC, 1);
287 $filearray = array_merge($filearray,
dol_dir_list($upload_dirold,
"files", 0,
'',
'\.meta$',
'name', SORT_ASC, 1));
291 if (count($filearray) > 0) {
294 if (count($filetomerge->lines) > 0) {
295 print $langs->trans(
'PropalMergePdfProductActualFile');
298 print
'<form name="filemerge" action="'.DOL_URL_ROOT.
'/product/document.php?id='.
$object->id.
'" method="post">';
299 print
'<input type="hidden" name="token" value="'.newToken().
'">';
300 print
'<input type="hidden" name="action" value="filemerge">';
301 if (count($filetomerge->lines) == 0) {
302 print $langs->trans(
'PropalMergePdfProductChooseFile');
305 print
'<table class="noborder">';
309 $langs->load(
"languages");
311 print
'<tr class="liste_titre"><td>';
313 $default_lang = empty($lang_id) ? $langs->getDefaultLang() : $lang_id;
315 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
317 print
Form::selectarray(
'lang_id', $langs_available, $default_lang, 0, 0, 0,
'', 0, 0, 0,
'ASC');
320 print
'<input type="submit" class="button" name="refresh" value="'.$langs->trans(
'Refresh').
'">';
326 foreach ($filearray as $filetoadd) {
327 if ($ext = pathinfo($filetoadd[
'name'], PATHINFO_EXTENSION) ==
'pdf') {
329 $filename = $filetoadd[
'name'];
332 if (array_key_exists($filetoadd[
'name'].
'_'.$default_lang, $filetomerge->lines)) {
333 $filename = $filetoadd[
'name'].
' - '.$langs->trans(
'Language_'.$default_lang);
334 $checked =
' checked ';
337 if (array_key_exists($filetoadd[
'name'], $filetomerge->lines)) {
338 $checked =
' checked ';
342 print
'<tr class="oddeven"><td>';
343 print
'<input type="checkbox" '.$checked.
' name="filetoadd[]" id="filetoadd" value="'.$filetoadd[
'name'].
'">'.$filename.
'</input>';
349 print
'<input type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'">';
358 print $langs->trans(
"ErrorUnknown");
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Put here description of your class.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
product_prepare_head($object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.