Viewing file: clientes_crud_view.php (6.16 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<div class="content-wrapper" style="min-height: 946px;"> <div style="margin-left:20px;"> <div ng-app="app" ng-controller="EditableRowCtrl"> <section class="content-header"> <h1>CLIENTES</h1> <br> <br> <form class="form-inline"> <div class="form-group"> <label >BUSQUEDA:</label> <input type="text" style="width: 300px;height: 30px;" ng-model="search" class="form-control" placeholder="BUSCAR CLIENTE"> <button type="button" class="btn btn-default" ng-click="addClient()">AGREGAR CLIENTE</button> </div> </form> </section> <!-- Main content --> <section class="content"> <table class="table table-bordered table-hover table-condensed"> <tr style="font-weight: bold"> <td style="width:15%">RAZON SOCIAL</td> <td style="width:10%">CUIT</td> <td style="width:10%">PROVINCIA</td> <td style="width:10%">CORREO</td> <td style="width:15%">TELEFONO</td> <td style="width:30%">DIRECCION</td> <td style="width:10%">EXPRESO</td> <td style="width:15%">ACCION</td> </tr> <tr ng-repeat="lista in list | startFrom:(currentPage-1)*10 | limitTo:10 | filter:search"> <td> <!-- editable username (text with validation) --> <span editable-text="lista.business_name" e-name="business_name" e-form="rowform" e-required> {{ lista.business_name || 'empty' }} </span> </td> <td> <!-- editable username (text with validation) --> <span editable-text="lista.cuit" e-name="cuit" e-form="rowform" e-required> {{ lista.cuit || 'empty' }} </span> </td> <td> <!-- editable username (text with validation) --> <span editable-text="lista.province" e-name="province" e-form="rowform" e-required> {{ lista.province || 'empty' }} </span> </td> <td> <!-- editable status (select-local) --> <span editable-text="lista.mail" e-name="correo" e-form="rowform" e-required> {{ lista.mail || 'empty' }} </span> </td> <td> <!-- editable status (select-local) --> <span editable-text="lista.telephone" e-name="telephone" e-form="rowform" e-required> {{ lista.telephone || 'empty' }} </span> </td> <td> <!-- editable status (select-local) --> <span editable-text="lista.address" e-name="address" e-form="rowform" e-required> {{ lista.address || 'empty' }} </span> </td> <td> <!-- editable status (select-local) --> <span editable-text="lista.expresso" e-name="expresso" e-form="rowform" e-required> {{ lista.expresso || 'empty' }} </span> </td> <td style="white-space: nowrap"> <!-- form --> <form editable-form name="rowform" onbeforesave="saveUser($data, lista.nombre)" ng-show="rowform.$visible" class="form-buttons form-inline" shown="inserted == lista"> <button type="submit" ng-disabled="rowform.$waiting" class="btn btn-primary"> save </button> <button type="button" ng-disabled="rowform.$waiting" ng-click="rowform.$cancel()" class="btn btn-default"> cancel </button> </form> <div class="buttons" ng-show="!rowform.$visible"> <button type="button" class="btn btn-primary" ng-click="rowform.$show()">edit</button> <button type="button" class="btn btn-danger" ng-click="removeUser($index)">del</button> </div> </td> </tr> </table> <pagination boundary-links="true" num-pages="noOfPages" total-items="totalItems" page="currentPage" items-per-page="10" class="pagination-sm nomargin" previous-text="‹" next-text="›" first-text="«" last-text="»"></pagination> </div> </section><!-- /.content --> </div><!-- /.content-wrapper --> <script language="Javascript"> var app = angular.module("app", ["xeditable","ui.bootstrap"]); app.run(function(editableOptions) { editableOptions.theme = 'bs3'; }); //filtering shown units app.filter('startFrom', function() { return function(input, start) { start = +start; //parse to int return input.slice(start); } }); app.controller('EditableRowCtrl', function($scope, $filter, $http) { $scope.list = []; $http.get("<?php echo site_url("webService/getClientes");?>").success(function(data){ $scope.list = data; $scope.filteredItems = $scope.list.length; //Initially for no filter $scope.totalItems = $scope.list.length; }); $scope.checkName = function(data, id) { if (id === 2 && data !== 'awesome') { return "Username 2 should be `awesome`"; } }; $scope.saveUser = function(data, id) { //$scope.user not updated yet angular.extend(data, {id: id}); return $http.post('/saveUser', data); }; // remove user $scope.removeUser = function(index) { $scope.users.splice(index, 1); $scope.totalItems = $scope.users.length; }; // add user $scope.addProducto = function() { $scope.inserted = { descripcion:'', nombre: '', id_estado: null, precio: null, numero:null }; // counting modulo of users.length with pagesize which is 4 var pagecount = $scope.list.length % 20; if (pagecount >= 19) // if 3 which is before new page add new page $scope.noOfPages++; $scope.list.unshift($scope.inserted); $scope.totalItems = $scope.list.length; }; //pagination at initialization $scope.totalItems = $scope.list.length; $scope.currentPage = 1; // set page click $scope.setPage = function(pageNo) { $scope.currentPage = pageNo; }; }); </script>
|