예제 #1
0
 print '<td align="left">';
 if ($fields['pid']) {
     $product_static->id = $fields['pid'];
     $product_static->ref = $fields['pref'];
     $product_static->type = $fields['ptype'];
     print $product_static->getNomUrl(1);
     if (dol_string_nohtmltag($fields['descr'])) {
         print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
     }
 } else {
     if ($type) {
         $text = img_object($langs->trans('Service'), 'service');
     } else {
         $text = img_object($langs->trans('Product'), 'product');
     }
     print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
     // Show range
     print_date_range($fields['ddate_start'], $fields['ddate_end']);
 }
 print '</td>';
 // Total HT
 if ($modetax == 0) {
     print '<td class="nowrap" align="right">';
     print price($fields['totalht']);
     if (price2num($fields['ftotal_ttc'])) {
         //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
         $ratiolineinvoice = $fields['dtotal_ttc'] / $fields['ftotal_ttc'];
         //print ' ('.round($ratiolineinvoice*100,2).'%)';
     }
     print '</td>';
 }
예제 #2
0
 /**
  * Clean a cell to respect rules of CSV file cells
  *
  * @param 	string	$newvalue	String to clean
  * @param	string	$charset	Input AND Output character set
  * @return 	string				Value cleaned
  */
 function csv_clean($newvalue, $charset)
 {
     $addquote = 0;
     // Rule Dolibarr: No HTML
     //print $charset.' '.$newvalue."\n";
     $newvalue = dol_string_nohtmltag($newvalue, 1, $charset);
     //print $charset.' '.$newvalue."\n";
     // Rule 1 CSV: No CR, LF in cells
     $newvalue = str_replace("\r", '', $newvalue);
     $newvalue = str_replace("\n", '\\n', $newvalue);
     // Rule 2 CSV: If value contains ", we must escape with ", and add "
     if (preg_match('/"/', $newvalue)) {
         $addquote = 1;
         $newvalue = str_replace('"', '""', $newvalue);
     }
     // Rule 3 CSV: If value contains separator, we must add "
     if (preg_match('/' . $this->separator . '/', $newvalue)) {
         $addquote = 1;
     }
     return ($addquote ? '"' : '') . $newvalue . ($addquote ? '"' : '');
 }
예제 #3
0
 /**
  * writeHTMLCell
  *
  * @param	int		$w				Width
  * @param 	int		$h				Height
  * @param 	int		$x				X
  * @param 	int		$y				Y
  * @param 	string	$html			Html
  * @param 	int		$border			Border
  * @param 	int		$ln				Ln
  * @param 	boolean	$fill			Fill
  * @param 	boolean	$reseth			Reseth
  * @param 	string	$align			Align
  * @param 	boolean	$autopadding	Autopadding
  * @return 	void
  */
 public function writeHTMLCell($w, $h, $x, $y, $html = '', $border = 0, $ln = 0, $fill = false, $reseth = true, $align = '', $autopadding = true)
 {
     $this->SetXY($x, $y);
     $val = str_replace('<br>', "\n", $html);
     //$val=dol_string_nohtmltag($val,false,'ISO-8859-1');
     $val = dol_string_nohtmltag($val, false, 'UTF-8');
     $this->MultiCell($w, $h, $val, $border, $align, $fill);
 }
예제 #4
0
/**
 *	Build a file from an array of events.
 *  All input data must be encoded in $conf->charset_output
 *
 *	@param		string	$format				'rss'
 *	@param		string	$title				Title of export
 *	@param		string	$desc				Description of export
 *	@param		array	$events_array		Array of events ('uid','startdate','summary','url','desc','author','category')
 *	@param		string	$outputfile			Output file
 *	@param		string	$filter				Filter
 *	@return		int							<0 if ko, Nb of events in file if ok
 */
function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '')
{
    global $user, $conf, $langs;
    global $dolibarr_main_url_root;
    dol_syslog("xcal.lib.php::build_rssfile Build rss file " . $outputfile . " to format " . $format);
    if (empty($outputfile)) {
        return -1;
    }
    $fichier = fopen($outputfile, 'w');
    if ($fichier) {
        $date = date("r");
        // Print header
        $form = '<?xml version="1.0" encoding="' . $langs->charset_output . '"?>';
        fwrite($fichier, $form);
        fwrite($fichier, "\n");
        $form = '<rss version="2.0">';
        fwrite($fichier, $form);
        fwrite($fichier, "\n");
        $form = "<channel>\n<title>" . $title . "</title>\n";
        fwrite($fichier, $form);
        $form = '<description><![CDATA[' . $desc . '.]]></description>' . "\n" . '<copyright>Dolibarr</copyright>' . "\n" . '<lastBuildDate>' . $date . '</lastBuildDate>' . "\n" . '<generator>Dolibarr</generator>' . "\n";
        $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', $dolibarr_main_url_root);
        $url = $urlwithouturlroot . DOL_URL_ROOT . '/public/agenda/agendaexport.php?format=rss&exportkey=' . urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
        $form .= '<link><![CDATA[' . $url . ']]></link>' . "\n";
        //print $form;
        fwrite($fichier, $form);
        foreach ($events_array as $date => $event) {
            $eventqualified = true;
            if ($filter) {
                // TODO Add a filter
                $eventqualified = false;
            }
            if ($eventqualified) {
                $uid = $event['uid'];
                $startdate = $event['startdate'];
                $summary = $event['summary'];
                $url = $event['url'];
                $author = $event['author'];
                $category = $event['category'];
                /* No place inside a RSS
                   $priority     = $event['priority'];
                   $fulldayevent = $event['fulldayevent'];
                   $location     = $event['location'];
                   $email        = $event['email'];
                   */
                $description = preg_replace('/<br[\\s\\/]?>/i', "\n", $event['desc']);
                $description = dol_string_nohtmltag($description, 0);
                // Remove html tags
                fwrite($fichier, "<item>\n");
                fwrite($fichier, "<title><![CDATA[" . $summary . "]]></title>\n");
                fwrite($fichier, "<link><![CDATA[" . $url . "]]></link>\n");
                fwrite($fichier, "<author><![CDATA[" . $author . "]]></author>\n");
                fwrite($fichier, "<category><![CDATA[" . $category . "]]></category>\n");
                fwrite($fichier, "<description><![CDATA[");
                if ($description) {
                    fwrite($fichier, $description);
                }
                //else fwrite($fichier, 'NoDesc');
                fwrite($fichier, "]]></description>\n");
                fwrite($fichier, "<pubDate>" . date("r", $startdate) . "</pubDate>\n");
                fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[" . $uid . "]]></guid>\n");
                fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n");
                fwrite($fichier, "</item>\n");
            }
        }
        fwrite($fichier, '</channel>');
        fwrite($fichier, "\n");
        fwrite($fichier, '</rss>');
        fclose($fichier);
        if (!empty($conf->global->MAIN_UMASK)) {
            @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
        }
    }
}
 /**
  * Clean a cell to respect rules of Excel file cells
  *
  * @param 	string	$newvalue	String to clean
  * @return 	string				Value cleaned
  */
 function excel_clean($newvalue)
 {
     // Rule Dolibarr: No HTML
     $newvalue = dol_string_nohtmltag($newvalue);
     return $newvalue;
 }
예제 #6
0
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$langs->load("companies");
$langs->load("products");
$langs->load("admin");
$langs->load("mails");
$langs->load("other");
$langs->load("errors");
$action = GETPOST('action', 'alpha');
if (!$user->admin) {
    accessforbidden();
}
$usersignature = $user->signature;
// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
if ($action == 'test' || $action == 'send') {
    $usersignature = dol_string_nohtmltag($usersignature);
}
$substitutionarrayfortest = array('__LOGIN__' => $user->login, '__ID__' => 'TESTIdRecord', '__EMAIL__' => 'TESTEMail', '__LASTNAME__' => 'TESTLastname', '__FIRSTNAME__' => 'TESTFirstname', '__SIGNATURE__' => $user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN) ? $usersignature : '');
complete_substitutions_array($substitutionarrayfortest, $langs);
/*
 * Actions
 */
if ($action == 'update' && empty($_POST["cancel"])) {
    dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"), 'chaine', 0, '', $conf->entity);
    // Send mode parameters
    dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"), 'chaine', 0, '', $conf->entity);
    dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"), 'chaine', 0, '', $conf->entity);
    dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"), 'chaine', 0, '', $conf->entity);
    dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine', 0, '', $conf->entity);
    dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine', 0, '', $conf->entity);
    dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"), 'chaine', 0, '', $conf->entity);
예제 #7
0
파일: list.php 프로젝트: ADDAdev/Dolibarr
 if ($num > 0) {
     $var = true;
     $total_ht = 0;
     $total_tva = 0;
     $total_ttc = 0;
     $totalrecu = 0;
     while ($i < min($num, $limit)) {
         $objp = $db->fetch_object($resql);
         $var = !$var;
         $datelimit = $db->jdate($objp->datelimite);
         print '<tr ' . $bc[$var] . '>';
         print '<td class="nowrap">';
         $facturestatic->id = $objp->facid;
         $facturestatic->ref = $objp->facnumber;
         $facturestatic->type = $objp->type;
         $notetoshow = dol_string_nohtmltag($user->societe_id > 0 ? $objp->note_public : $objp->note, 1);
         $paiement = $facturestatic->getSommePaiement();
         print '<table class="nobordernopadding"><tr class="nocellnopadd">';
         print '<td class="nobordernopadding nowrap">';
         print $facturestatic->getNomUrl(1, '', 200, 0, $notetoshow);
         print $objp->increment;
         print '</td>';
         print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
         if (!empty($objp->note_private)) {
             print ' <span class="note">';
             print '<a href="' . DOL_URL_ROOT . '/compta/facture/note.php?id=' . $objp->facid . '">' . img_picto($langs->trans("ViewPrivateNote"), 'object_generic') . '</a>';
             print '</span>';
         }
         $filename = dol_sanitizeFileName($objp->facnumber);
         $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($objp->facnumber);
         $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objp->facid;
 /**
  * Clean a cell to respect rules of TSV file cells
  *
  * @param 	string	$newvalue	String to clean
  * @param	string	$charset	Input AND Output character set
  * @return 	string				Value cleaned
  */
 function tsv_clean($newvalue, $charset)
 {
     // Rule Dolibarr: No HTML
     $newvalue = dol_string_nohtmltag($newvalue, 1, $charset);
     // Rule 1 TSV: No CR, LF in cells
     $newvalue = str_replace("\r", '', $newvalue);
     $newvalue = str_replace("\n", '\\n', $newvalue);
     // Rule 2 TSV: If value contains tab, we must replace by space
     if (preg_match('/' . $this->separator . '/', $newvalue)) {
         $newvalue = str_replace("\t", " ", $newvalue);
     }
     return $newvalue;
 }
예제 #9
0
/**
 *	Truncate a string to a particular length adding '...' if string larger than length.
 * 	If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'.
 *  MAIN_DISABLE_TRUNC=1 can disable all truncings
 *	@param      string				String to truncate
 *	@param      size				Max string size. 0 for no limit.
 *	@param		trunc				Where to trunc: right, left, middle, wrap
 * 	@param		stringencoding		Tell what is source string encoding
 *	@return     string				Truncated string
 */
function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF-8')
{
    global $conf;
    if ($size == 0) {
        return $string;
    }
    if (empty($conf->global->MAIN_DISABLE_TRUNC)) {
        // We go always here
        if ($trunc == 'right') {
            $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
            if (dol_strlen($newstring, $stringencoding) > $size + 1) {
                return dol_substr($newstring, 0, $size, $stringencoding) . '...';
            } else {
                return $string;
            }
        }
        if ($trunc == 'middle') {
            $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
            if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > $size + 1) {
                $size1 = round($size / 2);
                $size2 = round($size / 2);
                return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
            } else {
                return $string;
            }
        }
        if ($trunc == 'left') {
            $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
            if (dol_strlen($newstring, $stringencoding) > $size + 1) {
                return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
            } else {
                return $string;
            }
        }
        if ($trunc == 'wrap') {
            $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
            if (dol_strlen($newstring, $stringencoding) > $size + 1) {
                return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
            } else {
                return $string;
            }
        }
    } else {
        return $string;
    }
}
예제 #10
0
파일: odf.php 프로젝트: Samara94/dolibarr
 /**
  * Function to convert a HTML string into an ODT string
  *
  * @param	string	$value	String to convert
  */
 public function htmlToUTFAndPreOdf($value)
 {
     // We decode into utf8, entities
     $value = dol_html_entity_decode($value, ENT_QUOTES);
     // We convert html tags
     $ishtml = dol_textishtml($value);
     if ($ishtml) {
         // If string is "MYPODUCT - Desc <strong>bold</strong> with &eacute; accent<br />\n<br />\nUn texto en espa&ntilde;ol ?"
         // Result after clean must be "MYPODUCT - Desc bold with é accent\n\nUn texto en espa&ntilde;ol ?"
         // We want to ignore \n and we want all <br> to be \n
         $value = preg_replace('/(\\r\\n|\\r|\\n)/i', '', $value);
         $value = preg_replace('/<br>/i', "\n", $value);
         $value = preg_replace('/<br\\s+[^<>\\/]*>/i', "\n", $value);
         $value = preg_replace('/<br\\s+[^<>\\/]*\\/>/i', "\n", $value);
         //$value=preg_replace('/<strong>/','__lt__text:p text:style-name=__quot__bold__quot____gt__',$value);
         //$value=preg_replace('/<\/strong>/','__lt__/text:p__gt__',$value);
         $value = dol_string_nohtmltag($value, 0);
     }
     return $value;
 }
예제 #11
0
/**
 *	Truncate a string to a particular length adding '...' if string larger than length.
 * 	If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'.
 *  MAIN_DISABLE_TRUNC=1 can disable all truncings
 *
 *	@param	string	$string				String to truncate
 *	@param  int		$size				Max string size visible. 0 for no limit. Final string size can be 1 more (if size was max+1) or 3 more (if we added ...)
 *	@param	string	$trunc				Where to trunc: right, left, middle (size must be a 2 power), wrap
 * 	@param	string	$stringencoding		Tell what is source string encoding
 *  @param	int		$nodot				Truncation do not add ... after truncation. So it's an exact truncation.
 *  @param  int     $display            Trunc is use to display and can be changed for small screen
 *	@return string						Truncated string
 */
function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF-8', $nodot = 0, $display = 0)
{
    global $conf;
    if (empty($stringencoding)) {
        $stringencoding = 'UTF-8';
    }
    if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) {
        return $string;
    }
    // reduce for small screen
    if ($conf->dol_optimize_smallscreen == 1 && $display == 1) {
        $size = round($size / 3);
    }
    // We go always here
    if ($trunc == 'right') {
        $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
        if (dol_strlen($newstring, $stringencoding) > $size + ($nodot ? 0 : 1)) {
            return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...');
        } else {
            return $string;
        }
    } elseif ($trunc == 'middle') {
        $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
        if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > $size + 1) {
            $size1 = round($size / 2);
            $size2 = round($size / 2);
            return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
        } else {
            return $string;
        }
    } elseif ($trunc == 'left') {
        $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
        if (dol_strlen($newstring, $stringencoding) > $size + 1) {
            return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
        } else {
            return $string;
        }
    } elseif ($trunc == 'wrap') {
        $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
        if (dol_strlen($newstring, $stringencoding) > $size + 1) {
            return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
        } else {
            return $string;
        }
    } else {
        return 'BadParam3CallingDolTrunc';
    }
}
예제 #12
0
 /**
  * testDolStringNohtmltag
  *
  * @return boolean
  */
 public function testDolStringNohtmltag()
 {
     $text = "A\nstring\n";
     $after = dol_string_nohtmltag($text, 0);
     $this->assertEquals("A\nstring", $after, "test1");
     $text = "A <b>string<b>\n\nwith html tag and '<' chars<br>\n";
     $after = dol_string_nohtmltag($text, 0);
     $this->assertEquals("A string\n\nwith html tag and '<' chars", $after, "test2");
     $text = "A <b>string<b>\n\nwith tag with < chars<br>\n";
     $after = dol_string_nohtmltag($text, 1);
     $this->assertEquals("A string with tag with < chars", $after, "test3");
     return true;
 }