Beispiel #1
0
 public function initialize()
 {
     $this->add(new Text('name', array('maxlength' => 100, 'type' => 'text', 'placeholder' => 'Nombre de la cuenta', 'required' => 'required', 'class' => 'form-control', 'id' => 'name')));
     $this->add(new Text('nit', array('maxlength' => 20, 'type' => 'text', 'placeholder' => 'NIT', 'class' => 'form-control', 'id' => 'nit')));
     $this->add(new Email('email', array('maxlength' => 100, 'type' => 'email', 'placeholder' => 'Dirección de correo eléctronico', 'required' => 'required', 'class' => 'form-control', 'id' => 'email')));
     $this->add(new Text('phone', array('maxlength' => 30, 'type' => 'text', 'placeholder' => 'Número de télefono o celular', 'required' => 'required', 'class' => 'form-control', 'id' => 'phone')));
     $this->add(new Text('address', array('maxlength' => 100, 'type' => 'text', 'placeholder' => 'Dirección', 'required' => 'required', 'class' => 'form-control', 'id' => 'phone')));
     $countries = array("" => "Seleccione una opción");
     foreach (Country::find() as $country) {
         $countries[$country->idCountry] = $country->name;
     }
     $this->add(new Select('idCountry', $countries, array('class' => 'form-control', 'required' => 'required')));
     $this->add(new Select('state', array(), array('class' => 'form-control', 'required' => 'required')));
     $this->add(new Select('city', array(), array('class' => 'form-control', 'required' => 'required')));
     $this->add(new Text('accountName', array('maxlength' => 100, 'type' => 'text', 'placeholder' => 'Nombre de la cuenta', 'required' => 'required', 'class' => 'form-control', 'id' => 'name')));
     $this->add(new Email('accountEmail', array('maxlength' => 100, 'type' => 'email', 'placeholder' => 'Dirección de correo eléctronico', 'required' => 'required', 'class' => 'form-control', 'id' => 'email')));
     $this->add(new Text('accountPhone', array('maxlength' => 30, 'type' => 'text', 'placeholder' => 'Número de télefono o celular', 'required' => 'required', 'class' => 'form-control', 'id' => 'phone')));
     $this->add(new Text('accountAddress', array('maxlength' => 100, 'type' => 'text', 'placeholder' => 'Dirección', 'required' => 'required', 'class' => 'form-control', 'id' => 'phone')));
     $this->add(new Select('idAccountplan', array()));
     $accounttypes = array("" => "Seleccione una opción");
     foreach (Accounttype::find() as $accounttype) {
         $accounttypes[$accounttype->idAccounttype] = $accounttype->name;
     }
     $this->add(new Select('idAccounttype', $accounttypes, array('class' => 'select2 form-control', 'required' => 'required')));
     $this->add(new Check('status', array('value' => 1, 'id' => 'status', 'class' => 'onoffswitch-checkbox', 'id' => 'status')));
 }
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Accounttype::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
?>
		<?php 
echo $form->error($model, 'accounttypename');
?>
	</div>

    <div class="row">
		<?php 
echo $form->labelEx($model, 'parentaccounttypeid');
?>
		<?php 
echo $form->hiddenField($model, 'parentaccounttypeid');
?>
    <input type="text" name="parentaccounttypename" id="parentaccounttypename" readonly style="width:80%" value="
<?php 
echo Accounttype::model()->findByPk($model->parentaccounttypeid) !== null ? Accounttype::model()->findByPk($model->parentaccounttypeid)->accounttypename : '';
?>
">
    <?php 
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'parentaccounttype_dialog', 'options' => array('title' => Yii::t('app', 'Account Type'), 'width' => 'auto', 'autoOpen' => false, 'modal' => true)));
$this->widget('zii.widgets.grid.CGridView', array('id' => 'parentaccounttype-grid', 'dataProvider' => $parentaccounttype->searchwstatus(), 'filter' => $parentaccounttype, 'template' => '{summary}{pager}<br>{items}{pager}{summary}', 'columns' => array(array('header' => '', 'type' => 'raw', 'value' => 'CHtml::Button("+",
          array("name" => "send_absstatus",
          "id" => "send_absstatus",
          "onClick" => "$(\\"#parentaccounttype_dialog\\").dialog(\\"close\\");
          $(\\"#parentaccounttypename\\").val(\\"$data->accounttypename\\");
          $(\\"#Accounttype_parentaccounttypeid\\").val(\\"$data->accounttypeid\\");"))'), array('name' => 'accounttypeid', 'visible' => false, 'value' => '$data->accounttypeid', 'htmlOptions' => array('width' => '1%')), 'accounttypename', array('class' => 'CCheckBoxColumn', 'name' => 'recordstatus', 'selectableRows' => '0', 'header' => 'Record Status', 'checked' => '$data->recordstatus'))));
$this->endWidget('zii.widgets.jui.CJuiDialog');
echo CHtml::Button('...', array('onclick' => '$("#parentaccounttype_dialog").dialog("open"); return false;'));
?>
		<?php 
echo $form->error($model, 'parentaccountid');
 public function actionUpload()
 {
     parent::actionUpload();
     $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
     // folder for uploaded files
     $file = $folder . basename($_FILES['uploadfile']['name']);
     if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
         $row = 0;
         if (($handle = fopen($file, "r")) !== FALSE) {
             while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 if ($row > 0) {
                     $model = Account::model()->findByPk((int) $data[0]);
                     if ($model === null) {
                         $model = new Account();
                     }
                     $model->accountid = (int) $data[0];
                     $model->accountcode = $data[1];
                     $model->accountname = $data[2];
                     if ($data[3] != '') {
                         $model->parentaccountid = (int) $data[3];
                     } else {
                         $model->parentaccountid = null;
                     }
                     if ($data[4] != '') {
                         $accounttype = Accounttype::model()->findbysql("select * from accounttype where upper(accounttypename) = upper('" . $data[4] . "')");
                         if ($accounttype != null) {
                             $model->accounttypeid = $accounttype->accounttypeid;
                         } else {
                             $model->accounttypeid = null;
                         }
                     } else {
                         $model->accounttypeid = null;
                     }
                     if ($data[5] != '') {
                         $currency = Currency::model()->findbysql("select * from currency where upper(currencyname) = upper('" . $data[5] . "')");
                         if ($currency != null) {
                             $model->currencyid = $currency->currencyid;
                         } else {
                             $model->currencyid = null;
                         }
                     } else {
                         $model->currencyid = null;
                     }
                     $model->recordstatus = $data[6];
                     try {
                         if (!$model->save()) {
                             $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
                         }
                     } catch (Exception $e) {
                         $this->messages = $this->messages . $e->getMessage();
                     }
                 }
                 $row++;
             }
         } else {
             $this->messages = $this->messages . ' memory or harddisk full';
         }
         fclose($handle);
     } else {
         $this->messages = $this->messages . ' check your directory permission';
     }
     if ($this->messages == '') {
         $this->messages = 'success';
     }
     echo $this->messages;
 }