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');
47 if (empty($modulepart)) {
51 if ($modulepart ==
'produit' || $modulepart ==
'product' || $modulepart ==
'service' || $modulepart ==
'produit|service') {
52 $result =
restrictedArea($user,
'produit|service', $id,
'product&product');
53 if ($modulepart ==
'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire)) {
57 } elseif ($modulepart ==
'project') {
59 if (empty($user->rights->projet->lire)) {
63 } elseif ($modulepart ==
'bom') {
65 if (empty($user->rights->bom->read)) {
69 } elseif ($modulepart ==
'member') {
70 $result =
restrictedArea($user,
'adherent', $id,
'',
'',
'fk_soc',
'rowid');
71 if (empty($user->rights->adherent->lire)) {
75 } elseif ($modulepart ==
'user') {
76 $result =
restrictedArea($user, $modulepart, $id, $modulepart, $modulepart);
77 if (empty($user->rights->user->user->lire)) {
81 } elseif ($modulepart ==
'tax') {
82 $result =
restrictedArea($user, $modulepart, $id,
'chargesociales',
'charges');
83 if (empty($user->rights->tax->charges->lire)) {
87 } elseif ($modulepart ==
'bank') {
89 if (empty($user->rights->banque->lire)) {
93 } elseif ($modulepart ==
'medias') {
94 $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
99 } elseif ($modulepart ==
'facture_fourn' || $modulepart ==
'facture_fournisseur') {
100 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture');
101 if (empty($user->rights->fournisseur->facture->lire)) {
108 if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire)) {
116 if (!$accessallowed) {
121 if ($modulepart ==
'produit' || $modulepart ==
'product' || $modulepart ==
'service' || $modulepart ==
'produit|service') {
122 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
125 $result = $object->fetch($id);
129 $dir = $conf->product->multidir_output[$object->entity];
131 $dir = $conf->product->multidir_output[$object->entity];
134 $dir = $conf->service->multidir_output[$object->entity];
137 } elseif ($modulepart ==
'project') {
138 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
141 $result = $object->fetch($id);
145 $dir = $conf->project->multidir_output[$object->entity];
147 } elseif ($modulepart ==
'propal') {
148 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
149 $object =
new Propal($db);
151 $result = $object->fetch($id);
155 $dir = $conf->propal->multidir_output[$object->entity];
157 } elseif ($modulepart ==
'holiday') {
158 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
161 $result = $object->fetch($id);
165 $dir = $conf->$modulepart->dir_output;
167 } elseif ($modulepart ==
'member') {
168 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
171 $result = $object->fetch($id);
175 $dir = $conf->adherent->dir_output;
177 } elseif ($modulepart ==
'societe') {
178 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
181 $result = $object->fetch($id);
185 $dir = $conf->$modulepart->dir_output;
187 } elseif ($modulepart ==
'user') {
188 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
189 $object =
new User($db);
191 $result = $object->fetch($id);
195 $dir = $conf->$modulepart->dir_output;
197 } elseif ($modulepart ==
'expensereport') {
198 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
201 $result = $object->fetch($id);
205 $dir = $conf->expensereport->dir_output;
207 } elseif ($modulepart ==
'tax') {
208 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
211 $result = $object->fetch($id);
215 $dir = $conf->$modulepart->dir_output;
217 } elseif ($modulepart ==
'ticket') {
218 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
219 $object =
new Ticket($db);
221 $result = $object->fetch($id);
225 $dir = $conf->$modulepart->dir_output;
227 } elseif ($modulepart ==
'bom') {
228 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
229 $object =
new BOM($db);
231 $result = $object->fetch($id);
235 $dir = $conf->$modulepart->dir_output;
237 } elseif ($modulepart ==
'mrp') {
238 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
239 $object =
new MO($db);
241 $result = $object->fetch($id);
245 $dir = $conf->$modulepart->dir_output;
247 } elseif ($modulepart ==
'bank') {
248 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
251 $result = $object->fetch($id);
255 $dir = $conf->bank->dir_output;
257 } elseif ($modulepart ==
'facture') {
258 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
261 $result = $object->fetch($id);
265 $dir = $conf->$modulepart->dir_output;
267 } elseif ($modulepart ==
'facture_fourn' || $modulepart ==
'facture_fournisseur') {
268 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
271 $result = $object->fetch($id);
275 $dir = $conf->fournisseur->dir_output.
'/facture';
277 } elseif ($modulepart ==
'medias') {
278 $dir = $dolibarr_main_data_root.
'/'.$modulepart;
280 print
'Bug: Action crop for modulepart = '.$modulepart.
' is not supported yet by photos_resize.php.';
283 if (empty($backtourl)) {
286 if (in_array($modulepart, array(
'product',
'produit',
'service',
'produit|service'))) {
287 $backtourl = DOL_URL_ROOT.
"/product/document.php?id=".$id.
'&file='.urldecode($file);
288 } elseif (in_array($modulepart, array(
'expensereport'))) {
289 $backtourl = DOL_URL_ROOT.
"/expensereport/document.php?id=".$id.
'&file='.urldecode($file);
290 } elseif (in_array($modulepart, array(
'holiday'))) {
291 $backtourl = DOL_URL_ROOT.
"/holiday/document.php?id=".$id.
'&file='.urldecode($file);
292 } elseif (in_array($modulepart, array(
'member'))) {
293 $backtourl = DOL_URL_ROOT.
"/adherents/document.php?id=".$id.
'&file='.urldecode($file);
294 } elseif (in_array($modulepart, array(
'project'))) {
295 $backtourl = DOL_URL_ROOT.
"/projet/document.php?id=".$id.
'&file='.urldecode($file);
296 } elseif (in_array($modulepart, array(
'propal'))) {
297 $backtourl = DOL_URL_ROOT.
"/comm/propal/document.php?id=".$id.
'&file='.urldecode($file);
298 } elseif (in_array($modulepart, array(
'societe'))) {
299 $backtourl = DOL_URL_ROOT.
"/societe/document.php?id=".$id.
'&file='.urldecode($file);
300 } elseif (in_array($modulepart, array(
'tax'))) {
301 $backtourl = DOL_URL_ROOT.
"/compta/sociales/document.php?id=".$id.
'&file='.urldecode($file);
302 } elseif (in_array($modulepart, array(
'ticket'))) {
303 $backtourl = DOL_URL_ROOT.
"/ticket/document.php?id=".$id.
'&file='.urldecode($file);
304 } elseif (in_array($modulepart, array(
'user'))) {
305 $backtourl = DOL_URL_ROOT.
"/user/document.php?id=".$id.
'&file='.urldecode($file);
306 } elseif (in_array($modulepart, array(
'facture'))) {
307 $backtourl = DOL_URL_ROOT.
"/compta/facture/document.php?id=".$id.
'&file='.urldecode($file);
308 } elseif (in_array($modulepart, array(
'facture_fourn',
'facture_fournisseur'))) {
309 $backtourl = DOL_URL_ROOT.
"/fourn/facture/document.php?id=".$id.
'&file='.urldecode($file);
310 } elseif (in_array($modulepart, array(
'bank')) && preg_match(
'/\/statement\/([^\/]+)\//', $file, $regs)) {
312 $backtourl = DOL_URL_ROOT.
"/compta/bank/account_statement_document.php?id=".$id.
'&num='.urlencode($num).
'&file='.urldecode($file);
313 } elseif (in_array($modulepart, array(
'bank'))) {
314 $backtourl = DOL_URL_ROOT.
"/compta/bank/document.php?id=".$id.
'&file='.urldecode($file);
315 } elseif (in_array($modulepart, array(
'mrp'))) {
316 $backtourl = DOL_URL_ROOT.
"/mrp/mo_document.php?id=".$id.
'&file='.urldecode($file);
317 } elseif (in_array($modulepart, array(
'medias'))) {
318 $section_dir = dirname($file);
319 if (!preg_match(
'/\/$/', $section_dir)) {
322 $backtourl = DOL_URL_ROOT.
"/website/index.php?action=file_manager&website=".$website.
'§ion_dir='.urlencode($section_dir);
325 $backtourl = DOL_URL_ROOT.
"/".$modulepart.
"/".$modulepart.
"_document.php?id=".$id.
'&file='.urldecode($file);
336 header(
"Location: ".$backtourl);
339 dol_print_error(
'',
'Cancel on photo_resize with a not supported value of modulepart='.$modulepart);
346 print
'Bug: Value for $dir could not be defined.';
349 $fullpath = $dir.
"/".$original_file;
353 if ($result == $fullpath) {
355 if (is_object($object)) {
356 $object->addThumbs($fullpath);
360 $rel_filename = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $fullpath);
361 $rel_filename = preg_replace(
'/^[\\/]/',
'', $rel_filename);
363 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
365 $result = $ecmfile->fetch(0,
'', $rel_filename);
367 $filename = basename($rel_filename);
368 $rel_dir = dirname($rel_filename);
369 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
370 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
373 $result = $ecmfile->update($user);
374 } elseif ($result == 0) {
375 $filename = basename($rel_filename);
376 $rel_dir = dirname($rel_filename);
377 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
378 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
380 $ecmfile->filepath = $rel_dir;
381 $ecmfile->filename = $filename;
383 $ecmfile->fullpath_orig = $fullpath;
384 $ecmfile->gen_or_uploaded =
'unknown';
385 $ecmfile->description =
'';
386 $ecmfile->keywords =
'';
387 $result = $ecmfile->create($user);
391 $result = $ecmfile->create($user);
395 header(
"Location: ".$backtourl);
398 dol_print_error(
'',
'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart);
403 $_GET[
'file'] = $_POST[
"file"];
409 if ($action ==
'confirm_crop') {
411 print
'Bug: Value for $dir could not be defined.';
414 $fullpath = $dir.
"/".$original_file;
418 if ($result == $fullpath) {
419 if (is_object($object)) {
420 $object->addThumbs($fullpath);
424 $rel_filename = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $fullpath);
425 $rel_filename = preg_replace(
'/^[\\/]/',
'', $rel_filename);
427 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
429 $result = $ecmfile->fetch(0,
'', $rel_filename);
431 $filename = basename($rel_filename);
432 $rel_dir = dirname($rel_filename);
433 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
434 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
437 $result = $ecmfile->update($user);
438 } elseif ($result == 0) {
439 $filename = basename($rel_filename);
440 $rel_dir = dirname($rel_filename);
441 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
442 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
444 $ecmfile->filepath = $rel_dir;
445 $ecmfile->filename = $filename;
447 $ecmfile->fullpath_orig = $fullpath;
448 $ecmfile->gen_or_uploaded =
'unknown';
449 $ecmfile->description =
'';
450 $ecmfile->keywords =
'';
451 $result = $ecmfile->create($user);
455 $result = $ecmfile->create($user);
459 header(
"Location: ".$backtourl);
462 dol_print_error(
'',
'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart);
467 $_GET[
'file'] = $_POST[
"file"];
478 $title = $langs->trans(
"ImageEditor");
479 $morejs = array(
'/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js',
'/core/js/lib_photosresize.js');
480 $morecss = array(
'/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css');
482 llxHeader($head, $title,
'',
'', 0, 0, $morejs, $morecss);
488 $height = $infoarray[
'height'];
489 $width = $infoarray[
'width'];
490 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"CurrentInformationOnImage").
': </span>';
491 print
'<span class="opacitymedium">';
492 print $langs->trans(
"Width").
': <strong>'.$width.
'</strong> x '.$langs->trans(
"Height").
': <strong>'.$height.
'</strong>';
502 print
'<!-- Form to resize -->'.
"\n";
503 print
'<form name="redim_file" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.($num ?
'&num='.$num :
'').
'" method="POST">';
504 print
'<input type="hidden" name="token" value="'.newToken().
'">';
506 print
'<fieldset id="redim_file">';
507 print
'<legend>'.$langs->trans(
"Resize").
'</legend>';
508 print $langs->trans(
"ResizeDesc").
'<br>';
509 print $langs->trans(
"NewLength").
': <input name="sizex" type="number" class="flat maxwidth50 right"> px <span class="opacitymedium">'.$langs->trans(
"or").
'</span> ';
510 print $langs->trans(
"NewHeight").
': <input name="sizey" type="number" class="flat maxwidth50 right"> px <br>';
512 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'" />';
513 print
'<input type="hidden" name="action" value="confirm_resize" />';
514 print
'<input type="hidden" name="product" value="'.$id.
'" />';
515 print
'<input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).
'" />';
516 print
'<input type="hidden" name="id" value="'.$id.
'" />';
518 print
'<input class="button" id="submitresize" name="sendit" value="'.dol_escape_htmltag($langs->trans(
"Resize")).
'" type="submit" />';
520 print
'<input type="submit" id="cancelresize" name="cancel" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" />';
521 print
'</fieldset>'.
"\n";
532 if (!empty($conf->use_javascript_ajax)) {
534 $height = $infoarray[
'height'];
535 $width = $infoarray[
'width'];
536 $widthforcrop = $width;
537 $refsizeforcrop =
'orig';
541 if (!empty($_SESSION[
'dol_screenwidth'])) {
542 $widthforcroporigin = $widthforcrop;
543 while ($widthforcrop > round($_SESSION[
'dol_screenwidth'] / 1.5)) {
545 $ratioforcrop = 2 * $ratioforcrop;
546 $widthforcrop = floor($widthforcroporigin / $ratioforcrop);
547 $refsizeforcrop =
'screenwidth';
551 print
'<!-- Form to crop -->'.
"\n";
552 print
'<fieldset id="redim_file">';
553 print
'<legend>'.$langs->trans(
"Recenter").
'</legend>';
554 print $langs->trans(
"DefineNewAreaToPick").
'...<br>';
555 print
'<br><div class="center">';
557 if (empty($conf->dol_no_mouse_hover)) {
558 print
'<div style="border: 1px solid #888888; width: '.$widthforcrop.
'px;">';
559 print
'<img src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$object->entity.
'&file='.urlencode($original_file).
'" alt="" id="cropbox" width="'.$widthforcrop.
'px"/>';
563 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.($num ?
'&num='.$num :
'').
'" method="POST">';
564 print
'<input type="hidden" name="token" value="'.newToken().
'">';
566 <div class="jc_coords">
567 '.$langs->trans(
"NewSizeAfterCropping").
':
568 <label>X1=<input type="number" class="flat maxwidth50" id="x" name="x" /></label>
569 <label>Y1=<input type="number" class="flat maxwidth50" id="y" name="y" /></label>
570 <label>X2=<input type="number" class="flat maxwidth50" id="x2" name="x2" /></label>
571 <label>Y2=<input type="number" class="flat maxwidth50" id="y2" name="y2" /></label>
572 <label>W=<input type="number" class="flat maxwidth50" id="w" name="w" /></label>
573 <label>H=<input type="number" class="flat maxwidth50" id="h" name="h" /></label>
576 <input type="hidden" id="file" name="file" value="'.
dol_escape_htmltag($original_file).
'" />
577 <input type="hidden" id="action" name="action" value="confirm_crop" />
578 <input type="hidden" id="product" name="product" value="'.
dol_escape_htmltag($id).
'" />
579 <input type="hidden" id="dol_screenwidth" name="dol_screenwidth" value="'.$_SESSION[
'dol_screenwidth'].
'" />
580 <input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'.$refsizeforcrop.
'" />
581 <input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'.$ratioforcrop.
'" /><!-- value in field used by js/lib/lib_photoresize.js -->
582 <input type="hidden" id="imagewidth" name="imagewidth" value="'.$width.
'" /><!-- value in field used by js/lib/lib_photoresize.js -->
583 <input type="hidden" id="imageheight" name="imageheight" value="'.$height.
'" /><!-- value in field used by js/lib/lib_photoresize.js -->
587 <input type="submit" id="submitcrop" name="submitcrop" class="button" value="'.
dol_escape_htmltag($langs->trans(
"Recenter")).
'" />
589 <input type="submit" id="cancelcrop" name="cancel" class="button button-cancel" value="'.
dol_escape_htmltag($langs->trans(
"Cancel")).
'" />
592 $langs->load(
"other");
593 print
'<div class="opacitymedium">'.$langs->trans(
"FeatureNotAvailableOnDevicesWithoutMouse").
'</div>';
595 print
'</fieldset>'.
"\n";
600 print
'<script type="text/javascript">
601 jQuery(document).ready(function() {
602 $("#submitcrop").click(function(e) {
603 console.log("We click on submitcrop");
604 var idClicked = e.target.id;
605 if (parseInt(jQuery(\'#w\').val())) return true;
606 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, bmp and webp) ...
Class to manage products or services.
Class to manage Dolibarr users.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
const TYPE_SERVICE
Service.
Class to manage suppliers invoices.
const TYPE_PRODUCT
Regular product.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
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 from a POST of a form...
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.
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.
restrictedArea($user, $features, $objectid=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.
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...
dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0, $filetowrite= '', $newquality=0)
Resize or crop an image file (Supported extensions are gif, jpg, png, bmp and webp) ...
Class to manage ECM files.
Class to manage proposals.