//// 'lb_contract_date_end', //// 'lb_contract_type', //// 'lb_contract_amount', //// 'lb_contract_parent', //// 'lb_contract_status', // ), //)); $this->widget('editable.EditableDetailView', array('id' => 'user-details', 'data' => $model, 'url' => $model->getActionURL('ajaxUpdateField'), 'placement' => 'right', 'attributes' => array(array('name' => 'lb_customer_id', 'editable' => array('type' => 'select', 'source' => CHtml::listData(LbCustomer::model()->findAll(), 'lb_record_primary_key', 'lb_customer_name'))), array('name' => 'lb_address_id', 'editable' => array('type' => 'select', 'source' => CHtml::listData(LbCustomerAddress::model()->findAll(), 'lb_record_primary_key', 'lb_customer_address_line_1'))), array('name' => 'lb_contact_id', 'editable' => array('type' => 'select', 'source' => CHtml::listData(LbCustomerContact::model()->getResultsAsFindAll(), 'lb_record_primary_key', 'lb_customer_contract_name'))), array('name' => 'lb_contract_date_start', 'editable' => array('type' => 'date', 'viewformat' => 'dd-mm-yyyy', 'format' => 'yyyy-mm-dd')), array('name' => 'lb_contract_date_end', 'editable' => array('type' => 'date', 'viewformat' => 'dd-mm-yyyy', 'format' => 'yyyy-mm-dd')), array('name' => 'lb_contract_type', 'editable' => array('type' => 'text')), array('name' => 'lb_contract_notes', 'editable' => array('type' => 'textarea')), array('name' => 'lb_contract_status', 'editable' => array('type' => 'select', 'source' => LbContracts::$ContractStatusArray)), 'lb_contract_amount'))); ?> <div style="margin-top: 30px;"> <h4><?php echo Yii::t('lang', 'Document'); ?> </h4> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'lb-contracts-documnet_grid', 'dataProvider' => LbContractDocument::model()->getContractDocument($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 border=\'0\' alt=\'\' src=\'".Yii::app()->getBaseUrl().$data->lb_document_url_icon."\' />".$data->lb_document_name."</a>"'), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => "{delete}", 'deleteButtonUrl' => 'Yii::app()->createUrl("lbContract/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-contracts-documnet_grid');\n \$('#uploadFile .qq-upload-list').html('');\n }"))); } ?> </div> </div> <div style="margin-top: 30px;"> <div style="margin-top: 40px;" class="panel-header-title"> <div class="panel-header-title-left" style="width: 20%"> <h4><?php echo Yii::t('lang', 'Related Invoice'); ?>
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); $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); // $duoi='.'.$temp[count($temp)-1]; // $lendduoi = strlen($temp[count($temp)-1])+1; // $filename = substr( $pic->name,0,strlen($pic->name)-$lendduoi); $documentModel = new LbContractDocument(); $documentModel->lb_contract_id = $id; $documentModel->lb_document_url = "/uploads/" . $fileName; $documentModel->lb_document_name = $fileName; $documentModel->lb_document_url_icon = "/images/fileicons/32px/" . $temp[count($temp) - 1] . ".png"; $documentModel->save(); // DONE return $return; // it's array }