public function actionACProveedor()
 {
     if (isset($_GET['term'])) {
         $searchTerm = $_GET['term'];
         $result = array();
         $vehiculos = Proveedores::model()->findAll('nombre LIKE :nombre', array(':nombre' => '%' . $searchTerm . '%'));
         foreach ($vehiculos as $vehiculo) {
             $result[] = array('label' => $vehiculo->nombre, 'value' => $vehiculo->nombre, 'id' => $vehiculo->id);
         }
         echo CJSON::encode($result);
     }
 }
 /**
  * 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 = Proveedores::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemple #3
0
	<div class="row">
		<?php 
echo $form->label($model, 'idTipoVehiculo');
?>
		<?php 
echo $form->dropDownList($model, 'idTipoVehiculo', GxHtml::listDataEx(TiposVehiculos::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All')));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'idProveedor');
?>
		<?php 
echo $form->dropDownList($model, 'idProveedor', GxHtml::listDataEx(Proveedores::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All')));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'idMarca');
?>
		<?php 
echo $form->dropDownList($model, 'idMarca', GxHtml::listDataEx(MarcasVehiculos::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All')));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'idModelo');
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $modelProveedor = Proveedores::model()->findByPk($model->proveedor_id);
     $modelContacto = PersonasContacto::model()->findByAttributes(array('proveedor_id' => $model->proveedor_id));
     //$modelCuenta= ProveedoresCuentas::model()->findById($model->proveedor_id);
     //$modelObjeto= ProveedoresObjetos::model()->findById($model->proveedor_id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ProveedoresExtranjeros'])) {
         $model->attributes = $_POST['ProveedoresExtranjeros'];
         $modelProveedor->attributes = $_POST['Proveedores'];
         $modelContacto->attributes = $_POST['PersonasContacto'];
         $transaction = $model->dbConnection->beginTransaction();
         // Transaction begin //Yii::app()->db->beginTransaction
         try {
             $modelProveedor->nacional = false;
             if (!$modelProveedor->tiene_rif) {
                 $modelProveedor->rif = 'N/A';
             }
             //$modelProveedor->tiene_rif = $_POST['Proveedores']['tiene_rif'];
             $flag = $modelProveedor->save();
             if ($flag) {
                 $model->proveedor_id = $modelProveedor->id;
                 $modelContacto->proveedor_id = $modelProveedor->id;
                 $flag = $flag && $model->save();
                 $flag = $flag && $modelContacto->save();
             }
             if ($flag) {
                 $transaction->commit();
                 // committing
                 Yii::app()->user->setFlash('success', "Proveedor extranjero registrado con exito.");
                 $this->redirect(array('view', 'id' => $model->id));
             } else {
                 throw new Exception("Error Processing Request", 1);
             }
         } catch (Exception $e) {
             $transaction->rollBack();
             Yii::app()->user->setFlash('error', "No se pudo registrar el proveedor extranjero.");
             //return false;
         }
     }
     $this->render('update', array('model' => $model, 'modelProveedor' => $modelProveedor, 'modelContacto' => $modelContacto));
 }
Exemple #5
0
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', 'Administrar'));
$this->menu = array(array('label' => Yii::t('app', 'Listar') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Agregar') . ' ' . $model->label(), 'url' => array('create')));
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\$.fn.yiiGridView.update('registro-factura-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1><?php 
echo Yii::t('app', 'Administrar') . ' ' . GxHtml::encode($model->label(2));
?>
</h1>

<?php 
echo GxHtml::link(Yii::t('app', 'Busqueda Avanzada'), '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'registro-factura-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'emptyText' => 'No hay resultados', 'summaryText' => 'Mostrando del {start} al {end} de {count} resultado(s).', 'pager' => array('header' => '', 'prevPageLabel' => 'Anterior', 'nextPageLabel' => 'Siguiente'), 'columns' => array('nro_factura', array('name' => 'total_neto', 'value' => 'OrdenTrabajo::formatearPeso($data->total_neto)', 'htmlOptions' => array('style' => 'text-align: right;')), array('name' => 'total_bruto', 'value' => 'OrdenTrabajo::formatearPeso($data->total_bruto)', 'htmlOptions' => array('style' => 'text-align: right;')), array('name' => 'id_proveedor', 'value' => 'GxHtml::valueEx($data->idProveedor)', 'filter' => GxHtml::listDataEx(Proveedores::model()->findAllAttributes(null, true)), 'htmlOptions' => array('style' => 'text-align: center;')), 'fecha', array('class' => 'CButtonColumn', 'header' => 'Opciones', 'htmlOptions' => array('width' => 120), 'template' => '{view}{update}{delete}', 'buttons' => array('view' => array('label' => 'Ver', 'url' => 'Yii::app()->createUrl("registrofactura/view", array("id"=>$data->id))', 'imageUrl' => Yii::app()->baseUrl . '/images/ver.png'), 'update' => array('label' => 'Editar', 'url' => 'Yii::app()->createUrl("registrofactura/update", array("id"=>$data->id))', 'imageUrl' => Yii::app()->baseUrl . '/images/editar.png'), 'delete' => array('label' => 'Borrar', 'url' => 'Yii::app()->createUrl("registrofactura/delete", array("id"=>$data->id))', 'imageUrl' => Yii::app()->baseUrl . '/images/delete.png'))))));
Exemple #6
0
?>
		<?php 
echo $form->error($model, 'nro_factura');
?>
		</div><!-- row -->
		
		<div class="row">
		<?php 
echo $form->labelEx($model, 'id_proveedor');
?>
                <?php 
$criteria = new CDbCriteria();
$criteria->order = 'nombre ASC';
?>
		<?php 
echo $form->dropDownList($model, 'id_proveedor', GxHtml::listDataEx(Proveedores::model()->findAllAttributes(null, true, $criteria)));
?>
		<?php 
echo $form->error($model, 'id_proveedor');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'fecha');
?>
		<?php 
$form->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'language' => 'es', 'attribute' => 'fecha', 'value' => $model->fecha, 'options' => array('showButtonPanel' => true, 'changeYear' => true, 'dateFormat' => 'yy-mm-dd')));
?>
		<?php 
echo $form->error($model, 'fecha');
?>