This commit is contained in:
Martin Müller 2014-03-29 21:09:17 +01:00
parent 675bc39bf0
commit adf05c8a06
5 changed files with 74 additions and 17 deletions

View File

@ -34,7 +34,5 @@ class AppController extends Controller {
public $components = array('Security','MiconwareSession');
function beforeFilter(){
parent::beforeFilter();
}
}

View File

@ -21,6 +21,13 @@ class UserController extends AppController {
* @throws NotFoundException When the view file could not be found
* or MissingViewException in debug mode.
*/
function beforeFilter(){
$this->Security->unlockedActions[]="settings_isearch";
/*if($this->request->action=="settings_isearch")
$this->Security->=false;*/
parent::beforeFilter();
}
public function profil() {
$this->MiconwareSession->init($this);
@ -412,11 +419,13 @@ class UserController extends AppController {
$this->render('/Home/error');
}else{
if($this->request->is('post')){
$tosave = array();
$tosave['DreamjobISerach'] = $this->data['DreamjobISerach'];
var_dump($tosave);
$result = $this->DreamjobISearch->saveMany($tosave);
$tosave = $this->request->data['DreamjobISearch'];
foreach($tosave as $i => $a)
$tosave[$i]['worker_id']=$profil['AppUser']['id'];
$result = $this->DreamjobISearch->saveAndDelete($tosave,$profil['DreamjobISearch']);
if($result){
$this->MiconwareSession->refreshCache();
$profil = $this->MiconwareSession->getWorker();
$this->MiconwareSession->setFlash('dreamjob.settings.save','flash',array('alert'=>'success'));
}else{
$this->MiconwareSession->setFlash('dreamjob.settings.save.error','flash',array('alert'=>'danger'));

View File

@ -34,6 +34,33 @@ class DreamjobISearch extends AppModel {
*
* @var array
*/
public function saveAndDelete($data,$old){
$dataSource = $this->getDataSource();
$dataSource->begin();
$result = $this->saveMany($data);
if($result){
$array1 = array();
$array2 = array();
foreach($data as $a)
if(isset($a['id']))
$array1[]=$a['id'];
foreach($old as $a)
if(isset($a['id']))
$array2[]=$a['id'];
$diff=array_diff($array2, $array1);
if(count($diff)>0)
$result = $this->delete($diff);
}
if ($result) {
$dataSource->commit();
return true;
} else {
$dataSource->rollback();
}
return false;
}
public $validate = array(
'worker_id' => array(
'numeric' => array(

View File

@ -52,16 +52,12 @@
that = this;
newRow = $(".new").html();
$(this).change(function(){
tosave = true;
$("tr",that).each(function(){
see = true;
save = true;
$("select",this).each(function(){
if(see)
see = $(this).val()=='';
if(save){
save = $(this).val()!='';
console.log($(this).val()!='');
}
});
if(see && $(this).attr("data")=="set"){
$(this).attr("data","");
@ -73,9 +69,20 @@
$(that).append("<tr class=\"new\">"+newRow+"</tr>");
evet();
}
if(save && !$("tr",that).hasClass("new"))
saveForm();
save = true;
that2=this;
$("select",this).each(function(){
if(save && !$(that2).hasClass("new")){
save = $(this).val()!='';
}
});
if(tosave && !$(that2).hasClass("new")){
tosave = save;
}
});
if(tosave)
saveForm();
});
//ZUOFT WIRD GESPEICHERT
@ -90,8 +97,16 @@
}
evet();
function saveForm(){
load($(this).attr("action"),{data:$(this).serialize(), type:'GET'},false);
console.log("save");
i = 0;
$("tr.new",that).remove();
$("tr",that).each(function(){
$("select,input",this).each(function(){
str = $(this).attr("name").replace(/data\[(.*)\]\[.*\]\[(.*)\]/g,'data[$1]['+i+'][$2]');
$(this).attr("name",str);
});
i++;
});
load($(that).attr("action"),{data:$(that).parents("form").serialize(), type:'POST'},false);
}
});
$(where+" form.hide-form").each(function(evt){

View File

@ -47,6 +47,14 @@ ALTER TABLE `mic_dj_jobs_opening_worker`
ALTER TABLE `mic_dj_account_cmpy` CHANGE `branch` `branch_id` INT(11) NOT NULL;
ALTER TABLE `mic_dj_jobs_opening` CHANGE `branch` `branch_id` INT(11) NOT NULL;
-- LOLA
ALTER TABLE `ic_dj_account_isearch` CHANGE `branch` `branch_id` INT(11) NOT NULL;
update `mic_dj_account_isearch` left join `mic_dj_list_job` on `name`=`job` set `job`=`mic_dj_list_job`.`id`
update `mic_dj_account_isearch` left join `mic_dj_list_branch` on `name`=`branch` set `job`=`mic_dj_list_branch`.`id`
ALTER TABLE `mic_dj_account_isearch` CHANGE `branch` `branch_id` INT(11) NOT NULL;
ALTER TABLE `mic_dj_account_isearch` CHANGE `job` `job_id` INT(11) NOT NULL;
ALTER TABLE `mic_dj_account_isearch`
ADD CONSTRAINT `mic_dj_account_isearch_branch` FOREIGN KEY (`branch_id`) REFERENCES `mic_dj_list_branch` (`id`),
ADD CONSTRAINT `mic_dj_account_isearch_job` FOREIGN KEY (`job_id`) REFERENCES `mic_dj_list_job` (`id`);