コード例 #1
0
 public function renderButtons($data, $row)
 {
     //$getAllocatedItem = Allocate::model()->findByAttributes(array('cons_id'=>$data->id,'date_out'=>NULL));
     $getAllocatedItem = Allocate::model()->find('cons_id = :cons_id AND (date_out IS NULL OR date_out = :date_out)', array(':cons_id' => $data->id, ':date_out' => '0000-00-00'));
     $getConsStatus = Consumable::model()->find('id = :id', array(':id' => $data->id));
     $status = Status::model()->find('id = :id', array(':id' => $getConsStatus['status_id']));
     $canAllocate = $getAllocatedItem['allocate_id'] && $status['status'] != 'blocked' ? true : false;
     $this->widget('bootstrap.widgets.TbButtonGroup', array('size' => 'small', 'type' => 'inverse', 'buttons' => array(array('label' => 'Manage Group', 'url' => 'http://localhost/asset_management/index.php/usergroup/listbuilder?groupId=' . $data->id . '&groupName=' . $data->name))));
 }
コード例 #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Consumablestock();
     //$allocate = new Allocate;
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     /*Executed when you have data SUBMITTED*/
     if (isset($_POST['Consumablestock'])) {
         $model->attributes = $_POST['Consumablestock'];
         $model->commodity_id = $_GET['commodity_id'];
         if (!empty($_FILES['Consumablestock']['tmp_name']['document'])) {
             $file = CUploadedFile::getInstance($model, 'document');
             $model->documentFileName = $file->name;
             $model->documentFileType = $file->type;
             $fp = fopen($file->tempName, 'r');
             $content = fread($fp, filesize($file->tempName));
             fclose($fp);
             $model->document = $content;
         }
         if ($model->save()) {
             $stocknameRow = Stockname::model()->findByAttributes(array('commodity_id' => $model->commodity_id));
             /***********Change dynamically**/
             $consumable = Consumable::model()->findByAttributes(array('id' => $model->consumable_id));
             for ($i = 1; $i <= $model->quantity; $i++) {
                 $allocate = new Allocate();
                 $allocate->commodity_id = $model->commodity_id;
                 $allocate->cons_id = $model->consumable_id;
                 $allocate->id = $i;
                 $allocate->stock_id = $model->id;
                 $allocate->date_in = $model->date_in;
                 $allocate->stockname = $stocknameRow['prefix'] . $consumable['name'] . '/' . $allocate->id;
                 $allocate->barcode = Common::getItemBarcode(array("itemId" => $allocate->allocate_id, "barcode" => $allocate->stockname));
                 $allocate->save();
                 //print_r($allocate->getErrors());die;
             }
             //Yii::app()->request->redirect('http://localhost/asset_management/index.php/consumable/admin');
             //Yii::app()->request->redirect('Yii::app()->request->returnUrl');
             //Yii::app()->request->return;
             echo "<script type='text/javascript'>self.history.go(-2);</script>";
         }
     }
     /*Executed when you want to create*/
     $this->render('create', array('model' => $model));
 }
コード例 #3
0
 public static function UpdateStatusOfConsumables($userId)
 {
     /*Get the user's group*/
     $ugRows = Usergroup::model()->findAll('uid=:uid', array(':uid' => $userId));
     $grps = [];
     foreach ($ugRows as $ug) {
         $grps[] = $ug['gid'];
     }
     /*Get Blocked Item Table Ids*/
     $getRows = BlockeditemUser::model()->findAllByAttributes(array('uid' => $userId));
     $biU = [];
     foreach ($getRows as $row) {
         $biU[] = $row['blockitem_id'];
     }
     $getRows = BlockeditemGroup::model()->findAllByAttributes(array('gid' => $grps));
     $biG = [];
     foreach ($getRows as $row) {
         $biG[] = $row['blockitem_id'];
     }
     ////////////Blocked For All
     $getRows = Blockeditem::model()->findAllByAttributes(array('flag' => 0));
     $biA = [];
     foreach ($getRows as $row) {
         $biA[] = $row['id'];
     }
     $blockeditemtableIds = array_merge($biU, $biG);
     $blockeditemtableIds = array_unique(array_merge($blockeditemtableIds, $biA));
     $consumableItemIds = Blockeditem::model()->findAllByAttributes(array('id' => $blockeditemtableIds));
     $consIds = [];
     foreach ($consumableItemIds as $row) {
         $consIds[] = $row['item_id'];
     }
     $getConsumables = Consumable::model()->findAll();
     foreach ($getConsumables as $cons) {
         $model = Consumable::model()->findByPk($cons['id']);
         if (in_array($cons['id'], $consIds)) {
             $model->isBlockedForMe = 1;
         } else {
             $model->isBlockedForMe = 0;
         }
         $model->update();
     }
 }
コード例 #4
0
    <style>
        .buttonDesign{
            margin-left : 2px;
            margin-right : 2px;
        }
    </style>
</html>
<?php 
/* @var $this AllocateController */
/* @var $model Allocate */
$this->breadcrumbs = array('Allocates' => array('admin'), 'Manage');
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$('#allocate-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<?php 
$row = Consumable::model()->findByAttributes(array('id' => $_GET['itemId']));
?>
<h1> Stock <span style="color:#B40431"> <?php 
echo $row['name'];
?>
</span> Barcode <?php 
$this->widget('application.extensions.print.printWidget', array('cssFile' => 'print.css', 'printedElement' => '#barcode'));
?>
</h1>

<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->
コード例 #5
0
ファイル: _form.php プロジェクト: anjanababu/Asset-Management
<div class="form">

    <?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'blockeditem-form', 'enableAjaxValidation' => false));
?>
    

    <?php 
echo $form->errorSummary($model);
?>
    <?php 
$chosenId = $_GET['id'];
$itemId = isset($_GET['itemId']) ? $_GET['itemId'] : '';
$commodityId = isset($_GET['commodity_id']) ? $_GET['commodity_id'] : '';
$item = Consumable::model()->findByAttributes(array('id' => $itemId));
?>
    <?php 
//$a = $item['name'];echo "<script>alert($a)</script>";die;
?>
    <?php 
//<h2><span style="color:#B40431">dsad<?php $item['name']
?>
    
    <p class="help-block">Fields with <span class="required">*</span> are required.</p>
    <?php 
echo $form->hiddenField($model, 'commodity_id', array('span' => 5, 'value' => $commodityId));
?>
    <?php 
echo $form->hiddenField($model, 'item_id', array('span' => 5, 'value' => $itemId));
?>
コード例 #6
0
<div id="chart_big1"></div>
<?php 
$x = array();
$y = array();
$allconsumables = Consumable::model()->findAllByAttributes(array('is_deleted' => 0));
foreach ($allconsumables as $cons) {
    $x[] = $cons['name'];
    $stocks = Allocate::model()->findAllByAttributes(array('cons_id' => $cons['id'], 'date_out' => NULL));
    $y[] = count($stocks);
}
$x_data = json_encode($x);
$y_data = json_encode($y);
Yii::app()->clientScript->registerScript('chart_big1', "\n\$(document).ready(function(){\n        \$.jqplot.config.enablePlugins = true;\n        var s1 = {$y_data};\n        var ticks = {$x_data};\n         \n        plot1 = \$.jqplot('chart_big1', [s1], {\n            // Only animate if we're not using excanvas (not in IE 7 or IE 8)..\n            animate: !\$.jqplot.use_excanvas,\n            seriesDefaults:{\n                renderer:\$.jqplot.BarRenderer,\n                pointLabels: { show: true }\n            },\n            axes: {\n                xaxis: {\n                    renderer: \$.jqplot.CategoryAxisRenderer,\n                    ticks: ticks\n                }\n            },\n            highlighter: { show: false }\n        });\n     \n        \$('#chart1').bind('jqplotDataClick',\n            function (ev, seriesIndex, pointIndex, data) {\n                \$('#info1').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);\n            }\n        );\n    });\n");
コード例 #7
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Consumable the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Consumable::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #8
0
 public function getInfo()
 {
     /* Items allocated*/
     $commodity['consumable'] = Consumable::model()->findAll();
     $commodity['monitor'] = Monitor::model()->findAll();
     $commodity['printers'] = Printers::model()->findAll();
     $commodity['devices'] = Devices::model()->findAll();
     $dup = $commodity;
     /* Items available on Loan*/
     $availableOnLoan = 0;
     $thresholdItems = 0;
     $content = '';
     foreach ($commodity as $key => $commo) {
         foreach ($commo as $item) {
             if ($item['available_on_loan'] == 1 || $item['available_on_loan'] == 'Yes') {
                 ++$availableOnLoan;
             }
             if ($key == 'consumable') {
                 $commodity = Commodity::model()->findByAttributes(array('name' => $key));
                 $allocates = Allocate::model()->findAllByAttributes(array('commodity_id' => $commodity['id'], 'cons_id' => $item['id']));
                 if (count($allocates) < $item['threshold']) {
                     ++$thresholdItems;
                 }
             }
         }
     }
     /** Allocated and unallocated **/
     $countAllocated = 0;
     $countUnAllocated = 0;
     $commodity = $dup;
     $unAllocated = Allocate::model()->findAllByAttributes(array('date_out' => NULL));
     $allocated = Allocate::model()->findAll('date_out IS NOT NULL');
     $countAllocated += count($allocated);
     $countUnAllocated += count($unAllocated);
     $content .= '<b style="color:red">' . $availableOnLoan . '</b> item available on loan<br/>';
     $content .= '<b style="color:red">' . $thresholdItems . '</b> item below threshold<br/>';
     $content .= '<b style="color:red">' . $countAllocated . '</b> item allocated<br/>';
     $content .= '<b style="color:red">' . $countUnAllocated . '</b> item unallocated<br/>';
     /* Items below threshold*/
     return $content;
 }