27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
32 $langs->loadLangs(array(
"products",
"other"));
35 $action =
GETPOST(
'action',
'aZ09');
36 $modulepart =
GETPOST(
'modulepart',
'alpha') ?
GETPOST(
'modulepart',
'alpha') :
'produit|service';
37 $original_file =
GETPOST(
"file");
38 $backtourl =
GETPOST(
'backtourl');
39 $cancel =
GETPOST(
'cancel',
'alpha');
41 $file =
GETPOST(
'file',
'alpha');
43 $website =
GETPOST(
'website',
'alpha');
49 if ($modulepart ==
'produit' || $modulepart ==
'product' || $modulepart ==
'service' || $modulepart ==
'produit|service')
51 $result =
restrictedArea($user,
'produit|service', $id,
'product&product');
52 if ($modulepart ==
'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire))
accessforbidden();
54 } elseif ($modulepart ==
'project')
59 } elseif ($modulepart ==
'bom')
64 } elseif ($modulepart ==
'member')
66 $result =
restrictedArea($user,
'adherent', $id,
'',
'',
'fk_soc',
'rowid');
69 } elseif ($modulepart ==
'user')
74 } elseif ($modulepart ==
'tax')
76 $result =
restrictedArea($user, $modulepart, $id,
'chargesociales',
'charges');
79 } elseif ($modulepart ==
'bank')
84 } elseif ($modulepart ==
'medias')
86 $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
89 } elseif ($modulepart ==
'facture_fourn' || $modulepart ==
'facture_fournisseur')
91 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture');
97 if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire))
accessforbidden();
109 if ($modulepart ==
'produit' || $modulepart ==
'product' || $modulepart ==
'service' || $modulepart ==
'produit|service')
111 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
115 $result = $object->fetch($id);
117 $dir = $conf->product->multidir_output[$object->entity];
121 } elseif ($modulepart ==
'project')
123 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
127 $result = $object->fetch($id);
129 $dir = $conf->project->multidir_output[$object->entity];
131 } elseif ($modulepart ==
'propal')
133 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
134 $object =
new Propal($db);
137 $result = $object->fetch($id);
139 $dir = $conf->propal->multidir_output[$object->entity];
141 } elseif ($modulepart ==
'holiday')
143 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
147 $result = $object->fetch($id);
149 $dir = $conf->$modulepart->dir_output;
151 } elseif ($modulepart ==
'member')
153 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
157 $result = $object->fetch($id);
159 $dir = $conf->adherent->dir_output;
161 } elseif ($modulepart ==
'societe')
163 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
167 $result = $object->fetch($id);
169 $dir = $conf->$modulepart->dir_output;
171 } elseif ($modulepart ==
'user')
173 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
174 $object =
new User($db);
177 $result = $object->fetch($id);
179 $dir = $conf->$modulepart->dir_output;
181 } elseif ($modulepart ==
'expensereport')
183 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
187 $result = $object->fetch($id);
189 $dir = $conf->expensereport->dir_output;
191 } elseif ($modulepart ==
'tax')
193 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
197 $result = $object->fetch($id);
199 $dir = $conf->$modulepart->dir_output;
201 } elseif ($modulepart ==
'ticket')
203 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
204 $object =
new Ticket($db);
207 $result = $object->fetch($id);
209 $dir = $conf->$modulepart->dir_output;
211 } elseif ($modulepart ==
'bom')
213 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
214 $object =
new BOM($db);
217 $result = $object->fetch($id);
219 $dir = $conf->$modulepart->dir_output;
221 } elseif ($modulepart ==
'mrp') {
222 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
223 $object =
new MO($db);
226 $result = $object->fetch($id);
228 $dir = $conf->$modulepart->dir_output;
230 } elseif ($modulepart ==
'bank') {
231 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
235 $result = $object->fetch($id);
237 $dir = $conf->bank->dir_output;
239 } elseif ($modulepart ==
'facture') {
240 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
244 $result = $object->fetch($id);
246 $dir = $conf->$modulepart->dir_output;
248 } elseif ($modulepart ==
'facture_fourn' || $modulepart ==
'facture_fournisseur') {
249 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
253 $result = $object->fetch($id);
255 $dir = $conf->fournisseur->dir_output.
'/facture';
257 } elseif ($modulepart ==
'medias') {
258 $dir = $dolibarr_main_data_root.
'/'.$modulepart;
260 print 'Bug: Action crop for modulepart = '.$modulepart.
' is not supported yet by photos_resize.php.';
263 if (empty($backtourl))
267 if (in_array($modulepart, array(
'product',
'produit',
'service',
'produit|service'))) $backtourl = DOL_URL_ROOT.
"/product/document.php?id=".$id.
'&file='.urldecode($file);
268 elseif (in_array($modulepart, array(
'expensereport'))) $backtourl = DOL_URL_ROOT."/expensereport/document.php?
id=".$id.'&file='.urldecode($file);
269 elseif (in_array($modulepart, array('holiday'))) $backtourl = DOL_URL_ROOT."/holiday/document.php?
id=".$id.'&file='.urldecode($file);
270 elseif (in_array($modulepart, array('member'))) $backtourl = DOL_URL_ROOT."/adherents/document.php?
id=".$id.'&file='.urldecode($file);
271 elseif (in_array($modulepart, array('project'))) $backtourl = DOL_URL_ROOT."/projet/document.php?
id=".$id.'&file='.urldecode($file);
272 elseif (in_array($modulepart, array('propal'))) $backtourl = DOL_URL_ROOT."/comm/propal/document.php?
id=".$id.'&file='.urldecode($file);
273 elseif (in_array($modulepart, array('societe'))) $backtourl = DOL_URL_ROOT."/societe/document.php?
id=".$id.'&file='.urldecode($file);
274 elseif (in_array($modulepart, array('tax'))) $backtourl = DOL_URL_ROOT."/compta/sociales/document.php?
id=".$id.'&file='.urldecode($file);
275 elseif (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?
id=".$id.'&file='.urldecode($file);
276 elseif (in_array($modulepart, array('
user'))) $backtourl = DOL_URL_ROOT."/
user/document.php?
id=".$id.'&file='.urldecode($file);
277 elseif (in_array($modulepart, array('facture'))) $backtourl = DOL_URL_ROOT."/compta/facture/document.php?
id=".$id.'&file='.urldecode($file);
278 elseif (in_array($modulepart, array('facture_fourn', 'facture_fournisseur'))) $backtourl = DOL_URL_ROOT."/fourn/facture/document.php?
id=".$id.'&file='.urldecode($file);
279 elseif (in_array($modulepart, array('bank')) && preg_match('/\/statement\/([^\/]+)\
281 $backtourl = DOL_URL_ROOT."/compta/bank/account_statement_document.php?
id=".$id.'&num='.urlencode($num).'&file='.urldecode($file);
282 } elseif (in_array($modulepart, array('bank'))) $backtourl = DOL_URL_ROOT."/compta/bank/document.php?
id=".$id.'&file='.urldecode($file);
283 elseif (in_array($modulepart, array('mrp'))) $backtourl = DOL_URL_ROOT."/mrp/mo_document.php?
id=".$id.'&file='.urldecode($file);
284 elseif (in_array($modulepart, array('medias'))) {
285 $section_dir = dirname($file);
286 if (!preg_match(
'/\/$/', $section_dir)) $section_dir .=
'/';
287 $backtourl = DOL_URL_ROOT.
"/website/index.php?action=file_manager&website=".$website.
'§ion_dir='.urlencode($section_dir);
290 else $backtourl = DOL_URL_ROOT.
"/".$modulepart.
"/".$modulepart.
"_document.php?id=".$id.
'&file='.urldecode($file);
300 header(
"Location: ".$backtourl);
303 dol_print_error(
'',
'Cancel on photo_resize with a not supported value of modulepart='.$modulepart);
311 print 'Bug: Value for $dir could not be defined.';
314 $fullpath = $dir.
"/".$original_file;
318 if ($result == $fullpath)
321 if (is_object($object)) {
322 $object->addThumbs($fullpath);
326 $rel_filename = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $fullpath);
327 $rel_filename = preg_replace(
'/^[\\/]/',
'', $rel_filename);
329 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
331 $result = $ecmfile->fetch(0,
'', $rel_filename);
334 $filename = basename($rel_filename);
335 $rel_dir = dirname($rel_filename);
336 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
337 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
340 $result = $ecmfile->update($user);
341 } elseif ($result == 0)
343 $filename = basename($rel_filename);
344 $rel_dir = dirname($rel_filename);
345 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
346 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
348 $ecmfile->filepath = $rel_dir;
349 $ecmfile->filename = $filename;
351 $ecmfile->fullpath_orig = $fullpath;
352 $ecmfile->gen_or_uploaded =
'unknown';
353 $ecmfile->description =
'';
354 $ecmfile->keyword =
'';
355 $result = $ecmfile->create($user);
360 $result = $ecmfile->create($user);
365 header(
"Location: ".$backtourl);
368 dol_print_error(
'',
'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart);
373 $_GET[
'file'] = $_POST[
"file"];
379 if ($action ==
'confirm_crop')
382 print 'Bug: Value for $dir could not be defined.';
385 $fullpath = $dir.
"/".$original_file;
390 if ($result == $fullpath)
392 if (is_object($object)) {
393 $object->addThumbs($fullpath);
397 $rel_filename = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $fullpath);
398 $rel_filename = preg_replace(
'/^[\\/]/',
'', $rel_filename);
400 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
402 $result = $ecmfile->fetch(0,
'', $rel_filename);
405 $filename = basename($rel_filename);
406 $rel_dir = dirname($rel_filename);
407 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
408 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
411 $result = $ecmfile->update($user);
412 } elseif ($result == 0)
414 $filename = basename($rel_filename);
415 $rel_dir = dirname($rel_filename);
416 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
417 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
419 $ecmfile->filepath = $rel_dir;
420 $ecmfile->filename = $filename;
422 $ecmfile->fullpath_orig = $fullpath;
423 $ecmfile->gen_or_uploaded =
'unknown';
424 $ecmfile->description =
'';
425 $ecmfile->keyword =
'';
426 $result = $ecmfile->create($user);
431 $result = $ecmfile->create($user);
435 header(
"Location: ".$backtourl);
438 dol_print_error(
'',
'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart);
443 $_GET[
'file'] = $_POST[
"file"];
453 $title= $langs->trans(
"ImageEditor");
455 llxHeader($head, $title,
'',
'', 0, 0, array(
'/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js',
'/core/js/lib_photosresize.js'), array(
'/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css'));
461 $height = $infoarray[
'height'];
462 $width = $infoarray[
'width'];
463 print $langs->trans(
"CurrentInformationOnImage").
': ';
464 print $langs->trans(
"Width").
': <strong>'.$width.
'</strong> x '.$langs->trans(
"Height").
': <strong>'.$height.
'</strong><br>';
473 print '<!-- Form to resize -->'.
"\n";
474 print '<form name="redim_file" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.($num ?
'&num='.$num :
'').
'" method="POST">';
475 print '<input type="hidden" name="token" value="'.newToken().
'">';
477 print '<fieldset id="redim_file">';
478 print '<legend>'.$langs->trans(
"Resize").
'</legend>';
479 print $langs->trans(
"ResizeDesc").
'<br>';
480 print $langs->trans(
"NewLength").
': <input name="sizex" type="number" class="flat maxwidth50"> px '.$langs->trans(
"or").
' ';
481 print $langs->trans(
"NewHeight").
': <input name="sizey" type="number" class="flat maxwidth50"> px <br>';
483 print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'" />';
484 print '<input type="hidden" name="action" value="confirm_resize" />';
485 print '<input type="hidden" name="product" value="'.$id.
'" />';
486 print '<input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).
'" />';
487 print '<input type="hidden" name="id" value="'.$id.
'" />';
489 print '<input class="button" id="submitresize" name="sendit" value="'.dol_escape_htmltag($langs->trans(
"Resize")).
'" type="submit" />';
491 print '<input type="submit" id="cancelresize" name="cancel" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" />';
492 print '</fieldset>'.
"\n";
503 if (!empty($conf->use_javascript_ajax))
506 $height = $infoarray[
'height'];
507 $width = $infoarray[
'width'];
508 $widthforcrop = $width; $refsizeforcrop =
'orig'; $ratioforcrop = 1;
510 if (!empty($_SESSION[
'dol_screenwidth']) && ($widthforcrop > round($_SESSION[
'dol_screenwidth'] / 2)))
513 $widthforcrop = round($_SESSION[
'dol_screenwidth'] / $ratioforcrop);
514 $refsizeforcrop =
'screenwidth';
517 print '<!-- Form to crop -->'.
"\n";
518 print '<fieldset id="redim_file">';
519 print '<legend>'.$langs->trans(
"Recenter").
'</legend>';
520 print $langs->trans(
"DefineNewAreaToPick").
'...<br>';
521 print '<br><div class="center">';
522 print '<div style="border: 1px solid #888888; width: '.$widthforcrop.
'px;">';
523 print '<img src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$object->entity.
'&file='.urlencode($original_file).
'" alt="" id="cropbox" width="'.$widthforcrop.
'px"/>';
527 print '<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.($num ?
'&num='.$num :
'').
'" method="POST">';
528 print '<input type="hidden" name="token" value="'.newToken().
'">';
530 <div class="jc_coords">
531 '.$langs->trans(
"NewSizeAfterCropping").
':
532 <label>X1 <input type="number" class="flat maxwidth50" id="x" name="x" /></label>
533 <label>Y1 <input type="number" class="flat maxwidth50" id="y" name="y" /></label>
534 <label>X2 <input type="number" class="flat maxwidth50" id="x2" name="x2" /></label>
535 <label>Y2 <input type="number" class="flat maxwidth50" id="y2" name="y2" /></label>
536 <label>W <input type="number" class="flat maxwidth50" id="w" name="w" /></label>
537 <label>H <input type="number" class="flat maxwidth50" id="h" name="h" /></label>
540 <input type="hidden" id="file" name="file" value="'.
dol_escape_htmltag($original_file).
'" />
541 <input type="hidden" id="action" name="action" value="confirm_crop" />
542 <input type="hidden" id="product" name="product" value="'.
dol_escape_htmltag($id).
'" />
543 <input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'.$refsizeforcrop.
'" />
544 <input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'.$ratioforcrop.
'" /><!-- field used by core/lib/lib_photoresize.js -->
548 <input type="submit" id="submitcrop" name="submitcrop" class="button" value="'.
dol_escape_htmltag($langs->trans(
"Recenter")).
'" />
550 <input type="submit" id="cancelcrop" name="cancel" class="button button-cancel" value="'.
dol_escape_htmltag($langs->trans(
"Cancel")).
'" />
552 print '</fieldset>'.
"\n";
557 print '<script type="text/javascript" language="javascript">
558 jQuery(document).ready(function() {
559 $("#submitcrop").click(function(e) {
560 console.log("We click on submitcrop");
561 var idClicked = e.target.id;
562 if (parseInt(jQuery(\'#w\').val())) return true;
563 alert(\''.dol_escape_js($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Dimension"))).
'\');
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of the module paid holiday.
dol_getImageSize($file, $url=false)
Return size of image file on disk (Supported extensions are gif, jpg, png and bmp) ...
Class to manage products or services.
Class to manage Dolibarr users.
const TYPE_SERVICE
Service.
Class to manage suppliers invoices.
const TYPE_PRODUCT
Regular product.
Class to manage bank accounts.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage members of a foundation.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage Trips and Expenses.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage invoices.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Class to manage ECM files.
dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0)
Resize or crop an image file (Supported extensions are gif, jpg, png and bmp)
Class to manage proposals.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...