Example #1
0
 public function actionDownload($id)
 {
     $file = LbDocument::model()->findByPk($id);
     $filePath = $file->lb_document_url;
     $material = LbDocument::model()->findByPk($id);
     $src = $file->lb_document_url;
     $length = strlen($src);
     $src = substr($src, 1, $length);
     //kiem tra nguoi dung
     if (isset(Yii::app()->user)) {
         if (@file_exists($src)) {
             $path_parts = @pathinfo($src);
             //$mime = $this->__get_mime($path_parts['extension']);
             header('Content-Description: File Transfer');
             header('Content-Type: application/octet-stream');
             //header('Content-Type: '.$mime);
             header('Content-Disposition: attachment; filename=' . basename($src));
             header('Content-Transfer-Encoding: binary');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Pragma: public');
             header('Content-Length: ' . filesize($src));
             ob_clean();
             flush();
             readfile($src);
         } else {
             header("HTTP/1.0 404 Not Found");
             exit;
         }
     }
 }
Example #2
0
 public function addDocument($module_name, $parent_id, $fileName)
 {
     $documentModel = new LbDocument();
     $documentModel->lb_document_parent_type = $module_name;
     $documentModel->lb_document_parent_id = $parent_id;
     $documentModel->lb_document_url = "/uploads/" . $fileName;
     $documentModel->lb_document_name = $fileName;
     // this links your picture model to the main model (like your user, or profile model)
     $documentModel->lb_document_encoded_name = $fileName;
     $documentModel->save();
     // DONE
 }
Example #3
0
if (count($invoices) > 0) {
    foreach ($invoices as $inv) {
        $invoice = LbInvoice::model()->findByPk($inv->lb_invoice_id);
        $invoice_view .= $invoice['lb_invoice_no'] . '; ';
    }
}
//    echo '</div><div style="float: right; width: 49%;">';
//    echo '</div>';
?>
    <div style="margin-top: 30px;">
    <h4><?php 
echo Yii::t('lang', 'Document');
?>
</h4>
    <?php 
$this->widget('bootstrap.widgets.TbGridView', array('id' => 'lb-expenses-documnet_grid', 'dataProvider' => LbDocument::model()->getDocumentParentTypeProvider(LbDocument::LB_DOCUMENT_PARENT_TYPE_EXPENSES, $model->lb_record_primary_key), 'template' => '{items}', 'hideHeader' => true, 'htmlOptions' => array('width' => '500'), 'columns' => array(array('type' => 'raw', 'value' => '"<a href=\'".Yii::app()->getBaseUrl().$data->lb_document_url."\'><img width=\'100px;\' border=\'0\' alt=\'\' src=\'".Yii::app()->getBaseUrl().$data->lb_document_url."\' />".$data->lb_document_name."</a>"'), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => $templateDelete, 'deleteButtonUrl' => 'Yii::app()->createUrl("lbExpenses/default/deleteDocument",array("id"=>$data->lb_record_primary_key))', 'htmlOptions' => array('width' => '20')))));
?>
    <div>
            <?php 
if ($canEdit) {
    $this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFile', 'config' => array('action' => $this->createUrl('uploadDocument', array('id' => $model->lb_record_primary_key)), 'allowedExtensions' => array("jpeg", "jpg", "gif", "png", "pdf", "odt", "docx", "doc", "dia"), 'sizeLimit' => 10 * 1024 * 1024, 'minSizeLimit' => 1 * 1024, 'onComplete' => "js:function(id, fileName, responseJSON){\n                                        \$.fn.yiiGridView.update('lb-expenses-documnet_grid');\n                                        \$('#uploadFile .qq-upload-list').html('');\n                                   }")));
}
?>
    </div>
</div>
<?php 
/**
 * Show tabs of other details: address, contact, invoice
 */
$tab_customer = LBApplication::renderPartial($this, '_expenses_customer', array('expenses_customer' => $customerExpenses, 'expenses_id' => $model->lb_record_primary_key), true);
$tab_invoice = LBApplication::renderPartial($this, '_expenses_invoice', array('expenses_invoice' => $invoiceExpenses, 'expenses_id' => $model->lb_record_primary_key), true);
 public function actionUploadDocument($id)
 {
     Yii::import("ext.EAjaxUpload.qqFileUploader");
     $folder = 'uploads/';
     // folder for uploaded files
     $allowedExtensions = array("jpeg", "jpg", "gif", "png", "pdf", "odt", "docx", "doc", "dia");
     //array("jpg","jpeg","gif","exe","mov" and etc...
     $sizeLimit = 10 * 1024 * 1024;
     // maximum file size in bytes
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
     $result = $uploader->handleUpload($folder, false);
     $return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
     $fileSize = filesize($folder . $result['filename']);
     //GETTING FILE SIZE
     $fileName = $result['filename'];
     //GETTING FILE NAME
     //tach filename va duoi
     //                $temp = explode('.', $fileName);
     //                $encoded_filename = str_replace(' ', '_', $filename);
     //                $duoi='.'.$temp[count($temp)-1];
     //                $lendduoi = strlen($temp[count($temp)-1])+1;
     //                $filename = substr( $pic->name,0,strlen($pic->name)-$lendduoi);
     $documentModel = new LbDocument();
     $documentModel->lb_document_parent_type = LbDocument::LB_DOCUMENT_PARENT_TYPE_EXPENSES;
     $documentModel->lb_document_parent_id = $id;
     $documentModel->lb_document_url = "/uploads/" . $fileName;
     $documentModel->lb_document_name = $fileName;
     // this links your picture model to the main model (like your user, or profile model)
     $documentModel->lb_document_encoded_name = $fileName;
     $documentModel->save();
     // DONE
     return $return;
     // it's array
 }
Example #5
0
echo '<div id="container-invoice-internal-note"
    style="display: block; clear: both; padding-top: -9px; width: 100%;" class="">';
echo '<table class="items table table-bordered" style="width:100%;">' . ' <thead>
    <tr>
		<th class="lb-grid-header" style="font-size:18px;">' . Yii::t('lang', 'Attachment') . '</th>
		</tr>
	</thead>';
echo '</table>';
//echo '<tr><td>';
echo '<div>';
$this->widget('bootstrap.widgets.TbGridView', array('id' => 'lb-expenses-documnet_grid', 'dataProvider' => LbDocument::model()->getDocumentParentTypeProvider($module_name, $id), 'template' => '{items}', 'hideHeader' => true, 'htmlOptions' => array('width' => '500'), 'columns' => array(array('type' => 'raw', 'value' => '"<a href=\'".LbDocument::model()->getActionURLNormalized("download",array("id"=>$data->lb_record_primary_key))."\' ><img width=\'100px;\' border=\'0\' alt=\'\' src=\'".Yii::app()->getBaseUrl().$data->lb_document_url."\' />".$data->lb_document_name."</a>"'), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{delete}', 'deleteButtonUrl' => 'LbDocument::model()->getActionURLNormalized("default/deleteDocument",array("id"=>$data->lb_record_primary_key))', 'htmlOptions' => array('width' => '20'), 'afterDelete' => 'function(link,success,data){
                        if(success) {
                            refreshTotals();
                        }
                    } '))));
$this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFile1', 'config' => array('action' => LbDocument::model()->getActionURLNormalized('uploadDocument', array('id' => $id, 'module_name' => $module_name)), 'allowedExtensions' => array("jpeg", "jpg", "gif", "png", "pdf", "odt", "docx", "doc", "dia"), 'sizeLimit' => 10 * 1024 * 1024, 'minSizeLimit' => 1 * 1024, 'element' => '$("#uploadFile)', 'onComplete' => "js:function(id, fileName, responseJSON){\n                                        \$.fn.yiiGridView.update('lb-expenses-documnet_grid');\n                                        \$('#uploadFile1 .qq-upload-list').html('');\n                                        \n                                   }")));
//echo '</td></tr></tbody></table>';
echo '</div>';
echo '</div>';
// end note div
?>
    <div>
        <!--<div class="qq-upload-button" style="position: relative; overflow: hidden; direction: ltr;">Upload a file<input type="file" name="file" style="position: absolute; right: 0px; top: 0px; font-family: Arial; font-size: 118px; margin: 0px; padding: 0px; cursor: pointer; opacity: 0;"></div>-->
            <?php 
//            if($canEdit)
?>
    </div>
 
 <style>
     #uploadFile1 .qq-uploader .qq-upload-button
     {