public function __construct($new, $unit)
 {
     $absolute = formatNumber($new / $unit);
     $relative = formatNumber($absolute - 1);
     $hundred = formatNumber($absolute * 100);
     if ($absolute > 1) {
         $nominal = 'positive';
     } else {
         if ($absolute = 1) {
             $nominal = 'status-quo';
         } else {
             $nominal = 'negative';
         }
     }
 }
Esempio n. 2
0
function formatBytes($bytes, $precision = 2, $system = 'IEC')
{
    if ($system === 'IEC') {
        $base = 1024;
        $units = array('B', 'KiB', 'MiB', 'GiB', 'TiB');
    } elseif ($system === 'SI') {
        $base = 1000;
        $units = array('B', 'KB', 'MB', 'GB', 'TB');
    }
    $bytes = max(intval($bytes), 0);
    $pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base));
    $pow = min($pow, count($units) - 1);
    $bytes /= pow($base, $pow);
    return formatNumber($bytes, $precision) . ' ' . $units[$pow];
}
function formatNumber($v, $noOfDec = 2, $pad = null)
{
    $num = sprintf("%.{$noOfDec}f", (double) $v);
    return $num;
    // this to be fixed latter
    if ($num >= 100000) {
        $num = $num / 100000;
        $num = formatNumber($num);
        $num = $num . "Lakh";
    } else {
        if ($num >= 1000) {
            $num = $num / 1000;
            $num = formatNumber($num);
            $num = $num . "<b> K </b>";
        }
    }
}
function parseContacts($filename)
{
    $contacts = array();
    $handle = fopen($filename, 'r');
    $contents = fread($handle, filesize($filename));
    $contactsString = trim($contents);
    $contactsArray = explode("\n", $contactsString);
    $newArray = [];
    fclose($handle);
    foreach ($contactsArray as $value) {
        $personInfoArray = explode("|", $value);
        $personInfoArray[1] = formatNumber($personInfoArray[1]);
        //next line is saying you are pushing info(associative array) into newArray.
        $newArray[] = ['name' => $personInfoArray[0], 'number' => $personInfoArray[1]];
    }
    // array literal notation is this [].
    // todo - read file and parse contacts
    return $newArray;
}
function sort_my_array($arr)
{
    foreach ($arr as $key => $row) {
        $nome[$key] = $row[0];
        $cnpj[$key] = $row[1];
        $usuario[$key] = $row[2];
        $auxVlr = formatNumber($row[3]);
        $valor[$key] = (double) $auxVlr;
        $email[$key] = $row[4];
    }
    if (isset($_GET['ordena'])) {
        switch ($_GET['ordena']) {
            case 'nomeA-emailD-valorD':
                array_multisort($nome, SORT_ASC, $email, SORT_DESC, $valor, SORT_DESC, $arr);
                break;
            case 'nomeD-emailD-valorD':
                array_multisort($nome, SORT_DESC, $email, SORT_DESC, $valor, SORT_DESC, $arr);
                break;
            case 'usuarioA-nomeA-valorD':
                array_multisort($usuario, SORT_ASC, $nome, SORT_ASC, $valor, SORT_DESC, $arr);
                break;
            case 'usuarioD-nomeA-valorD':
                array_multisort($usuario, SORT_DESC, $nome, SORT_ASC, $valor, SORT_DESC, $arr);
                break;
            case 'emailD-nomeD-valorA':
                array_multisort($email, SORT_DESC, $nome, SORT_DESC, $valor, SORT_ASC, $arr);
                break;
            case 'emailA-nomeD-valorA':
                array_multisort($email, SORT_ASC, $nome, SORT_DESC, $valor, SORT_ASC, $arr);
                break;
            case 'valorD-nomeA-emailA':
                array_multisort($valor, SORT_DESC, $nome, SORT_ASC, $email, SORT_ASC, $arr);
                break;
            case 'valorA-nomeA-emailA':
                array_multisort($valor, SORT_ASC, $nome, SORT_ASC, $email, SORT_ASC, $arr);
                break;
            default:
                # code...
                break;
        }
    }
    return $arr;
}
Esempio n. 6
0
function contactInfo($db, $call)
{
    $contacts = '';
    $q3 = "SELECT ares_contact_type, contact, validity, A.type " . "FROM ares_contact_info A, ares_contact_type B " . "WHERE A.type = B.type AND A.call='" . $call . "'";
    //echo "<p>" . $q3 . ",/p>\n";
    $r3 = getResult($q3, $db);
    while ($row3 = getRow($r3, $db)) {
        $xx = $row3[1];
        if ($row3[3] < 4) {
            $xx = formatNumber($row3[1]);
        }
        if ($row3[2] == 1) {
            $contacts = $contacts . $row3[0] . ": <b>" . $xx . "</b><br>";
        } else {
            $contacts = $contacts . $row3[0] . ": " . $xx . "<br>";
        }
    }
    echo $contacts;
}
function parseContacts($filename)
{
    $filename = 'contacts.txt';
    $handle = fopen($filename, 'r');
    $contents = fread($handle, filesize($filename));
    //$keys = array('name','number');
    $trimContent = trim($contents);
    $contacts = array();
    $formatArray = [];
    $contactsArray = explode("\n", $trimContent);
    //$contacts=explode('|',$contents);
    fclose($handle);
    foreach ($contactsArray as $value) {
        $personInfoArray = explode('|', $value);
        $personInfoArray[1] = formatNumber($personInfoArray[1]);
        $formatArray[] = ['name' => $personInfoArray[0], 'number' => $personInfoArray[1]];
    }
    // todo - read file and parse contacts
    return $formatArray;
}
Esempio n. 8
0
    //get current values
    $sth = $dbh->prepare('SELECT *
			FROM ' . $TYPES[$_POST['type']]['pluralName'] . '
			WHERE ' . $TYPES[$_POST['type']]['idName'] . ' = :id');
    $sth->execute([':id' => $_POST['id']]);
    $item = $sth->fetch();
    $return['html'] = '<h1>Edit ' . $_POST['type'] . '</h1>';
    foreach ($TYPES[$_POST['type']]['formData'] as $key => $section) {
        $return['html'] .= '<section><h2>' . $key . '</h2><div class="sectionData">';
        foreach ($section as $column) {
            $return['html'] .= '<ul>';
            foreach ($column as $field) {
                $formalName = $TYPES[$_POST['type']]['fields'][$field]['formalName'];
                $attributes = $TYPES[$_POST['type']]['fields'][$field]['verifyData'];
                if ($attributes[1] == 'int' || $attributes[1] == 'dec') {
                    $item[$field] = formatNumber($item[$field]);
                }
                if ($attributes[1] == 'int' || $attributes[1] == 'str' || $attributes[1] == 'dec' || $attributes[1] == 'email') {
                    $return['html'] .= '<li><label for="' . $field . '">' . $formalName . '</label>';
                    $return['html'] .= '<input type="text" name="' . $field . '" autocomplete="off" value="' . $item[$field] . '"></li>';
                } elseif ($attributes[1] == 'id' || $attributes[1] == 'opt') {
                    $empty = $attributes[0] == 0 || $field == 'managerID' && $item[$field] == 0 ? true : false;
                    //allow empty field if it's not required, or if the item is the top employee
                    $return['html'] .= '<li><label for="' . $field . '">' . $formalName . '</label><select name="' . $field . '">';
                    $return['html'] .= $attributes[1] == 'id' ? generateTypeOptions($attributes[2], $empty, $item[$field]) : generateFieldOptions($_POST['type'], $field, $empty, $item[$field]);
                    $return['html'] .= '</select></li>';
                } elseif ($attributes[1] == 'disp') {
                    $return['html'] .= '<li>&nbsp;</li>';
                } elseif ($attributes[1] == 'date') {
                    $return['html'] .= '<li><label for="' . $field . '">' . $formalName . '</label>';
                    $return['html'] .= '<input type="text" class="dateInput" name="' . $field . '" autocomplete="off" value="' . formatDate($item[$field]) . '"></li>';
Esempio n. 9
0
function getBudgetItemsByBudgetId($budgetId, $isGBK = false)
{
    global $mysql;
    $res = array();
    $arr = $mysql->DBGetAsMap(" select * from `budget_item` where `budgetId` = '?' and `isDeleted` = 'false' ORDER BY LEFT( itemCode, 2 ) ASC , ( SUBSTRING( itemCode, 2 ) ) *1 DESC ", $budgetId);
    $count = 0;
    $smallCount = array(0, 0, 0, 0, 0, 0);
    $directFee = 0;
    $isFirstSmallCount = true;
    $NOPQRSItems = array();
    foreach ($arr as $val) {
        $itemCode = $val['itemCode'];
        $itemUnit = $val['itemUnit'];
        $itemAmount = $val['itemAmount'] == "" || $val['itemAmount'] == null ? 0 : $val['itemAmount'];
        $discount = $val['discount'];
        $budgetId = $val['budgetId'];
        $itemName = $isGBK ? str2GBK($val['itemName']) : $val['itemName'];
        $itemUnit = $isGBK ? str2GBK($val['itemUnit']) : $val['itemUnit'];
        //这几项需要单独计算
        if (in_array($itemCode, array('N', 'O', 'P', 'Q', 'R', 'S'))) {
            $NOPQRSItems[$itemCode] = $val;
            continue;
        }
        // itemCode  长度为1时认为是大项
        if (strlen($itemCode) == 1) {
            if ($isFirstSmallCount) {
                //第一个大项出现时不输出小计
                $isFirstSmallCount = false;
            } else {
                //增加一行小计
                $res[$count++] = array('budgetItemId' => 'NULL' . $count, 'itemName' => $isGBK ? str2GBK('小计') : '小计', 'budgetId' => $budgetId, 'mainMaterialTotalPrice' => $smallCount[0], 'auxiliaryMaterialTotalPrice' => $smallCount[1], 'manpowerTotalPrice' => $smallCount[2], 'machineryTotalPrice' => $smallCount[3], 'manpowerTotalCost' => $smallCount[4], 'mainMaterialTotalCost' => $smallCount[5]);
                $directFee += $smallCount[0];
                $directFee += $smallCount[1];
                $directFee += $smallCount[2];
                $directFee += $smallCount[3];
                $smallCount = array(0, 0, 0, 0, 0, 0);
            }
            //输出大项
            $res[$count++] = array('itemName' => $itemName, 'basicItemId' => $val['basicItemId'], 'itemCode' => $val['itemCode'], 'budgetId' => $val['budgetId'], 'budgetItemId' => $val['budgetItemId'], 'isEditable' => true);
            continue;
        }
        //正常输出项
        $res[$count] = $val;
        $res[$count]['itemName'] = $itemName;
        $res[$count]['itemAmount'] = $itemAmount;
        $res[$count]['itemUnit'] = $itemUnit;
        $res[$count]['mainMaterialPrice'] = $val['mainMaterialPrice'] * $discount / 100;
        $res[$count]['auxiliaryMaterialPrice'] = $val['auxiliaryMaterialPrice'] * $discount / 100;
        $res[$count]['manpowerPrice'] = $val['manpowerPrice'] * $discount / 100;
        $res[$count]['machineryPrice'] = $val['machineryPrice'] * $discount / 100;
        $res[$count]['orgMainMaterialPrice'] = "原价:" . $val['mainMaterialPrice'] . " " . ($discount == 100 ? "" : $discount / 10 . "折");
        $res[$count]['orgAuxiliaryMaterialPrice'] = "原价:" . $val['auxiliaryMaterialPrice'] . " " . ($discount == 100 ? "" : $discount / 10 . "折");
        $res[$count]['orgManpowerPrice'] = "原价:" . $val['manpowerPrice'] . " " . ($discount == 100 ? "" : $discount / 10 . "折");
        $res[$count]['orgMachineryPrice'] = "原价:" . $val['machineryPrice'] . " " . ($discount == 100 ? "" : $discount / 10 . "折");
        //损耗=(主材单价+辅料单价)*0.05,按折扣后的价格
        $loss = ($res[$count]['mainMaterialPrice'] + $res[$count]['auxiliaryMaterialPrice']) * 0.05;
        if ($val['lossPercent'] != $loss) {
            $val['lossPercent'] = $loss;
            editItem($val);
        }
        $res[$count]['lossPercent'] = $loss;
        //主材总价=(主菜单价+损耗)* 数量,按折扣后的价格
        $mainMaterialTotalPrice = $itemAmount * ($res[$count]['mainMaterialPrice'] + $loss);
        $res[$count]['mainMaterialTotalPrice'] = $mainMaterialTotalPrice;
        $res[$count]['auxiliaryMaterialTotalPrice'] = $itemAmount * $res[$count]['auxiliaryMaterialPrice'];
        $res[$count]['manpowerTotalPrice'] = $itemAmount * $res[$count]['manpowerPrice'];
        $res[$count]['machineryTotalPrice'] = $itemAmount * $res[$count]['machineryPrice'];
        $res[$count]['remark'] = $val['remark'] == 'NULL' ? '' : ($isGBK ? str2GBK($val['remark']) : addslashes(nl2br(str_replace("\n", "<br />", $val['remark']))));
        $res[$count]['isEditable'] = true;
        /**
        			2.辅材总价=辅材单价*数量
        			3.人工总价=人工单价*数量
        			4.机械总价=机械单价*数量
        			6.小计=各类小项总价之和
        			7.合计=所有小巷综合			
        			**/
        $smallCount[0] += $res[$count]['mainMaterialTotalPrice'];
        $smallCount[1] += $res[$count]['auxiliaryMaterialTotalPrice'];
        $smallCount[2] += $res[$count]['manpowerTotalPrice'];
        $smallCount[3] += $res[$count]['machineryTotalPrice'];
        $smallCount[4] += $res[$count]['manpowerCost'];
        $smallCount[5] += $res[$count]['mainMaterialCost'];
        foreach ($res[$count] as $key => $val) {
            if ($val === "" || $val === null) {
                //去除空值,减少网络数据量
                unset($res[$count][$key]);
            }
        }
        $count++;
    }
    //如果 isFirstSmallCount 还是初始化的状态true说明没有一行小计,false的时候,说明至少有一个大项输出了。
    if (!$isFirstSmallCount) {
        //最后一行小计
        $res[$count++] = array('budgetItemId' => 'NULL' . $count, 'itemName' => $isGBK ? str2GBK('小计') : '小计', 'budgetId' => $budgetId, 'mainMaterialTotalPrice' => $smallCount[0], 'auxiliaryMaterialTotalPrice' => $smallCount[1], 'manpowerTotalPrice' => $smallCount[2], 'machineryTotalPrice' => $smallCount[3], 'manpowerTotalCost' => $smallCount[4], 'mainMaterialTotalCost' => $smallCount[5], 'isEditable' => false);
        $directFee += $smallCount[0];
        $directFee += $smallCount[1];
        $directFee += $smallCount[2];
        $directFee += $smallCount[3];
        $smallCount = array(0, 0, 0, 0, 0, 0);
    }
    //增加一行空行
    $res[$count++] = array('budgetItemId' => 'NULL' . $count, 'budgetId' => $budgetId, 'isEditable' => false);
    //计算其他项
    $totalFee = $directFee;
    //N 工程直接费
    $itemUnit = '元';
    $itemName = '工程直接费';
    $itemCode = 'N';
    $item = $NOPQRSItems[$itemCode];
    $budgetItemId = $item['budgetItemId'];
    $fee = $directFee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    // O 设计费
    $itemUnit = '元';
    $itemName = '设计费3%';
    $itemCode = 'O';
    $item = $NOPQRSItems[$itemCode];
    $itemAmount = $item['itemAmount'];
    $budgetItemId = $item['budgetItemId'];
    $fee = $directFee * $itemAmount;
    $totalFee += $fee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    // P 效果图
    $itemUnit = '张';
    $itemName = '效果图';
    $itemCode = 'P';
    $item = $NOPQRSItems[$itemCode];
    $itemAmount = $item['itemAmount'];
    $budgetItemId = $item['budgetItemId'];
    $fee = 500 * $itemAmount;
    $totalFee += $fee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    // Q 5%管理费
    $itemUnit = '元';
    $itemName = '5%管理费';
    $itemCode = 'Q';
    $item = $NOPQRSItems[$itemCode];
    $itemAmount = $item['itemAmount'];
    $budgetItemId = $item['budgetItemId'];
    $fee = $directFee * $itemAmount;
    $totalFee += $fee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    // R 税金
    $itemUnit = '元';
    $itemName = '税金';
    $itemCode = 'R';
    $item = $NOPQRSItems[$itemCode];
    $itemAmount = $item['itemAmount'];
    $budgetItemId = $item['budgetItemId'];
    $fee = $directFee * $itemAmount;
    $totalFee += $fee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    // S 工程总造价
    $itemUnit = '元';
    $itemName = '工程总造价';
    $itemCode = 'S';
    $item = $NOPQRSItems[$itemCode];
    $budgetItemId = $item['budgetItemId'];
    $itemAmount = '';
    $fee = $totalFee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    foreach ($res as $count => $bItem) {
        //保留小数点后两位,不足补0
        foreach ($bItem as $key => $val) {
            if (!in_array($key, array('itemAmount', 'mainMaterialTotalPrice', 'auxiliaryMaterialTotalPrice', 'manpowerTotalPrice', 'mainMaterialTotalCost', 'lossPercent', 'manpowerTotalCost', 'machineryTotalPrice', 'mainMaterialPrice', 'auxiliaryMaterialPrice', 'machineryPrice', 'manpowerPrice'))) {
                continue;
            }
            $res[$count][$key] = formatNumber($val);
        }
    }
    return $res;
}
Esempio n. 10
0
function formatNumber_money($value)
{
    return formatNumber($value, 'intmoney');
}
Esempio n. 11
0
            <th>Count</th>
        </tr>
    </thead>
    <tbody>
        <?php 
reset($count);
$whole_size = $statistics->getSize();
for ($i = 0; $i < sizeof($count) - 1; $i++) {
    $key = key($count);
    ?>
            <tr>
                <td><?php 
    echo $key;
    ?>
</td>
                <td><?php 
    echo formatSizeNumber($whole_size[$key]);
    ?>
</td>
                <td><?php 
    echo formatNumber($count[$key]);
    ?>
</td>
            </tr>
            <?php 
    next($count);
}
?>
    </tbody>
</table>
Esempio n. 12
0
echo "<h1>User " . $user . "</h1>";
echo "<hr/>";
global $sz_range_fields;
global $sz_range_name;
// summary table
$tab = array(array());
$i = 0;
foreach ($user_info as $g => $vals) {
    if ($vals[COUNT] > 0) {
        $avg = round($vals[SIZE] / $vals[COUNT], 0);
    } else {
        $avg = 0;
    }
    $tab[$i][] = "{$user}/{$g}";
    $tab[$i][] = formatSizeNumber($vals[SIZE]);
    $tab[$i][] = formatNumber($vals[COUNT]);
    $tab[$i][] = formatSizeNumber($avg);
    $i++;
}
$header = "<thead> <tr>";
$header = $header . "<th>User/Group</th>";
$header = $header . "<th>Volume</th>";
$header = $header . "<th>File count</th>";
$header = $header . "<th>Avg Size</th>";
$header = $header . "</tr> </thead>";
generateMergedTable($tab, $header);
// profile table
$sz_ranges = array();
$tab = array(array());
$header = "<thead> <tr>";
foreach ($sz_range_name as $range) {
Esempio n. 13
0
        echo anchor('invoices/view/' . $row->id, $row->invoice_number);
        ?>
</td>
		<td><?php 
        echo anchor('invoices/view/' . $row->id, $display_date);
        ?>
</td>
		<td class="cName"><?php 
        echo anchor('invoices/view/' . $row->id, $row->name);
        ?>
 <span class="short_description"><?php 
        echo $short_description[$row->id];
        ?>
</span></td>
		<td><?php 
        echo anchor('invoices/view/' . $row->id, formatNumber($row->subtotal, TRUE));
        ?>
</td>
		<td>
		<?php 
        if ($row->amount_paid == $row->subtotal) {
            // paid invoices
            echo anchor('invoices/view/' . $row->id, $this->lang->line('invoice_closed'), array('title' => 'invoice status'));
        } elseif ($row->amount_paid > $row->subtotal) {
            // invoices with credit.
            echo anchor('invoices/view/' . $row->id, $this->lang->line('invoice_with_credit'), array('title' => 'invoice status'));
        } elseif (mysql_to_unix($row->dateIssued) >= strtotime('-' . $this->settings_model->get_setting('days_payment_due') . ' days')) {
            // owing less then the overdue days amount
            echo anchor('invoices/view/' . $row->id, $this->lang->line('invoice_open'), array('title' => 'invoice status'));
        } else {
            // owing more then the overdue days amount
Esempio n. 14
0
$count = $statistics->getCount();
for ($i = 0; $i < sizeof($top_size) - 1; $i++) {
    $group = key($top_size);
    ?>
            <tr>
                <td>
                    <?php 
    echo "<a href='" . str_replace(" ", "%20", $group) . "_group_popup.php'rel='#volume'>" . $group . "</a>";
    ?>
                </td>
                <td><?php 
    echo formatSizeNumber($top_size[$group]);
    ?>
</td>
                <td><?php 
    echo formatNumber($count[$group]);
    ?>
</td>
            </tr>
            <?php 
    next($top_size);
}
?>
    </tbody>
</table>

<!-- POPUP -->
<div class="apple_overlay" id="volume">
    <div class="contentWrap"></div>
</div>
Esempio n. 15
0
 /**
  * Computer total cost of a ticket
  *
  * @param $actiontime float : ticket actiontime
  * @param $cost_time float : ticket time cost
  * @param $cost_fixed float : ticket fixed cost
  * @param $cost_material float : ticket material cost
  * @param $edit boolean : used for edit of computation ?
  *
  * @return total cost formatted string
  **/
 static function trackingTotalCost($actiontime, $cost_time, $cost_fixed, $cost_material, $edit = true)
 {
     return formatNumber($actiontime * $cost_time / HOUR_TIMESTAMP + $cost_fixed + $cost_material, $edit);
 }
Esempio n. 16
0
    Redirect("Menu.php");
    exit;
}
$sDate = FilterInput($_GET['date'], 'char', 10);
// JPGraph seems to be fixed.. no longer needed
// setlocale(LC_ALL, 'C');
// Include JPGraph library and the pie chart drawing modules
LoadLib_JPGraph(pie, pie3d);
$sSQL = "SELECT fun_Name as Fund, SUM(dna_Amount) as Total\n\tFROM donations_don\n\tLEFT JOIN donationamounts_dna ON donations_don.don_ID = donationamounts_dna.dna_don_ID\n\tLEFT JOIN donationfund_fun ON donationamounts_dna.dna_fun_ID = donationfund_fun.fun_ID\n\tWHERE don_Date = '{$sDate}'\n\tGROUP BY fun_ID ORDER BY fun_Name ASC";
$result = RunQuery($sSQL);
$i = 0;
while ($row = mysql_fetch_array($result)) {
    extract($row);
    $funds[$i] = $Fund;
    $totals[$i] = $Total;
    $funds[$i] = $funds[$i] . " (" . formatNumber($Total, 'money') . ")";
    $i++;
}
// Start Graphing ---------------------------->
// Create the graph.
$graph = new PieGraph(550, 200);
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set(gettext("Total by Fund for") . " {$sDate}");
$graph->title->SetFont(FF_FONT1, FS_BOLD, 16);
$graph->title->SetColor("darkblue");
$graph->legend->Pos(0.02, 0.15);
// Create the bar plot
$p1 = new PiePlot3d($totals);
$p1->SetTheme("sand");
$p1->SetCenter(0.285);
Esempio n. 17
0
function toNumber($n, $d)
{
    $toNumber = formatNumber($n, $d, -1);
    return @$toNumber;
}
Esempio n. 18
0
 /** Get groups assigned to tickets between 2 dates
  * BASED ON SPIP DISPLAY GRAPH : www.spip.net
  * @param $type string : "month" or "year"
  * @param $entrees array : array containing data to displayed
  * @param $titre string : title
  * @param $unit string : unit
  * @param $showtotal boolean : also show total values ?
  * @return array contains the distinct groups assigned to a tickets
  */
 static function graphBy($entrees, $titre = "", $unit = "", $showtotal = 1, $type = "month")
 {
     global $DB, $CFG_GLPI, $LANG;
     $total = "";
     if ($showtotal == 1) {
         $total = array_sum($entrees);
     }
     echo "<p class='center'>";
     echo "<font face='verdana,arial,helvetica,sans-serif' size='2'>";
     echo "<strong>{$titre} - {$total} {$unit}</strong></font>";
     echo "<div class='center'>";
     if (count($entrees) > 0) {
         $max = max($entrees);
         $maxgraph = substr(ceil(substr($max, 0, 2) / 10) . "000000000000", 0, strlen($max));
         if ($maxgraph < 10) {
             $maxgraph = 10;
         }
         if (1.1 * $maxgraph < $max) {
             $maxgraph .= "0";
         }
         if (0.8 * $maxgraph > $max) {
             $maxgraph = 0.8 * $maxgraph;
         }
         $rapport = 200 / $maxgraph;
         $largeur = floor(420 / count($entrees));
         if ($largeur < 1) {
             $largeur = 1;
         }
         if ($largeur > 50) {
             $largeur = 50;
         }
     }
     echo "<table class='tab_glpi'><tr>";
     echo "<td style='background-image:url(" . $CFG_GLPI["root_doc"] . "/pics/fond-stats.gif)' >";
     echo "<table><tr><td bgcolor='black'>";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/noir.png' width='1' height='200' alt=''></td>";
     // Presentation graphique
     $n = 0;
     $decal = 0;
     $tab_moyenne = "";
     $total_loc = 0;
     while (list($key, $value) = each($entrees)) {
         $n++;
         if ($decal == 30) {
             $decal = 0;
         }
         $decal++;
         $tab_moyenne[$decal] = $value;
         $total_loc = $total_loc + $value;
         reset($tab_moyenne);
         $moyenne = 0;
         while (list(, $val_tab) = each($tab_moyenne)) {
             $moyenne += $val_tab;
         }
         $moyenne = $moyenne / count($tab_moyenne);
         $hauteur_moyenne = round($moyenne * $rapport);
         $hauteur = round($value * $rapport);
         echo "<td class='bottom' width=" . $largeur . ">";
         if ($hauteur >= 0) {
             if ($hauteur_moyenne > $hauteur) {
                 $difference = $hauteur_moyenne - $hauteur - 1;
                 echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/moyenne.png' width=" . $largeur . " height='1' >";
                 echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/rien.gif' width=" . $largeur . " height=" . $difference . " >";
                 echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/noir.png' width=" . $largeur . " height='1' >";
                 if (strstr($key, "-01")) {
                     // janvier en couleur foncee
                     echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/fondgraph1.png' width=" . $largeur . " height=" . $hauteur . " >";
                 } else {
                     echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/fondgraph2.png' width=" . $largeur . " height=" . $hauteur . " >";
                 }
             } else {
                 if ($hauteur_moyenne < $hauteur) {
                     $difference = $hauteur - $hauteur_moyenne - 1;
                     echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/noir.png' width=" . $largeur . " height='1'>";
                     if (strstr($key, "-01")) {
                         // janvier en couleur foncee
                         $couleur = "1";
                         $couleur2 = "2";
                     } else {
                         $couleur = "2";
                         $couleur2 = "1";
                     }
                     echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/fondgraph{$couleur}.png' width=" . $largeur . " height=" . $difference . ">";
                     echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/moyenne.png' width=" . $largeur . " height='1'>";
                     echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/fondgraph{$couleur}.png' width=" . $largeur . " height=" . $hauteur_moyenne . ">";
                 } else {
                     echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/noir.png' width=" . $largeur . " height='1'>";
                     if (strstr($key, "-01")) {
                         // janvier en couleur foncee
                         echo "<img alt=\"{$key}: {$val_tab}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/fondgraph1.png' width=" . $largeur . " height=" . $hauteur . ">";
                     } else {
                         echo "<img alt=\"{$key}: {$value}\" title=\"{$key}: {$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/fondgraph2.png' width=" . $largeur . " height=" . $hauteur . ">";
                     }
                 }
             }
         }
         echo "<img alt=\"{$value}\" title=\"{$value}\" src='" . $CFG_GLPI["root_doc"] . "/pics/rien.gif' width=" . $largeur . " height='1'>";
         echo "</td>\n";
     }
     echo "<td bgcolor='black'>";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/noir.png' width='1' height='1' alt=''></td></tr>";
     if ($largeur > 10) {
         echo "<tr><td></td>";
         foreach ($entrees as $key => $val) {
             if ($type == "month") {
                 $splitter = explode("-", $key);
                 echo "<td class='center'>" . utf8_substr($LANG['calendarM'][$splitter[1] - 1], 0, 3) . "</td>";
             } else {
                 if ($type == "year") {
                     echo "<td class='center'>" . substr($key, 2, 2) . "</td>";
                 }
             }
         }
         echo "</tr>";
     }
     if ($maxgraph <= 10) {
         $r = 2;
     } else {
         if ($maxgraph <= 100) {
             $r = 1;
         } else {
             $r = 0;
         }
     }
     echo "</table>";
     echo "</td>";
     echo "<td style='background-image:url(" . $CFG_GLPI["root_doc"] . "/pics/fond-stats.gif)' class='bottom'>";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rien.gif' style='background-color:black;' " . "width='3' height='1' alt=''></td>";
     echo "<td><img src='" . $CFG_GLPI["root_doc"] . "/pics/rien.gif' width='5' height='1' alt=''></td>";
     echo "<td class='top'>";
     echo "<table>";
     echo "<tr><td height='15' class='top'>";
     echo "<font face='arial,helvetica,sans-serif' size='1' class ='b'>" . formatNumber($maxgraph, false, $r) . "</font></td></tr>";
     echo "<tr><td height='25' class='middle'>";
     echo "<font face='arial,helvetica,sans-serif' size='1' color='#999999'>" . formatNumber(7 * ($maxgraph / 8), false, $r) . "</font></td></tr>";
     echo "<tr><td height='25' class='middle'>";
     echo "<font face='arial,helvetica,sans-serif' size='1'>" . formatNumber(3 * ($maxgraph / 4), false, $r);
     echo "</font></td></tr>";
     echo "<tr><td height='25' class='middle'>";
     echo "<font face='arial,helvetica,sans-serif' size='1' color='#999999'>" . formatNumber(5 * ($maxgraph / 8), false, $r) . "</font></td></tr>";
     echo "<tr><td height='25' class='middle'>";
     echo "<font face='arial,helvetica,sans-serif' size='1' class ='b'>" . formatNumber($maxgraph / 2, false, $r) . "</font></td></tr>";
     echo "<tr><td height='25' class='middle'>";
     echo "<font face='arial,helvetica,sans-serif' size='1' color='#999999'>" . formatNumber(3 * ($maxgraph / 8), false, $r) . "</font></td></tr>";
     echo "<tr><td height='25' class='middle'>";
     echo "<font face='arial,helvetica,sans-serif' size='1'>" . formatNumber($maxgraph / 4, false, $r);
     echo "</font></td></tr>";
     echo "<tr><td height='25' class='middle'>";
     echo "<font face='arial,helvetica,sans-serif' size='1' color='#999999'>" . formatNumber(1 * ($maxgraph / 8), false, $r) . "</font></td></tr>";
     echo "<tr><td height='10' class='bottom'>";
     echo "<font face='arial,helvetica,sans-serif' size='1' class='b'>0</font></td></tr>";
     echo "</table>";
     echo "</td></tr></table>";
     echo "</div>";
 }
Esempio n. 19
0
/**  Restore a mysql dump
 *
 * @param $DB DB object
 * @param $dumpFile dump file
 * @param $duree max delay before refresh
**/
function restoreMySqlDump($DB, $dumpFile, $duree)
{
    global $DB, $TPSCOUR, $offset, $cpt, $LANG;
    // $dumpFile, fichier source
    // $duree=timeout pour changement de page (-1 = aucun)
    // Desactivation pour empecher les addslashes au niveau de la creation des tables
    // En plus, au niveau du dump on considere qu'on est bon
    // set_magic_quotes_runtime(0);
    if (!file_exists($dumpFile)) {
        echo $LANG['document'][38] . "&nbsp;: {$dumpFile}<br>";
        return false;
    }
    $fileHandle = fopen($dumpFile, "rb");
    if (!$fileHandle) {
        echo $LANG['document'][45] . "&nbsp;: {$dumpFile}<br>";
        return false;
    }
    if ($offset != 0) {
        if (fseek($fileHandle, $offset, SEEK_SET) != 0) {
            //erreur
            echo $LANG['backup'][22] . " " . formatNumber($offset, false, 0) . "<br>";
            return false;
        }
        glpi_flush();
    }
    $formattedQuery = "";
    while (!feof($fileHandle)) {
        current_time();
        if ($duree > 0 && $TPSCOUR >= $duree) {
            //on atteint la fin du temps imparti
            return true;
        }
        // specify read length to be able to read long lines
        $buffer = fgets($fileHandle, 102400);
        // do not strip comments due to problems when # in begin of a data line
        $formattedQuery .= $buffer;
        if (get_magic_quotes_runtime()) {
            $formattedQuery = stripslashes($formattedQuery);
        }
        if (substr(rtrim($formattedQuery), -1) == ";") {
            // Do not use the $DB->query
            if ($DB->query($formattedQuery)) {
                //if no success continue to concatenate
                $offset = ftell($fileHandle);
                $formattedQuery = "";
                $cpt++;
            }
        }
    }
    if ($DB->error) {
        echo "<hr>" . $LANG['backup'][23] . " [{$formattedQuery}]<br>" . $DB->error() . "<hr>";
    }
    fclose($fileHandle);
    $offset = -1;
    return true;
}
Esempio n. 20
0
function getHoursAvailable($userid, $type = 1, $start = '2015-01-01', $end = '2015-12-31')
{
    $accrued = getHoursAccrued($userid, $type, $start, $end);
    //debugMessage($accrued);
    $taken = getHoursTaken($userid, $type, $start, $end);
    //debugMessage($taken);
    $available = $accrued - $taken;
    // debugMessage($available);
    return $available < 0 ? 0 : formatNumber($available);
}
         $occ = "";
     }
     $protec = "";
     if ($a->armorKinetic == 0 && $a->armorEnergy == 0) {
         $protec = "see memo";
         //No protec, see memeo
     } else {
         $protec = "Kin: " . formatNumber($a->armorKinetic) . "  Ene: " . formatNumber($a->armorEnergy);
         $protectionKinetic += $a->armorKinetic;
         $protectionEnergy += $a->armorEnergy;
     }
     echo formatResult($occ . $a->name . ($a->gearType == EPGear::$IMPLANT_GEAR ? " (Implant)" : "")) . $tab . $protec . $tab . setBookLink($a->name, $p) . $carriageReturn;
 }
 # total protection
 if ($protectionKinetic > 0 || $protectionEnergy > 0) {
     echo formatResult("") . $tab . "Kin: " . formatNumber($protectionKinetic) . "  Ene: " . formatNumber($protectionEnergy) . $carriageReturn;
 }
 echo $line . $carriageReturn;
 //GEARS
 echo formatTitle("Gears") . $carriageReturn . $carriageReturn;
 $gears = filterGeneralOnly($morphGear);
 foreach ($gears as $g) {
     if ($g->occurence > 1) {
         $occ = "(" . $g->occurence . ") ";
     } else {
         $occ = "";
     }
     echo formatResult($occ . " " . $g->name) . $tab . setBookLink($g->name, $p) . $carriageReturn;
 }
 echo $line . $carriageReturn;
 //IMPLANTS
Esempio n. 22
0
 /**
  * Return the name from the category and sub category values
  *
  * @return String the displayed name of the activity from the category and subcategory values
  */
 function getActivtyNameForDisplay()
 {
     $theamount = formatNumber($this->getAmount());
     if ($this->getCategory() == "Annual") {
         return $this->getName() . " (" . $theamount . " - Annual)";
     } elseif ($this->getCategory() == "Per Month") {
         return $this->getName() . " (" . $theamount . "/Month)";
     } elseif ($this->getCategory() == "Per Employee Per Month") {
         return $this->getName() . " (" . $theamount . "/Month)";
     } elseif ($this->getCategory() == "Per Employee Earning Percentage") {
         if ($this->getSubCategory() == "Max Social") {
             return $this->getName() . " (" . $theamount . "% of Gross -- Less or Equal to )" . MAX_SOCIAL_SECURITY;
         } else {
             return $this->getName() . " (" . $theamount . "% of Gross)";
         }
     } elseif ($this->getCategory() == "Per Employee") {
         return $this->getName() . " (" . $theamount . "/per employee)";
     } elseif ($this->getCategory() == "One Off") {
         return $this->getName() . " (" . $theamount . " - One Off)";
     }
     return $this->getName();
 }
Esempio n. 23
0
/** Display an infocom report
 *
 * @param $itemtype item type
 * @param $begin begin date
 * @param $end end date
**/
function display_infocoms_report($itemtype, $begin, $end)
{
    global $DB, $valeurtot, $valeurnettetot, $valeurnettegraphtot, $valeurgraphtot, $LANG, $CFG_GLPI;
    $itemtable = getTableForItemType($itemtype);
    $query = "SELECT `glpi_infocoms`.*,\n                    `{$itemtable}`.`name` AS name,\n                    `{$itemtable}`.`ticket_tco`,\n                    `glpi_entities`.`completename` AS entname,\n                    `glpi_entities`.`id` AS entID\n             FROM `glpi_infocoms`\n             INNER JOIN `{$itemtable}` ON (`{$itemtable}`.`id` = `glpi_infocoms`.`items_id`\n                                         AND `glpi_infocoms`.`itemtype` = '{$itemtype}')\n             LEFT JOIN `glpi_entities` ON (`{$itemtable}`.`entities_id` = `glpi_entities`.`id`)\n             WHERE `{$itemtable}`.`is_template` = '0' " . getEntitiesRestrictRequest("AND", $itemtable);
    if (!empty($begin)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` >= '{$begin}'\n                       OR `glpi_infocoms`.`use_date` >= '{$begin}') ";
    }
    if (!empty($end)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` <= '{$end}'\n                       OR `glpi_infocoms`.`use_date` <= '{$end}') ";
    }
    $query .= " ORDER BY entname ASC, `buy_date`, `use_date`";
    $display_entity = isMultiEntitiesMode();
    $result = $DB->query($query);
    if ($DB->numrows($result) > 0) {
        $item = new $itemtype();
        echo "<h2>" . $item->getTypeName() . "</h2>";
        echo "<table class='tab_cadre'><tr><th>" . $LANG['common'][16] . "</th>";
        if ($display_entity) {
            echo "<th>" . $LANG['entity'][0] . "</th>";
        }
        echo "<th>" . $LANG['financial'][21] . "</th><th>" . $LANG['financial'][92] . "</th>";
        echo "<th>" . $LANG['financial'][91] . "</th><th>" . $LANG['financial'][14] . "</th>";
        echo "<th>" . $LANG['financial'][76] . "</th><th>" . $LANG['financial'][80] . "</th></tr>";
        $valeursoustot = 0;
        $valeurnettesoustot = 0;
        $valeurnettegraph = array();
        $valeurgraph = array();
        while ($line = $DB->fetch_array($result)) {
            if (isset($line["is_global"]) && $line["is_global"]) {
                $line["value"] *= Computer_Item::countForItem($itemtype, $line["items_id"]);
            }
            if ($line["value"] > 0) {
                $valeursoustot += $line["value"];
            }
            $valeurnette = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "n");
            $tmp = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "all");
            if (is_array($tmp) && count($tmp) > 0) {
                foreach ($tmp["annee"] as $key => $val) {
                    if ($tmp["vcnetfin"][$key] > 0) {
                        if (!isset($valeurnettegraph[$val])) {
                            $valeurnettegraph[$val] = 0;
                        }
                        $valeurnettegraph[$val] += $tmp["vcnetdeb"][$key];
                    }
                }
            }
            if (!empty($line["buy_date"])) {
                $year = substr($line["buy_date"], 0, 4);
                if ($line["value"] > 0) {
                    if (!isset($valeurgraph[$year])) {
                        $valeurgraph[$year] = 0;
                    }
                    $valeurgraph[$year] += $line["value"];
                }
            }
            $valeurnettesoustot += str_replace(" ", "", $valeurnette);
            echo "<tr class='tab_bg_1'><td>" . $line["name"] . "</td>";
            if ($display_entity) {
                if ($line['entID'] == 0) {
                    echo "<td>" . $LANG['entity'][2] . "</td>";
                } else {
                    echo "<td>" . $line['entname'] . "</td>";
                }
            }
            echo "<td class='right'>" . formatNumber($line["value"]) . "</td><td class='right'>" . formatNumber($valeurnette) . "</td><td class='right'>" . Infocom::showTco($line["ticket_tco"], $line["value"]) . "</td><td>" . convDate($line["buy_date"]) . "</td><td>" . convDate($line["use_date"]) . "</td><td>" . getWarrantyExpir($line["buy_date"], $line["warranty_duration"]) . "</td></tr>";
        }
        $valeurtot += $valeursoustot;
        $valeurnettetot += $valeurnettesoustot;
        echo "<tr><td colspan='6' class='center'><h3>" . $LANG['common'][33] . "&nbsp;: " . $LANG['financial'][21] . "=" . formatNumber($valeursoustot) . " - " . $LANG['financial'][81] . "=" . formatNumber($valeurnettesoustot) . "</h3></td></tr>";
        if (count($valeurnettegraph) > 0) {
            echo "<tr><td colspan='5' class='center'>";
            ksort($valeurnettegraph);
            $valeurnettegraphdisplay = array_map('round', $valeurnettegraph);
            foreach ($valeurnettegraph as $key => $val) {
                if (!isset($valeurnettegraphtot[$key])) {
                    $valeurnettegraphtot[$key] = 0;
                }
                $valeurnettegraphtot[$key] += $valeurnettegraph[$key];
            }
            Stat::showGraph(array($LANG['financial'][81] => $valeurnettegraphdisplay), array('title' => $LANG['financial'][81], 'width' => 400));
            echo "</td></tr>";
        }
        if (count($valeurgraph) > 0) {
            echo "<tr><td colspan='5' class='center'>";
            ksort($valeurgraph);
            $valeurgraphdisplay = array_map('round', $valeurgraph);
            foreach ($valeurgraph as $key => $val) {
                if (!isset($valeurgraphtot[$key])) {
                    $valeurgraphtot[$key] = 0;
                }
                $valeurgraphtot[$key] += $valeurgraph[$key];
            }
            Stat::showGraph(array($LANG['financial'][21] => $valeurgraphdisplay), array('title' => $LANG['financial'][21], 'width' => 400));
            echo "</td></tr>";
        }
        echo "</table>";
        return true;
    }
    return false;
}
    }
    return false;
}
$types = array('Cartridge', 'Consumable', 'SoftwareLicense');
$i = 0;
echo "<table width='90%'><tr><td class='center top'>";
while (count($types) > 0) {
    $type = array_shift($types);
    if (display_infocoms_report($type, $_POST["date1"], $_POST["date2"])) {
        echo "</td>";
        $i++;
        if ($i % 2 == 0) {
            echo "</tr><tr>";
        }
        echo "<td class='center top'>";
    }
}
if ($i % 2 == 0) {
    echo "&nbsp;</td><td>&nbsp;";
}
echo "&nbsp;</td></tr></table>";
echo "<div class='center'><h3>" . $LANG['common'][33] . "&nbsp;: " . $LANG['financial'][21] . " = " . formatNumber($valeurtot) . " - " . $LANG['financial'][81] . " = " . formatNumber($valeurnettetot) . "</h3></div>\n";
if (count($valeurnettegraphtot) > 0) {
    $valeurnettegraphtotdisplay = array_map('round', $valeurnettegraphtot);
    Stat::showGraph(array($LANG['financial'][81] => $valeurnettegraphtotdisplay), array('title' => $LANG['financial'][81]));
}
if (count($valeurgraphtot) > 0) {
    $valeurgraphtotdisplay = array_map('round', $valeurgraphtot);
    Stat::showGraph(array($LANG['financial'][21] => $valeurgraphtotdisplay), array('title' => $LANG['financial'][21]));
}
commonFooter();
Esempio n. 25
0
	function checkType($row,$key){
		$level = "";
		if(isset($this->arrayFieldLevel[$this->arrayField[$key]])){
			for($i=0;$i<$row["level"];$i++){
				$level .= $this->arrayFieldLevel[$this->arrayField[$key]];
			}
		}
		switch($this->arrayType[$key]){
			
			//kiểu tiền tệ VNĐ
			case "vnd":
				return '<td ' . $this->arrayAttribute[$key] . '><span class="clickedit vnd" style="display:inline" id="' . $this->arrayField[$key] . ',' . $row[$this->field_id] . ',3">' .  formatNumber($row[$this->arrayField[$key]]) . '</span></td>';
			break;
			
			//kiểu tiền tệ USD
			case "usd":
				return '<td ' . $this->arrayAttribute[$key] . '><span class="clickedit vnd" style="display:inline" id="' . $this->arrayField[$key] . ',' . $row[$this->field_id] . ',3">' .  $row[$this->arrayField[$key]] . '</span></td>';
			break;
			
			//kiểu ngày tháng
			case "date":
				return '<td class="date" align="center" ' . $this->arrayAttribute[$key] . '>' .  date("d/m/Y",$row[$this->arrayField[$key]]) . '</td>';
			break;
			
			//kiểu hình ảnh
			case "picture":
				if($row[$this->arrayField[$key]]!=''){
					global $fs_filepath;
					return '<td width="30" align="center" style="padding:1px;" ><a rel="tooltip"  title="<img src=\'' . $fs_filepath . "small/small_" . $row[$this->arrayField[$key]] . '\' border=\'0\'>" href="#"><img src="' . $fs_filepath . "/small/small_" . $row[$this->arrayField[$key]] . '" width=30 height="20" border="0"></a></td>';
				}else{
					return '<td width="30">&nbsp;</td>';
				}
			break;
			
			//kiểu mãng dùng cho combobox có thể edit
			case "array":
				$field = $this->arrayField[$key];
				global $$field;
				$arrayList = $$field;
				$value = isset($arrayList[$row[$this->arrayField[$key]]]) ? $arrayList[$row[$this->arrayField[$key]]] : '';
				return '<td ' . $this->arrayAttribute[$key] . '  class="tooltip"  title="' . translate_text("Click sửa đổi sau đó chọn save") . '"><span class="editable_select_' . $this->arrayField[$key] . '" style="display:inline" id="select_2" name="' . $this->arrayField[$key] . ',' . $row[$this->field_id] . ',0">' . str_replace("-","",$value)  . '</span></td>';
			break;
			
			//kiểu mãng chỉ hiển thị không edit được
			case "arraytext":
				$field = $this->arrayField[$key];
				global $$field;
				$arrayList = $$field;
				$value = isset($arrayList[$row[$this->arrayField[$key]]]) ? $arrayList[$row[$this->arrayField[$key]]] : '';
				return '<td ' . $this->arrayAttribute[$key] . '>' . str_replace("-","",$value)  . '</td>';
			break;
			
			//kiểu copy bản ghi
			case "copy":
				return '<td width="10" align="center"><a class="edit"  rel="tooltip"  title="' . translate_text("Nhân bản thêm 1 bản ghi mới") . '" href="copy.php?record_id=' .  $row[$this->field_id] . '&url=' . base64_encode($_SERVER['REQUEST_URI']) . '"><img src="' . $this->image_path . 'copy.gif" border="0"></a></td>';
			break;
			
			//kiểu check box giá trị là 0 hoặc 1
			case "checkbox":
				return '<td width="10" align="center"><a class="edit" onclick="update_check(this); return false" href="listing.php?field=' . $this->arrayField[$key] . '&checkbox=1&record_id=' .  $row[$this->field_id] . '&url=' . base64_encode($_SERVER['REQUEST_URI']) . '"><img src="' . $this->image_path . 'check_' . $row[$this->arrayField[$key]] . '.gif" border="0"></a></td>';
			break;
			
			//kiểu hiển thị nút edit
			case "edit":
				return '<td width="10" align="center"><a class="edit"  rel="tooltip" title="' . translate_text("Bạn muốn sửa đổi bản ghi") . '" href="edit.php?record_id=' .  $row[$this->field_id] . '&url=' . base64_encode($_SERVER['REQUEST_URI']) . '"><img src="' . $this->image_path . 'edit.png" border="0"></a></td>';
			break;
			
			//kểu hiện thị nút xóa
			case "delete":
				if($this->delete){
					return '<td width="10"  align="center"><a class="delete" href="#" onclick="if (confirm(\''  . str_replace("'","\'",translate_text("Bạn muốn xóa bản ghi?") . ': ' . $row[$this->field_name])  . '\')){ deleteone(' . $row[$this->field_id] . '); }"><img src="' . $this->image_path . 'delete.gif" border="0"></a></td>';
				}else{
					return '';
				}
			break;
			
			case "view":
				return '<td width="10" align="center"><a class="view"  rel="tooltip" title="' . translate_text("Bạn muốn xem bản ghi") . '" href="view.php?record_id=' .  $row[$this->field_id] . '&url=' . base64_encode($_SERVER['REQUEST_URI']) . '"><img src="' . $this->image_path . 'view.gif" border="0"></a></td>';
			break;
			
			//kểu hiện thị nút xem toàn bộ phá giá của doanh nghiệp
			case "view_phagia":
				return '<td width="80" align="center"><a class="edit"  rel="tooltip" title="' . translate_text("Xem toàn bộ phá giá") . '" href="../phagia/listing.php?iBus=' .  $row[$this->field_id] . '&url=' . base64_encode($_SERVER['REQUEST_URI']) . '"><img src="' . $this->image_path . 'view.gif" border="0"></a></td>';
			break;
			
			//kiểu hiển thị text có sửa đổi
			case "string":
				return '<td ' . $this->arrayAttribute[$key] . ' class="tooltip"  title="' . translate_text("Click vào để sửa đổi sau đó enter để lưu lại") . '">' . $level . '<span class="clickedit" style="display:inline" id="' . $this->arrayField[$key] . ',' . $row[$this->field_id] . ',0">' .  $row[$this->arrayField[$key]] . '</span></td>';
			break;
			
			//kiểu hiện thị text không sửa đổi
			case "text":
				return '<td ' . $this->arrayAttribute[$key] . '>'  .  $row[$this->arrayField[$key]] . '</td>';
			break;
			
			//kiểu hiển thị số có sửa đổi
			case "number":
				return '<td ' . $this->arrayAttribute[$key] . ' class="tooltip"  title="' . translate_text("Click vào để sửa đổi sau đó enter để lưu lại") . '" align="center" width="10%" nowrap="nowrap">' . $level . '<span class="clickedit" style="display:inline" id="' . $this->arrayField[$key] . ',' . $row[$this->field_id] . ',0">' .  $row[$this->arrayField[$key]] . '</span></td>';
			break;
			
			//kiểu hiển thị số ko sửa đổi
			case "numbernotedit":
				return '<td ' . $this->arrayAttribute[$key] . ' align="center" width="10%" nowrap="nowrap">' . $level .  $row[$this->arrayField[$key]] . '</td>';
			break;
			
			//kiểu hiện nút reset
			case "resetpass":
				return '<td width="10"  align="center"><a href="#" onclick="if (confirm(\''  . str_replace("'","\'",translate_text("Bạn muốn reset lại password của user này không?") . ': ' . $row[$this->field_name])  . '\')){ resetpass(' . $row[$this->field_id] . '); }"><img src="' . $this->image_path . 'reset.gif" border="0"></a></td>';
			break;
			
			//kểu hiện thị nút gui email
			case "sent_email":
				return '<td width="80" align="center"><a class="edit" href="#"  rel="tooltip" title="' . translate_text("Gửi email thông báo tới thành viên") . '" onclick="sent_email(\'' . $row[$this->field_id] . '\')"><img src="' . $this->image_path . 'send.gif" border="0"></a></td>';
			break;
			
			//dạng mặc định
			default:
				return '<td ' . $this->arrayAttribute[$key] . '>' .  $row[$this->arrayField[$key]] . '</td>';
			break;
		}
	}
Esempio n. 26
0
 /**
  * Print the HTML array of value consumed for a budget
  *
  *@return Nothing (display)
  **/
 function showValuesByEntity()
 {
     global $DB, $LANG;
     $budgets_id = $this->fields['id'];
     if (!$this->can($budgets_id, 'r')) {
         return false;
     }
     // Type for which infocom are only template
     $ignore = array('CartridgeItem', 'ConsumableItem', 'Software');
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_infocoms`\n                WHERE `budgets_id` = '{$budgets_id}'\n                     AND `itemtype` NOT IN ('" . implode("','", $ignore) . "')" . getEntitiesRestrictRequest(" AND", 'glpi_infocoms', "entities_id") . "\n                GROUP BY `itemtype`";
     $result = $DB->query($query);
     $total = 0;
     $entities_values = array();
     $entitiestype_values = array();
     $found_types = array();
     if ($DB->numrows($result)) {
         while ($types = $DB->fetch_array($result)) {
             if (!class_exists($types['itemtype'])) {
                 continue;
             }
             $item = new $types['itemtype']();
             $found_types[$types['itemtype']] = $item->getTypeName();
             $table = getTableForItemType($types['itemtype']);
             $query_infos = "SELECT SUM(`glpi_infocoms`.`value`) AS `sumvalue`,\n                                   `{$table}`.`entities_id`\n                            FROM `{$table}`\n                            INNER JOIN `glpi_infocoms`\n                                 ON (`glpi_infocoms`.`items_id` = `{$table}`.`id`\n                                     AND `glpi_infocoms`.`itemtype` = '" . $types['itemtype'] . "')\n                            LEFT JOIN `glpi_entities`\n                                 ON (`{$table}`.`entities_id` = `glpi_entities`.`id`)\n                            WHERE `glpi_infocoms`.`budgets_id` = '{$budgets_id}' " . getEntitiesRestrictRequest(" AND", $table, "entities_id");
             if ($item->maybeTemplate()) {
                 $query_infos .= " AND `{$table}`.`is_template` = '0' ";
             }
             $query_infos .= "GROUP BY `{$table}`.`entities_id`\n                             ORDER BY `glpi_entities`.`completename` ASC";
             if ($result_infos = $DB->query($query_infos)) {
                 //Store, for each entity, the budget spent
                 while ($values = $DB->fetch_array($result_infos)) {
                     if (!isset($entities_values[$values['entities_id']])) {
                         $entities_values[$values['entities_id']] = 0;
                     }
                     if (!isset($entitiestype_values[$values['entities_id']][$types['itemtype']])) {
                         $entitiestype_values[$values['entities_id']][$types['itemtype']] = 0;
                     }
                     $entities_values[$values['entities_id']] += $values['sumvalue'];
                     $entitiestype_values[$values['entities_id']][$types['itemtype']] += $values['sumvalue'];
                 }
             }
         }
         $budget = new Budget();
         $budget->getFromDB($budgets_id);
         $colspan = count($found_types) + 2;
         echo "<div class='spaced'><table class='tab_cadre'>";
         echo "<tr><th colspan='{$colspan}'>" . $LANG['financial'][108] . "</th></tr>";
         echo "<tr><th>" . $LANG['entity'][0] . "</th>";
         if (count($found_types)) {
             foreach ($found_types as $type => $typename) {
                 echo "<th>{$typename}</th>";
             }
         }
         echo "<th>" . $LANG['common'][33] . "</th>";
         echo "</tr>";
         foreach ($entities_values as $entity => $value) {
             echo "<tr class='tab_bg_1'>";
             echo "<td class='b'>" . Dropdown::getDropdownName('glpi_entities', $entity) . "</td>";
             if (count($found_types)) {
                 foreach ($found_types as $type => $typename) {
                     echo "<td class='right'>";
                     $typevalue = 0;
                     if (isset($entitiestype_values[$entity][$type])) {
                         $typevalue = $entitiestype_values[$entity][$type];
                     }
                     echo formatNumber($typevalue);
                     echo "</td>";
                 }
             }
             echo "<td class='right b'>" . formatNumber($value) . "</td>";
             echo "</tr>";
             $total += $value;
         }
         echo "<tr class='tab_bg_1'><th colspan='{$colspan}'><br></th></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='right' colspan='" . ($colspan - 1) . "'>" . $LANG['financial'][108] . "</td>";
         echo "<td class='right b'>" . formatNumber($total) . "</td></tr>";
         if ($_SESSION['glpiactive_entity'] == $budget->fields['entities_id']) {
             echo "<tr class='tab_bg_1'>";
             echo "<td class='right' colspan='" . ($colspan - 1) . "'>" . $LANG['financial'][109] . "</td>";
             echo "<td class='right b'>" . formatNumber($budget->fields['value'] - $total) . "</td></tr>";
         }
         echo "</table></div>";
     }
 }
Esempio n. 27
0
    public function generatePDF($id, $pdfID)
    {
        global $dbh;
        global $SETTINGS;
        $filename = 'Default';
        $html = '';
        if ($pdfID == 1) {
            //TODO: make this look a bit nicer
            //TODO: padding doesn't work in tables in tcpdf, another option might be dompdf (https://github.com/dompdf/dompdf)
            $filename = 'Invoice';
            $html = '<body style="font-size:1em;">
					<div style="width:640px; margin:0 auto;">
					<span style="font-weight:bold; font-size:1.5em;">' . $SETTINGS['companyName'] . '</span>
					<div style="border-bottom: 2px solid #E5E5E5; margin:5px 0;">&nbsp;</div><br>
					Thank you for your order.  Your invoice is below.<br><br>';
            //get order info
            $sth = $dbh->prepare('SELECT date
						FROM orders
						WHERE orderID = :orderID');
            $sth->execute([':orderID' => $id]);
            $row = $sth->fetch();
            $html .= '<b>Order ID:</b> ' . $id . '<br>
						<b>Order Date:</b> ' . formatDate($row['date']) . '<br><br>
						<table style="width:100%;">
							<thead>
								<tr style="font-weight:bold;">
									<th style="width:40%;">Item</th>
									<th style="text-align:center; width:20%;">Quantity</th>
									<th style="text-align:center; width:20%;">Unit Price</th>
									<th style="text-align:right; width:20%;">Item Total</th>
								</tr>
							</thead>
							<tbody>';
            //get line items
            $lineItemTable = self::getLineItemTable($id);
            foreach ($lineItemTable[0] as $line) {
                if ($line['type'] == 'service' || $line['type'] == 'product') {
                    $recurringStr = !is_null($line['recurring']) ? ' (occurs monthly on day ' . $line['recurring'][0] . ' from ' . formatDate($line['recurring'][1]) . ' to ' . formatDate($line['recurring'][2]) . ')' : '';
                    $dateStr = isset($line['date']) ? formatDate($line['date']) . ': ' : '';
                    $html .= '<tr><td style="width:40%;">' . $dateStr . $line['name'] . $recurringStr . '</td>';
                    $html .= '<td style="text-align:center; width:20%;">' . formatNumber($line['quantity']) . '</td>';
                    $html .= '<td style="text-align:center; width:20%;">' . formatCurrency($line['unitPrice']) . '</td>';
                    $html .= '<td style="text-align:right; width:20%;">' . formatCurrency($line['lineAmount']) . '</td></tr>';
                } elseif ($line['type'] == 'discount') {
                    $unitPrice = $line['discountType'] == 'C' ? formatCurrency(-$line['discountAmount']) : $line['discountAmount'] . '%';
                    $html .= '<tr><td>Discount: ' . $line['name'] . '</td><td></td>';
                    $html .= '<td style="text-align:center;">' . $unitPrice . '</td>';
                    $html .= '<td style="text-align:right;">' . formatCurrency(-$line['lineAmount']) . '</td></tr>';
                }
            }
            $html .= '</tbody>
						</table>';
            //find amount paid
            $sth = $dbh->prepare('SELECT SUM(paymentAmount)
							FROM orderPayments
							WHERE orderID = :orderID');
            $sth->execute([':orderID' => $id]);
            $row = $sth->fetch();
            $paidAmount = $row['SUM(paymentAmount)'];
            //print totals
            $html .= '<table style="width:100%; text-align:right;"><tbody>';
            $html .= '<tr><td>Total:</td><td>' . formatCurrency($lineItemTable[1]) . '</td></tr>';
            $html .= '<tr><td>Amount Paid:</td><td>' . formatCurrency($paidAmount, true) . '</td></tr>';
            $html .= '<tr style="font-weight: bold;"><td>Amount Due:</td><td>' . formatCurrency($lineItemTable[1] - $paidAmount, true) . '</td></tr>';
            $html .= '</tbody></table>
					</div>
				</body>
				';
        }
        return [$filename, $html];
    }
Esempio n. 28
0
 /**
  * Show Infocom form for an item (not a standard showForm)
  *
  * @param $item CommonDBTM object
  * @param $withtemplate integer: template or basic item
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $CFG_GLPI, $LANG;
     // Show Infocom or blank form
     if (!haveRight("infocom", "r")) {
         return false;
     }
     if (!$item) {
         echo "<div class='spaced'>" . $LANG['financial'][85] . "</div>";
     } else {
         $date_tax = $CFG_GLPI["date_tax"];
         $dev_ID = $item->getField('id');
         $ic = new self();
         $option = "";
         if ($withtemplate == 2) {
             $option = " readonly ";
         }
         if (!strpos($_SERVER['PHP_SELF'], "infocoms-show") && in_array($item->getType(), array('CartridgeItem', 'ConsumableItem', 'Software'))) {
             echo "<div class='firstbloc center'>" . $LANG['financial'][84] . "</div>";
         }
         if (!$ic->getFromDBforDevice($item->getType(), $dev_ID)) {
             $input = array('itemtype' => $item->getType(), 'items_id' => $dev_ID, 'entities_id' => $item->getEntityID());
             if ($ic->can(-1, "w", $input) && $withtemplate != 2) {
                 echo "<div class='spaced b'>";
                 echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'><th>";
                 echo $item->getTypeName() . " - " . $item->getName() . "</th></tr>";
                 echo "<tr class='tab_bg_1'><td class='center'>";
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php?itemtype=" . $item->getType() . "&amp;items_id={$dev_ID}&amp;add=add'>" . $LANG['financial'][68];
                 echo "</a></td></tr></table></div>";
             }
         } else {
             // getFromDBforDevice
             $canedit = $ic->can($ic->fields['id'], "w") && $withtemplate != 2;
             if ($canedit) {
                 echo "<form name='form_ic' method='post' action='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php'>";
             }
             echo "<div class='spaced'>";
             echo "<table class='tab_cadre" . (!strpos($_SERVER['PHP_SELF'], "infocoms-show") ? "_fixe" : "") . "'>";
             echo "<tr><th colspan='4'>" . $LANG['financial'][3] . "</th></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][26] . "&nbsp;:</td>";
             echo "<td>";
             if ($withtemplate == 2) {
                 echo Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]);
             } else {
                 Dropdown::show('Supplier', array('value' => $ic->fields["suppliers_id"], 'entity' => $item->getEntityID()));
             }
             echo "</td>";
             if (haveRight("budget", "r")) {
                 echo "<td>" . $LANG['financial'][87] . "&nbsp;:</td><td >";
                 Dropdown::show('Budget', array('value' => $ic->fields["budgets_id"], 'entity' => $item->getEntityID(), 'comments' => 1));
             } else {
                 echo "<td colspan='2'>";
             }
             echo "</td></tr>";
             // Can edit calendar ?
             $editcalendar = $withtemplate != 2;
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][18] . "&nbsp;:</td>";
             echo "<td >";
             autocompletionTextField($ic, "order_number", array('option' => $option));
             echo "</td>";
             echo "<td>" . $LANG['financial'][28] . "&nbsp;:</td><td>";
             showDateFormItem("order_date", $ic->fields["order_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][20] . "*&nbsp;:</td>";
             echo "<td>";
             $objectName = autoName($ic->fields["immo_number"], "immo_number", $withtemplate == 2, 'Infocom', $item->getEntityID());
             autocompletionTextField($ic, "immo_number", array('value' => $objectName, 'option' => $option));
             echo "</td>";
             echo "<td>" . $LANG['financial'][14] . "&nbsp;:</td><td>";
             showDateFormItem("buy_date", $ic->fields["buy_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][82] . "&nbsp;:</td>";
             echo "<td>";
             autocompletionTextField($ic, "bill", array('option' => $option));
             echo "</td>";
             echo "<td>" . $LANG['financial'][27] . "&nbsp;:</td><td>";
             showDateFormItem("delivery_date", $ic->fields["delivery_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][19] . "&nbsp;:</td><td>";
             autocompletionTextField($ic, "delivery_number", array('option' => $option));
             echo "</td>";
             echo "<td>" . $LANG['financial'][76] . "&nbsp;:</td><td>";
             showDateFormItem("use_date", $ic->fields["use_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][21] . "&nbsp;:</td>";
             echo "<td><input type='text' name='value' {$option} value='" . formatNumber($ic->fields["value"], true) . "' size='14'></td>";
             echo "</td>";
             echo "<td>" . $LANG['financial'][114] . "&nbsp;:</td><td>";
             showDateFormItem("inventory_date", $ic->fields["inventory_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][78] . "&nbsp;:</td>";
             echo "<td><input type='text' {$option} name='warranty_value' value='" . formatNumber($ic->fields["warranty_value"], true) . "' size='14'></td>";
             echo "<td rowspan='5'>" . $LANG['common'][25] . "&nbsp;:</td>";
             echo "<td rowspan='5' class='middle'>";
             echo "<textarea cols='45' rows='9' name='comment' >" . $ic->fields["comment"];
             echo "</textarea></td></tr>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][81] . "&nbsp;:</td><td>";
             echo formatNumber(self::Amort($ic->fields["sink_type"], $ic->fields["value"], $ic->fields["sink_time"], $ic->fields["sink_coeff"], $ic->fields["warranty_date"], $ic->fields["use_date"], $date_tax, "n"));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][22] . "&nbsp;:</td><td >";
             if ($withtemplate == 2) {
                 echo self::getAmortTypeName($ic->fields["sink_type"]);
             } else {
                 self::dropdownAmortType("sink_type", $ic->fields["sink_type"]);
             }
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][23] . "&nbsp;:</td><td>";
             if ($withtemplate == 2) {
                 echo $ic->fields["sink_time"];
             } else {
                 Dropdown::showInteger("sink_time", $ic->fields["sink_time"], 0, 15);
             }
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][77] . "&nbsp;:</td>";
             echo "<td>";
             autocompletionTextField($ic, "sink_coeff", array('size' => 14, 'option' => $option));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             if (!in_array($item->getType(), array('Cartridge', 'CartridgeItem', 'Consumable', 'ConsumableItem', 'Software', 'SoftwareLicense'))) {
                 echo "<td>" . $LANG['financial'][89] . "&nbsp;:</td><td>";
                 echo self::showTco($item->getField('ticket_tco'), $ic->fields["value"]);
             } else {
                 echo "<td colspan='2'>";
             }
             echo "</td>";
             if (!in_array($item->getType(), array('Cartridge', 'CartridgeItem', 'Consumable', 'ConsumableItem', 'Software', 'SoftwareLicense'))) {
                 echo "<td>" . $LANG['financial'][90] . "&nbsp;:</td><td>";
                 echo self::showTco($item->getField('ticket_tco'), $ic->fields["value"], $ic->fields["warranty_date"]);
             } else {
                 echo "<td colspan='2'>";
             }
             echo "</td></tr>";
             echo "<tr><th colspan='4'>" . $LANG['financial'][7] . "</th></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][29] . "&nbsp;:</td><td>";
             showDateFormItem("warranty_date", $ic->fields["warranty_date"], true, $editcalendar);
             echo "</td>";
             echo "<td>" . $LANG['financial'][15] . "&nbsp;:</td><td>";
             if ($withtemplate == 2) {
                 // -1 = life
                 if ($ic->fields["warranty_duration"] == -1) {
                     echo $LANG['financial'][2];
                 } else {
                     echo $ic->fields["warranty_duration"];
                 }
             } else {
                 Dropdown::showInteger("warranty_duration", $ic->fields["warranty_duration"], 0, 120, 1, array(-1 => $LANG['financial'][2]));
             }
             if ($ic->fields["warranty_duration"] >= 0) {
                 echo " " . $LANG['financial'][57];
             }
             echo "<span class='small_space'>" . $LANG['financial'][88] . "</span>&nbsp;";
             echo getWarrantyExpir($ic->fields["warranty_date"], $ic->fields["warranty_duration"]);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['financial'][16] . "&nbsp;:</td>";
             echo "<td >";
             autocompletionTextField($ic, "warranty_info", array('option' => $option));
             echo "</td>";
             if ($CFG_GLPI['use_mailing']) {
                 echo "<td>" . $LANG['setup'][247] . "&nbsp;:</td>";
                 echo "<td>";
                 echo self::dropdownAlert("alert", $ic->fields["alert"]);
                 Alert::displayLastAlert('Infocom', $ic->fields['id']);
                 echo "</td>";
             } else {
                 echo "</td><td colspan='2'>";
             }
             echo "</td></tr>";
             if ($canedit) {
                 echo "<tr>";
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 echo "<input type='hidden' name='id' value='" . $ic->fields['id'] . "'>";
                 echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\"\n                      class='submit'>";
                 echo "</td>";
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 echo "<input type='submit' name='delete' value=\"" . $LANG['buttons'][6] . "\"\n                      class='submit'>";
                 echo "</td></tr>";
                 echo "</table></div></form>";
             } else {
                 echo "</table></div>";
             }
         }
     }
 }
Esempio n. 29
0
function formatMoney($amount)
{
    $aconfig = Zend_Registry::get("config");
    if (isEmptyString($amount)) {
        return '';
    }
    return formatNumber($amount) . "&nbsp;<span class='pagedescription'>(" . $aconfig->country->currencydecimalplaces . ")</span>";
}
Esempio n. 30
0
$collations = Sql::pSelectMapped('SHOW VARIABLES LIKE "%collation%"');
foreach ($collations as $ch_name => $val) {
    echo $ch_name . ' = ' . $val . '<br/>';
}
echo '<br/>';
// show MySQL query cache settings
$data = Sql::pSelectMapped('SHOW VARIABLES LIKE "%query_cache%"');
if ($data['have_query_cache'] == 'YES') {
    echo '<h2>Query cache settings</h2>';
    echo 'Type: ' . $data['query_cache_type'] . '<br/>';
    //valid values: ON, OFF or DEMAND
    echo 'Size: ' . formatDataSize($data['query_cache_size']) . ' (total size)<br/>';
    echo 'Limit: ' . formatDataSize($data['query_cache_limit']) . ' (per query)<br/>';
    echo 'Min result unit: ' . formatDataSize($data['query_cache_min_res_unit']) . '<br/>';
    echo 'Wlock invalidate: ' . $data['query_cache_wlock_invalidate'] . '<br/><br/>';
    // current query cache status
    $data = Sql::pSelectMapped('SHOW STATUS LIKE "%Qcache%"');
    echo '<h2>Query cache status</h2>';
    echo 'Hits: ' . formatNumber($data['Qcache_hits']) . '<br/>';
    echo 'Inserts: ' . formatNumber($data['Qcache_inserts']) . '<br/>';
    echo 'Queries in cache: ' . formatNumber($data['Qcache_queries_in_cache']) . '<br/>';
    echo 'Total blocks: ' . formatNumber($data['Qcache_total_blocks']) . '<br/>';
    echo '<br/>';
    echo 'Not cached: ' . formatNumber($data['Qcache_not_cached']) . '<br/>';
    echo 'Free memory: ' . formatDataSize($data['Qcache_free_memory']) . '<br/>';
    echo '<br/>';
    echo 'Free blocks: ' . formatNumber($data['Qcache_free_blocks']) . '<br/>';
    echo 'Lowmem prunes: ' . formatNumber($data['Qcache_lowmem_prunes']);
} else {
    echo '<h2>MySQL query cache is disabled</h2>';
}