28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
33 $langs->loadLangs(array(
"products",
"other"));
36 $action =
GETPOST(
'action',
'aZ09');
37 $modulepart =
GETPOST(
'modulepart',
'alpha') ?
GETPOST(
'modulepart',
'alpha') :
'produit|service';
38 $original_file =
GETPOST(
"file");
39 $backtourl =
GETPOST(
'backtourl');
40 $cancel =
GETPOST(
'cancel',
'alpha');
42 $file =
GETPOST(
'file',
'alpha');
44 $website =
GETPOST(
'website',
'alpha');
48 if (empty($modulepart)) {
52 if ($modulepart ==
'produit' || $modulepart ==
'product' || $modulepart ==
'service' || $modulepart ==
'produit|service') {
53 $result =
restrictedArea($user,
'produit|service', $id,
'product&product');
54 if ($modulepart ==
'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire)) {
58 } elseif ($modulepart ==
'project') {
60 if (empty($user->rights->projet->lire)) {
64 } elseif ($modulepart ==
'bom') {
66 if (empty($user->rights->bom->read)) {
70 } elseif ($modulepart ==
'member') {
71 $result =
restrictedArea($user,
'adherent', $id,
'',
'',
'fk_soc',
'rowid');
72 if (empty($user->rights->adherent->lire)) {
76 } elseif ($modulepart ==
'user') {
77 $result =
restrictedArea($user, $modulepart, $id, $modulepart, $modulepart);
78 if (empty($user->rights->user->user->lire)) {
82 } elseif ($modulepart ==
'tax') {
83 $result =
restrictedArea($user, $modulepart, $id,
'chargesociales',
'charges');
84 if (empty($user->rights->tax->charges->lire)) {
88 } elseif ($modulepart ==
'bank') {
90 if (empty($user->rights->banque->lire)) {
94 } elseif ($modulepart ==
'medias') {
95 $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
100 } elseif ($modulepart ==
'facture_fourn' || $modulepart ==
'facture_fournisseur') {
101 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture');
102 if (empty($user->rights->fournisseur->facture->lire)) {
109 if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire)) {
117 if (!$accessallowed) {
122 if ($modulepart ==
'produit' || $modulepart ==
'product' || $modulepart ==
'service' || $modulepart ==
'produit|service') {
123 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
126 $result = $object->fetch($id);
130 $dir = $conf->product->multidir_output[$object->entity];
132 $dir = $conf->product->multidir_output[$object->entity];
135 $dir = $conf->service->multidir_output[$object->entity];
138 } elseif ($modulepart ==
'project') {
139 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
142 $result = $object->fetch($id);
146 $dir = $conf->project->multidir_output[$object->entity];
148 } elseif ($modulepart ==
'propal') {
149 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
150 $object =
new Propal($db);
152 $result = $object->fetch($id);
156 $dir = $conf->propal->multidir_output[$object->entity];
158 } elseif ($modulepart ==
'holiday') {
159 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
162 $result = $object->fetch($id);
166 $dir = $conf->$modulepart->dir_output;
168 } elseif ($modulepart ==
'member') {
169 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
172 $result = $object->fetch($id);
176 $dir = $conf->adherent->dir_output;
178 } elseif ($modulepart ==
'societe') {
179 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
182 $result = $object->fetch($id);
186 $dir = $conf->$modulepart->dir_output;
188 } elseif ($modulepart ==
'user') {
189 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
190 $object =
new User($db);
192 $result = $object->fetch($id);
196 $dir = $conf->$modulepart->dir_output;
198 } elseif ($modulepart ==
'expensereport') {
199 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
202 $result = $object->fetch($id);
206 $dir = $conf->expensereport->dir_output;
208 } elseif ($modulepart ==
'tax') {
209 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
212 $result = $object->fetch($id);
216 $dir = $conf->$modulepart->dir_output;
218 } elseif ($modulepart ==
'ticket') {
219 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
220 $object =
new Ticket($db);
222 $result = $object->fetch($id);
226 $dir = $conf->$modulepart->dir_output;
228 } elseif ($modulepart ==
'bom') {
229 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
230 $object =
new BOM($db);
232 $result = $object->fetch($id);
236 $dir = $conf->$modulepart->dir_output;
238 } elseif ($modulepart ==
'mrp') {
239 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
240 $object =
new MO($db);
242 $result = $object->fetch($id);
246 $dir = $conf->$modulepart->dir_output;
248 } elseif ($modulepart ==
'bank') {
249 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
252 $result = $object->fetch($id);
256 $dir = $conf->bank->dir_output;
258 } elseif ($modulepart ==
'facture') {
259 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
262 $result = $object->fetch($id);
266 $dir = $conf->$modulepart->dir_output;
268 } elseif ($modulepart ==
'facture_fourn' || $modulepart ==
'facture_fournisseur') {
269 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
272 $result = $object->fetch($id);
276 $dir = $conf->fournisseur->dir_output.
'/facture';
278 } elseif ($modulepart ==
'medias') {
279 $dir = $dolibarr_main_data_root.
'/'.$modulepart;
281 print
'Bug: Action crop for modulepart = '.$modulepart.
' is not supported yet by photos_resize.php.';
284 if (empty($backtourl)) {
287 if (in_array($modulepart, array(
'product',
'produit',
'service',
'produit|service'))) {
288 $backtourl = DOL_URL_ROOT.
"/product/document.php?id=".((int) $id).
'&file='.urlencode($file);
289 } elseif (in_array($modulepart, array(
'expensereport'))) {
290 $backtourl = DOL_URL_ROOT.
"/expensereport/document.php?id=".((int) $id).
'&file='.urlencode($file);
291 } elseif (in_array($modulepart, array(
'holiday'))) {
292 $backtourl = DOL_URL_ROOT.
"/holiday/document.php?id=".((int) $id).
'&file='.urlencode($file);
293 } elseif (in_array($modulepart, array(
'member'))) {
294 $backtourl = DOL_URL_ROOT.
"/adherents/document.php?id=".((int) $id).
'&file='.urlencode($file);
295 } elseif (in_array($modulepart, array(
'project'))) {
296 $backtourl = DOL_URL_ROOT.
"/projet/document.php?id=".((int) $id).
'&file='.urlencode($file);
297 } elseif (in_array($modulepart, array(
'propal'))) {
298 $backtourl = DOL_URL_ROOT.
"/comm/propal/document.php?id=".((int) $id).
'&file='.urlencode($file);
299 } elseif (in_array($modulepart, array(
'societe'))) {
300 $backtourl = DOL_URL_ROOT.
"/societe/document.php?id=".((int) $id).
'&file='.urlencode($file);
301 } elseif (in_array($modulepart, array(
'tax'))) {
302 $backtourl = DOL_URL_ROOT.
"/compta/sociales/document.php?id=".((int) $id).
'&file='.urlencode($file);
303 } elseif (in_array($modulepart, array(
'ticket'))) {
304 $backtourl = DOL_URL_ROOT.
"/ticket/document.php?id=".((int) $id).
'&file='.urlencode($file);
305 } elseif (in_array($modulepart, array(
'user'))) {
306 $backtourl = DOL_URL_ROOT.
"/user/document.php?id=".((int) $id).
'&file='.urlencode($file);
307 } elseif (in_array($modulepart, array(
'facture'))) {
308 $backtourl = DOL_URL_ROOT.
"/compta/facture/document.php?id=".((int) $id).
'&file='.urlencode($file);
309 } elseif (in_array($modulepart, array(
'facture_fourn',
'facture_fournisseur'))) {
310 $backtourl = DOL_URL_ROOT.
"/fourn/facture/document.php?id=".((int) $id).
'&file='.urlencode($file);
311 } elseif (in_array($modulepart, array(
'bank')) && preg_match(
'/\/statement\/([^\/]+)\//', $file, $regs)) {
313 $backtourl = DOL_URL_ROOT.
"/compta/bank/account_statement_document.php?id=".((int) $id).
'&num='.urlencode($num).
'&file='.urlencode($file);
314 } elseif (in_array($modulepart, array(
'bank'))) {
315 $backtourl = DOL_URL_ROOT.
"/compta/bank/document.php?id=".((int) $id).
'&file='.urlencode($file);
316 } elseif (in_array($modulepart, array(
'mrp'))) {
317 $backtourl = DOL_URL_ROOT.
"/mrp/mo_document.php?id=".((int) $id).
'&file='.urlencode($file);
318 } elseif (in_array($modulepart, array(
'medias'))) {
319 $section_dir = dirname($file);
320 if (!preg_match(
'/\/$/', $section_dir)) {
323 $backtourl = DOL_URL_ROOT.
'/website/index.php?action=file_manager'.($website ?
'&website='.urlencode($website) :
'').
'§ion_dir='.urlencode($section_dir);
326 $backtourl = DOL_URL_ROOT.
"/".$modulepart.
"/".$modulepart.
"_document.php?id=".((int) $id).
'&file='.urlencode($file);
337 header(
"Location: ".$backtourl);
340 dol_print_error(
'',
'Cancel on photo_resize with a not supported value of modulepart='.$modulepart);
347 print
'Bug: Value for $dir could not be defined.';
350 $fullpath = $dir.
"/".$original_file;
354 if ($result == $fullpath) {
356 if (is_object($object)) {
357 $object->addThumbs($fullpath);
361 $rel_filename = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $fullpath);
362 $rel_filename = preg_replace(
'/^[\\/]/',
'', $rel_filename);
364 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
366 $result = $ecmfile->fetch(0,
'', $rel_filename);
368 $filename = basename($rel_filename);
369 $rel_dir = dirname($rel_filename);
370 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
371 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
374 $result = $ecmfile->update($user);
375 } elseif ($result == 0) {
376 $filename = basename($rel_filename);
377 $rel_dir = dirname($rel_filename);
378 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
379 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
381 $ecmfile->filepath = $rel_dir;
382 $ecmfile->filename = $filename;
384 $ecmfile->fullpath_orig = $fullpath;
385 $ecmfile->gen_or_uploaded =
'unknown';
386 $ecmfile->description =
'';
387 $ecmfile->keywords =
'';
388 $result = $ecmfile->create($user);
392 $result = $ecmfile->create($user);
396 header(
"Location: ".$backtourl);
399 dol_print_error(
'',
'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart);
404 $_GET[
'file'] = $_POST[
"file"];
410 if ($action ==
'confirm_crop') {
412 print
'Bug: Value for $dir could not be defined.';
415 $fullpath = $dir.
"/".$original_file;
419 if ($result == $fullpath) {
420 if (is_object($object)) {
421 $object->addThumbs($fullpath);
425 $rel_filename = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $fullpath);
426 $rel_filename = preg_replace(
'/^[\\/]/',
'', $rel_filename);
428 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
430 $result = $ecmfile->fetch(0,
'', $rel_filename);
432 $filename = basename($rel_filename);
433 $rel_dir = dirname($rel_filename);
434 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
435 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
438 $result = $ecmfile->update($user);
439 } elseif ($result == 0) {
440 $filename = basename($rel_filename);
441 $rel_dir = dirname($rel_filename);
442 $rel_dir = preg_replace(
'/[\\/]$/',
'', $rel_dir);
443 $rel_dir = preg_replace(
'/^[\\/]/',
'', $rel_dir);
445 $ecmfile->filepath = $rel_dir;
446 $ecmfile->filename = $filename;
448 $ecmfile->fullpath_orig = $fullpath;
449 $ecmfile->gen_or_uploaded =
'unknown';
450 $ecmfile->description =
'';
451 $ecmfile->keywords =
'';
452 $result = $ecmfile->create($user);
456 $result = $ecmfile->create($user);
460 header(
"Location: ".$backtourl);
463 dol_print_error(
'',
'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart);
468 $_GET[
'file'] = $_POST[
"file"];
479 $title = $langs->trans(
"ImageEditor");
480 $morejs = array(
'/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js',
'/core/js/lib_photosresize.js');
481 $morecss = array(
'/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css');
483 llxHeader($head, $title,
'',
'', 0, 0, $morejs, $morecss);
489 $height = $infoarray[
'height'];
490 $width = $infoarray[
'width'];
491 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"CurrentInformationOnImage").
': </span>';
492 print
'<span class="opacitymedium">';
493 print $langs->trans(
"Width").
': <strong>'.$width.
'</strong> x '.$langs->trans(
"Height").
': <strong>'.$height.
'</strong>';
503 print
'<!-- Form to resize -->'.
"\n";
504 print
'<form name="redim_file" action="'.$_SERVER[
"PHP_SELF"].
'?id='.((int) $id).($num ?
'&num='.urlencode($num) :
'').
'" method="POST">';
505 print
'<input type="hidden" name="token" value="'.newToken().
'">';
506 print
'<input type="hidden" name="backtourl" value="'.$backtourl.
'">';
508 print
'<fieldset id="redim_file">';
509 print
'<legend>'.$langs->trans(
"Resize").
'</legend>';
510 print $langs->trans(
"ResizeDesc").
'<br>';
511 print $langs->trans(
"NewLength").
': <input name="sizex" type="number" class="flat maxwidth50 right"> px <span class="opacitymedium">'.$langs->trans(
"or").
'</span> ';
512 print $langs->trans(
"NewHeight").
': <input name="sizey" type="number" class="flat maxwidth50 right"> px <br>';
514 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'" />';
515 print
'<input type="hidden" name="action" value="confirm_resize" />';
516 print
'<input type="hidden" name="product" value="'.$id.
'" />';
517 print
'<input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).
'" />';
518 print
'<input type="hidden" name="id" value="'.$id.
'" />';
520 print
'<input class="button" id="submitresize" name="sendit" value="'.dol_escape_htmltag($langs->trans(
"Resize")).
'" type="submit" />';
522 print
'<input type="submit" id="cancelresize" name="cancel" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" />';
523 print
'</fieldset>'.
"\n";
535 if (!empty($conf->use_javascript_ajax)) {
537 $height = $infoarray[
'height'];
538 $width = $infoarray[
'width'];
539 $widthforcrop = $width;
540 $refsizeforcrop =
'orig';
544 if (!empty($_SESSION[
'dol_screenwidth'])) {
545 $widthforcroporigin = $widthforcrop;
546 while ($widthforcrop > round($_SESSION[
'dol_screenwidth'] / 1.5)) {
548 $ratioforcrop = 2 * $ratioforcrop;
549 $widthforcrop = floor($widthforcroporigin / $ratioforcrop);
550 $refsizeforcrop =
'screenwidth';
554 print
'<!-- Form to crop -->'.
"\n";
555 print
'<fieldset id="redim_file">';
556 print
'<legend>'.$langs->trans(
"Recenter").
'</legend>';
557 print $langs->trans(
"DefineNewAreaToPick").
'...<br>';
558 print
'<br><div class="center">';
560 if (empty($conf->dol_no_mouse_hover)) {
561 print
'<div style="border: 1px solid #888888; width: '.$widthforcrop.
'px;">';
562 print
'<img src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$object->entity.
'&file='.urlencode($original_file).
'" alt="" id="cropbox" width="'.$widthforcrop.
'px"/>';
566 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.((int) $id).($num ?
'&num='.$num :
'').
'" method="POST">';
567 print
'<input type="hidden" name="token" value="'.newToken().
'">';
568 print
'<input type="hidden" name="backtourl" value="'.$backtourl.
'">';
570 <div class="jc_coords">
571 '.$langs->trans(
"NewSizeAfterCropping").
':
572 <label>X1=<input type="number" class="flat maxwidth50" id="x" name="x" /></label>
573 <label>Y1=<input type="number" class="flat maxwidth50" id="y" name="y" /></label>
574 <label>X2=<input type="number" class="flat maxwidth50" id="x2" name="x2" /></label>
575 <label>Y2=<input type="number" class="flat maxwidth50" id="y2" name="y2" /></label>
576 <label>W=<input type="number" class="flat maxwidth50" id="w" name="w" /></label>
577 <label>H=<input type="number" class="flat maxwidth50" id="h" name="h" /></label>
580 <input type="hidden" id="file" name="file" value="'.
dol_escape_htmltag($original_file).
'" />
581 <input type="hidden" id="action" name="action" value="confirm_crop" />
582 <input type="hidden" id="product" name="product" value="'.
dol_escape_htmltag($id).
'" />
583 <input type="hidden" id="dol_screenwidth" name="dol_screenwidth" value="'.$_SESSION[
'dol_screenwidth'].
'" />
584 <input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'.$refsizeforcrop.
'" />
585 <input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'.$ratioforcrop.
'" /><!-- value in field used by js/lib/lib_photoresize.js -->
586 <input type="hidden" id="imagewidth" name="imagewidth" value="'.$width.
'" /><!-- value in field used by js/lib/lib_photoresize.js -->
587 <input type="hidden" id="imageheight" name="imageheight" value="'.$height.
'" /><!-- value in field used by js/lib/lib_photoresize.js -->
591 <input type="submit" id="submitcrop" name="submitcrop" class="button" value="'.
dol_escape_htmltag($langs->trans(
"Recenter")).
'" />
593 <input type="submit" id="cancelcrop" name="cancel" class="button button-cancel" value="'.
dol_escape_htmltag($langs->trans(
"Cancel")).
'" />
596 $langs->load(
"other");
597 print
'<div class="opacitymedium">'.$langs->trans(
"FeatureNotAvailableOnDevicesWithoutMouse").
'</div>';
599 print
'</fieldset>'.
"\n";
604 print
'<script type="text/javascript">
605 jQuery(document).ready(function() {
606 $("#submitcrop").click(function(e) {
607 console.log("We click on submitcrop");
608 var idClicked = e.target.id;
609 if (parseInt(jQuery(\'#w\').val())) return true;
610 alert(\''.dol_escape_js($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Dimension"))).
'\');
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage members of a foundation.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Class to manage ECM files.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class of the module paid holiday.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage projects.
Class to manage proposals.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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)
dol_getImageSize($file, $url=false)
Return size of image file on disk (Supported extensions are gif, jpg, png, bmp and webp)
Class to generate the form for creating a new ticket.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.