From 4b2d54de1e25dc63394eae9b8fcc3394a2646b5c Mon Sep 17 00:00:00 2001 From: Sergio Casizzone Date: Tue, 7 Apr 2020 11:24:10 +0200 Subject: [PATCH 1/2] issue #21, #23, #22, #24 --- css/wallet.css | 37 ++++++++++++++ protected/components/Controller.php | 21 ++++++-- protected/controllers/ConsegneController.php | 44 +++++++++------- protected/controllers/UsersController.php | 37 ++++++++++++-- protected/models/ConsegneMan.php | 8 +-- protected/views/consegne/_form.php | 4 -- protected/views/consegne/index.php | 6 ++- protected/views/consegne/manage.php | 31 ++++++++---- protected/views/consegne/select.php | 18 ++++--- protected/views/consegne/view.php | 36 +++++++------ protected/views/users/_formpwd.php | 53 ++++++++++++++++++++ protected/views/users/changepwd.php | 22 ++++++++ protected/views/users/view.php | 12 ++--- 13 files changed, 254 insertions(+), 75 deletions(-) create mode 100644 protected/views/users/_formpwd.php create mode 100644 protected/views/users/changepwd.php diff --git a/css/wallet.css b/css/wallet.css index 318c32d..c8b1ea3 100755 --- a/css/wallet.css +++ b/css/wallet.css @@ -399,3 +399,40 @@ h1 small.logo-descri { #consegne-grid-gestore a:selected { color: blue; } + +a.tipaddress { + /* border-bottom: 1px dashed; */ + text-decoration: none + + +} +a.tipaddress:hover { + cursor: help; + position: relative +} +a.tipaddress span { + display: none +} +a.tipaddress:hover span { + padding: 5px 20px 5px 20px; + display: block; + z-index: 100; + + left: -100px; + margin: 10px; + width: 250px; + position: absolute; + top: -50px; + text-decoration: none + + + border: 1px solid darkblue; + background: #666; + color: yellow; + + -moz-border-radius:6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius:6px; + +} diff --git a/protected/components/Controller.php b/protected/components/Controller.php index 0060f90..ae1599e 100755 --- a/protected/components/Controller.php +++ b/protected/components/Controller.php @@ -22,9 +22,24 @@ class Controller extends CController public $breadcrumbs=array(); + /** + * Questa funzione ha lo scopo di mascherare l'indirizzo, ma di mostrarlo su + * richiesta (click) + * @var string $address è la stringa indirizzo da celare + * @var number $id è l'id della row da richiamare in caso di click + * @var number $tag è l'operazione richiesta + */ + public function maskAddress($address,$id,$tag=0) + { + $link = Yii::app()->createUrl( + "consegne/view", + ["id"=>crypt::Encrypt($id),"tag"=>$tag] + ); - - - + $return = CHtml::link('******'.$address.'',$link,[ + 'class'=>'tipaddress' + ]); + return $return; + } } diff --git a/protected/controllers/ConsegneController.php b/protected/controllers/ConsegneController.php index ce0603c..aa15a41 100755 --- a/protected/controllers/ConsegneController.php +++ b/protected/controllers/ConsegneController.php @@ -443,11 +443,12 @@ public function actionExport() ->setCategory($Category); // Add header - $colonne = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q'); + $colonne = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u'); $intestazione = array( "ID", "Data Inserimento", "ID User che inserisce", + "Nome User che inserisce", "Codice Fiscale", "Nome", "Cognome", @@ -455,8 +456,11 @@ public function actionExport() "Adulti", "Neonati", "Indirizzo", + "Quartiere", + "Municipalità", "Alert se < 7gg", - "ID Volontario in consegna", + "ID User in consegna", + "Nome User in consegna", "Pacco in consegna", "Data presa in carico", "Consegnato", @@ -475,23 +479,27 @@ public function actionExport() foreach($transactions as $item) { // Miscellaneous glyphs, UTF-8 $objPHPExcel->setActiveSheetIndex(0) - ->setCellValue('A'.$riga, $item->id_archive) - ->setCellValue('B'.$riga, date("d/m/Y",$item->data)) + ->setCellValue('A'.$riga, $item->id_archive) + ->setCellValue('B'.$riga, date("d/m/Y",$item->data)) ->setCellValue('C'.$riga, $item->id_user) - ->setCellValue('D'.$riga, $item->codfisc) - ->setCellValue('E'.$riga, $item->nome) - ->setCellValue('F'.$riga, $item->cognome) - ->setCellValue('G'.$riga, $item->telefono) - ->setCellValue('H'.$riga, $item->adulti) - ->setCellValue('I'.$riga, $item->bambini) - ->setCellValue('J'.$riga, $item->indirizzo) - ->setCellValue('K'.$riga, $item->trigger_alert) - ->setCellValue('L'.$riga, $item->id_volontario) - ->setCellValue('M'.$riga, $item->in_consegna) - ->setCellValue('N'.$riga, ($item->time_inconsegna == 0) ? '' : date("d/m/Y H:i:s",$item->time_inconsegna)) - ->setCellValue('O'.$riga, $item->consegnato) - ->setCellValue('P'.$riga, ($item->time_consegnato == 0) ? '' : date("d/m/Y H:i:s",$item->time_consegnato)) - ->setCellValue('Q'.$riga, $item->note); + ->setCellValue('D'.$riga, Users::model()->findByPk($item->id_user)->email) + ->setCellValue('E'.$riga, $item->codfisc) + ->setCellValue('F'.$riga, $item->nome) + ->setCellValue('G'.$riga, $item->cognome) + ->setCellValue('H'.$riga, $item->telefono) + ->setCellValue('I'.$riga, $item->adulti) + ->setCellValue('J'.$riga, $item->bambini) + ->setCellValue('K'.$riga, $item->indirizzo) + ->setCellValue('L'.$riga, $item->quartiere) + ->setCellValue('M'.$riga, $item->municipalita) + ->setCellValue('N'.$riga, $item->trigger_alert) + ->setCellValue('O'.$riga, $item->id_volontario) + ->setCellValue('P'.$riga, ($item->id_volontario == 0) ? '' : Users::model()->findByPk($item->id_volontario)->email) + ->setCellValue('Q'.$riga, $item->in_consegna) + ->setCellValue('R'.$riga, ($item->time_inconsegna == 0) ? '' : date("d/m/Y H:i:s",$item->time_inconsegna)) + ->setCellValue('S'.$riga, $item->consegnato) + ->setCellValue('T'.$riga, ($item->time_consegnato == 0) ? '' : date("d/m/Y H:i:s",$item->time_consegnato)) + ->setCellValue('U'.$riga, $item->note); $riga++; $Rows++; diff --git a/protected/controllers/UsersController.php b/protected/controllers/UsersController.php index dbb7583..7161d2b 100755 --- a/protected/controllers/UsersController.php +++ b/protected/controllers/UsersController.php @@ -36,11 +36,12 @@ public function accessRules() return array( array('allow', // allow authenticated user to perform 'create' and 'update' actions 'actions'=>array( - 'index', // mostra elenco soci - 'view', //visualizza dettagli socio - 'create', //crea manualmente un socio - 'update', //modifica socio - 'disable', //disattiva socio + 'index', // mostra elenco operatore + 'view', //visualizza dettagli operatore + 'create', //crea manualmente un operatore + 'update', //modifica operatore + 'disable', //disattiva operatore + 'changepwd', // cambia la password ), 'users'=>array('@'), ), @@ -93,6 +94,32 @@ public function actionCreate() )); } + /** + * 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 actionChangepwd($id) + { + $model=$this->loadModel(crypt::Decrypt($id)); + #echo "
".print_r($_POST,true)."
"; + #exit; + + if(isset($_POST['Users'])) + { + $model->attributes=$_POST['Users']; + $model->password = CPasswordHelper::hashPassword($model->password); + + if($model->save()){ + $this->redirect(array('view','id'=>crypt::Encrypt($model->id_user))); + } + } + + $this->render('changepwd',array( + 'model'=>$model, + )); + } + /** * Updates a particular model. diff --git a/protected/models/ConsegneMan.php b/protected/models/ConsegneMan.php index a4aa764..d999f15 100644 --- a/protected/models/ConsegneMan.php +++ b/protected/models/ConsegneMan.php @@ -115,13 +115,13 @@ public function search() $criteria=new CDbCriteria; - $criteria->compare('id_archive',$this->id_archive); - $criteria->compare('id_user',$this->id_user); + //$criteria->compare('id_archive',$this->id_archive); + //$criteria->compare('id_user',$this->id_user); $criteria->compare('codfisc',$this->codfisc,true); $criteria->compare('nome',$this->nome,true); $criteria->compare('cognome',$this->cognome,true); $criteria->compare('telefono',$this->telefono,true); - $criteria->compare('data',$this->data); + //$criteria->compare('data',$this->data); $criteria->compare('adulti',$this->adulti); $criteria->compare('bambini',$this->bambini); $criteria->compare('indirizzo',$this->indirizzo,true); @@ -160,7 +160,7 @@ public function search() 'criteria'=>$criteria, 'sort'=>array( 'defaultOrder'=>array( - 'id_archive'=>false, + 'id_archive'=>true, ) ), 'pagination' => array( diff --git a/protected/views/consegne/_form.php b/protected/views/consegne/_form.php index 048bc66..8118cae 100755 --- a/protected/views/consegne/_form.php +++ b/protected/views/consegne/_form.php @@ -82,10 +82,6 @@ hiddenField($model,'trigger_alert',array('value'=>0)); ?> - - - -
isNewRecord ? 'Inserisci' : 'Modifica'), array('class' => 'btn btn-primary')); ?>
diff --git a/protected/views/consegne/index.php b/protected/views/consegne/index.php index 37578b3..8e26061 100755 --- a/protected/views/consegne/index.php +++ b/protected/views/consegne/index.php @@ -60,7 +60,8 @@ array( 'name'=>'Indirizzo', 'type'=>'raw', - 'value'=>'CHtml::link($data->indirizzo,Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive),"tag"=>2]) )', + //'value'=>'CHtml::link($data->indirizzo,Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive),"tag"=>2]) )', + 'value'=> 'Yii::app()->controller->maskAddress($data->indirizzo,$data->id_archive,2)', ), array( 'name' => '', @@ -122,7 +123,8 @@ array( 'name'=>'Indirizzo', 'type'=>'raw', - 'value'=>'CHtml::link($data->indirizzo,Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive),"tag"=>1]) )', + //'value'=>'CHtml::link($data->indirizzo,Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive),"tag"=>1]) )', + 'value'=> 'Yii::app()->controller->maskAddress($data->indirizzo,$data->id_archive,1)', ), array( 'name' => '', diff --git a/protected/views/consegne/manage.php b/protected/views/consegne/manage.php index 4a97096..0769afa 100644 --- a/protected/views/consegne/manage.php +++ b/protected/views/consegne/manage.php @@ -43,15 +43,24 @@ 1 => '', // in consegna 2 => '', // in carico 3 => '', // tutti - ]; $activeButton[0] = 'active'; -if (isset($_GET['typelist'])) - $activeButton[$_GET['typelist']] = 'active'; +$get = 0; +if (isset($_GET['typelist'])){ + $get = $_GET['typelist']; + $activeButton[$get] = 'active'; +} + +$tag = [ + 0 => 3, + 1 => 1, + 2 => 2, + 3 => 0 +]; ?>
@@ -84,6 +93,15 @@ // 'class'=>'CCheckBoxColumn', // 'htmlOptions'=>array('style'=>'padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;vertical-align:middle;'), // ), + array( + + 'name'=>Yii::t('lang','data'), + 'type'=>'raw', + 'value' => 'CHtml::link(date("d/M/Y",$data->data), Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive),"tag"=>'.$tag[$get].']) )', + 'htmlOptions'=>array('style'=>'vertical-align:middle;'), + 'filter'=>false, + ), + array( 'name'=>'id_volontario', 'type'=>'raw', @@ -93,14 +111,7 @@ }) ), - array( - 'name'=>Yii::t('lang','data'), - 'type'=>'raw', - 'value' => 'CHtml::link(date("d/M/Y",$data->data), Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive)]) )', - 'htmlOptions'=>array('style'=>'vertical-align:middle;'), - 'filter'=>false, - ), 'quartiere', 'municipalita', 'indirizzo', diff --git a/protected/views/consegne/select.php b/protected/views/consegne/select.php index 08ffaf7..6e5018a 100755 --- a/protected/views/consegne/select.php +++ b/protected/views/consegne/select.php @@ -59,14 +59,18 @@ array( 'name'=>'indirizzo', 'type'=>'raw', - 'value'=>'CHtml::link($data->indirizzo,Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive),"tag"=>1]) )', + //'value'=>'CHtml::link($data->indirizzo,Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive),"tag"=>1]) )', + 'value'=> 'Yii::app()->controller->maskAddress($data->indirizzo,$data->id_archive,1)', ), - array( - 'name'=>'codfisc', - 'type' => 'raw', - 'value'=>'CHtml::link($data->codfisc,Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive)]) )', - 'htmlOptions'=>array('style'=>'vertical-align:middle;'), - ), + // array( + // 'name'=>'codfisc', + // 'type' => 'raw', + // 'value'=>'CHtml::link($data->codfisc,Yii::app()->createUrl("consegne/view",["id"=>crypt::Encrypt($data->id_archive)]) )', + // 'htmlOptions'=>array('style'=>'vertical-align:middle;'), + // ), + array( + 'value'=>'', + ), ) )); ?> diff --git a/protected/views/consegne/view.php b/protected/views/consegne/view.php index c3e41fc..2f9cd41 100755 --- a/protected/views/consegne/view.php +++ b/protected/views/consegne/view.php @@ -47,6 +47,10 @@ 'note', 'adulti', 'bambini', + array( + 'label'=>'Data consegna', + 'value'=>date("d/m/Y",$model->time_consegnato), + ), ), )); ?> @@ -57,22 +61,24 @@

- - - - - - - + + + + + + + + + - - - - id_volontario == 0 && $tag <>2){ ?> - - - - + + + + id_volontario == 0 && $tag <>2){ ?> + + + +

diff --git a/protected/views/users/_formpwd.php b/protected/views/users/_formpwd.php new file mode 100644 index 0000000..ce7bd87 --- /dev/null +++ b/protected/views/users/_formpwd.php @@ -0,0 +1,53 @@ +'Volontario',20=>'Gestore']; + +?> + +
+beginWidget('CActiveForm', array( + 'id'=>'users-form', + 'enableAjaxValidation'=>false, +)); ?> + + + +
+ labelEx($model,'Seleziona tipo utente'); ?> + dropDownList($model,'type',$type,array('class'=>'form-control','disabled'=>'disabled')); ?> +
+ +
+ labelEx($model,'email'); ?> + textField($model,'email',array('size'=>100,'readonly'=>!$model->isNewRecord,'class'=>'form-control')); ?> +
+ +
+ labelEx($model,'name'); ?> + textField($model,'name',array('size'=>60,'readonly'=>!$model->isNewRecord,'maxlength'=>250,'class'=>'form-control')); ?> +
+ +
+ labelEx($model,'surname'); ?> + textField($model,'surname',array('size'=>60,'readonly'=>!$model->isNewRecord,'maxlength'=>250,'class'=>'form-control')); ?> +
+ + +
+ password = ''; ?> + labelEx($model,'Nuova password'); ?> + textField($model,'password',array('size'=>60,'maxlength'=>250,'class'=>'form-control')); ?> + error($model,'password',array('class'=>'alert alert-danger')); ?> +
+ + + hiddenField($model,'status_activation_code'); ?> + + +
+ isNewRecord ? 'Inserisci' : 'Salva'), array('class' => 'btn btn-primary')); ?> +
+ + +endWidget(); ?> + +
diff --git a/protected/views/users/changepwd.php b/protected/views/users/changepwd.php new file mode 100644 index 0000000..b5fbbf9 --- /dev/null +++ b/protected/views/users/changepwd.php @@ -0,0 +1,22 @@ + +
+
+
+
+
+
+

Modifica Password operatore

+
+
+ renderPartial('_formpwd', array('model'=>$model)); ?> +
+
+
+
+ +
+
diff --git a/protected/views/users/view.php b/protected/views/users/view.php index 04ed73c..469becc 100755 --- a/protected/views/users/view.php +++ b/protected/views/users/view.php @@ -4,7 +4,8 @@ $idUserCrypted = crypt::Encrypt($model->id_user); $modifyURL = Yii::app()->createUrl('users/update').'&id='.$idUserCrypted; -$deleteURL = Yii::app()->createUrl('users/delete').'&id='.$idUserCrypted; +$pwdchangeURL = Yii::app()->createUrl('users/changepwd').'&id='.$idUserCrypted; +$deleteURL = Yii::app()->createUrl('users/disable').'&id='.$idUserCrypted; ?>
@@ -26,12 +27,6 @@ 'surname', 'name', 'email', - - - - - - ), )); ?> @@ -43,6 +38,9 @@ + + +
From f50cfa3c95c50e3a0a9bcc491fb76dd6e210707b Mon Sep 17 00:00:00 2001 From: Sergio Casizzone Date: Tue, 7 Apr 2020 11:42:40 +0200 Subject: [PATCH 2/2] users fix --- protected/controllers/UsersController.php | 8 ++++++++ protected/views/users/index.php | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/protected/controllers/UsersController.php b/protected/controllers/UsersController.php index 7161d2b..ad29946 100755 --- a/protected/controllers/UsersController.php +++ b/protected/controllers/UsersController.php @@ -63,6 +63,14 @@ public function actionView($id) )); } + public function actionDisable($id) + { + $user = $this->loadModel(crypt::Decrypt($id)); + $user->status_activation_code = 0; + $user->update(); + $this->redirect(array('index')); + } + /** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. diff --git a/protected/views/users/index.php b/protected/views/users/index.php index 3a788a3..56b4e7e 100755 --- a/protected/views/users/index.php +++ b/protected/views/users/index.php @@ -31,26 +31,26 @@ function type($type){
widget('zii.widgets.grid.CGridView', array( - 'id'=>'soci-grid', - 'htmlOptions' => array('class' => 'table table-wallet '), - 'dataProvider'=>$dataProvider, - 'id'=>'users-grid', - 'enablePagination' => true, + 'id'=>'soci-grid', + 'htmlOptions' => array('class' => 'table table-wallet '), + 'dataProvider'=>$dataProvider, + 'id'=>'users-grid', + 'enablePagination' => true, 'columns' => array( array( 'type'=> 'raw', 'name'=>'name', 'header'=>'Nome', - 'value' => 'CHtml::link(CHtml::encode(strtoupper(Users::model()->findByPk($data->id_user)->surname).chr(32).Users::model()->findByPk($data->id_user)->name), Yii::app()->createUrl("users/view")."&id=".CHtml::encode(crypt::Encrypt($data->id_user)))', - 'filter' => CHtml::listData(Users::model()->findAll(array('order'=>'surname ASC, name ASC')), 'surname', function($items) { - return $items->surname.' '.$items->name; - }) + 'value' => '($data->status_activation_code == 0) ? strtoupper(Users::model()->findByPk($data->id_user)->surname).chr(32).Users::model()->findByPk($data->id_user)->name : CHtml::link(CHtml::encode(strtoupper(Users::model()->findByPk($data->id_user)->surname).chr(32).Users::model()->findByPk($data->id_user)->name), Yii::app()->createUrl("users/view")."&id=".CHtml::encode(crypt::Encrypt($data->id_user)))', + 'filter' => CHtml::listData(Users::model()->findAll(array('order'=>'surname ASC, name ASC')), 'surname', function($items) { + return $items->surname.' '.$items->name; + }) ), array( 'name'=>'email', 'type'=>'raw', - 'value' => 'CHtml::link(CHtml::encode($data->email), Yii::app()->createUrl("users/view")."&id=".CHtml::encode(crypt::Encrypt($data->id_user)))', + 'value' => '($data->status_activation_code == 0) ? CHtml::encode($data->email) : CHtml::link(CHtml::encode($data->email), Yii::app()->createUrl("users/view")."&id=".CHtml::encode(crypt::Encrypt($data->id_user)))', ),