Commit 05857ece authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

delete repaired

parent dfd8ef3b
......@@ -8,10 +8,11 @@ class DeleteAction extends CAction
echo Rest::json(['result' => false, "msg"=>Yii::t("common","Please Login First"),"icon"=>"fa-sign-in"]);
//check form et session exist
if($form = PHDB::findOne( Form::COLLECTION , array("_id"=>new MongoId(($id)))) )
if($form = PHDB::findOne( Form::COLLECTION , [ "_id"=>new MongoId($id) ] ) )
{
// if( Authorisation::isElementAdmin($id, Form::ANSWER_COLLECTION, Yii::app()->session["userId"], false)) {
//cascade delete all subforms
if(isset($form["subForms"]))
{
PHDB::remove( Form::ANSWER_COLLECTION, ["formId" => implode("|", $form["subForms"]) ]);
......@@ -19,6 +20,13 @@ class DeleteAction extends CAction
PHDB::remove( Form::COLLECTION, ["id" => $fid]);
}
}
if( $isSubForm = PHDB::find( Form::COLLECTION , [ "subForms"=>$form["id"] ] ) ){
foreach ($isSubForm as $fid => $f) {
PHDB::update( Form::COLLECTION, [ "_id" => new MongoId($fid) ],
['$pull' => [ "subForms" => $form["id"] ]]);
}
}
PHDB::remove( Form::COLLECTION, ["_id" => new MongoId($id)] );
echo Rest::json(['result' => true ]);
......
......@@ -459,7 +459,7 @@ jQuery(document).ready(function() {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
//location.href = location.origin+location.pathname+"/form/<?php echo $formId ?>";
location.reload();
urlCtrl.loadByHash(location.hash);
} );
}
......
......@@ -74,8 +74,11 @@ if( isset($form["subForms"]) && count($form["subForms"]) > 1 ) {
echo '<a onclick="'.$l.'" href="javascript:;" '.$d.' >';
echo '<div class="stepNumber">'.$lbl.'</div>';
echo '<span class="stepDesc">'.$n.'</span></a>';
echo '<div class="stepNumber">'.$lbl.'</div>';
echo '<span class="stepDesc">'.$n.'</span></a>';
echo '<a href="javascript:;" class="editFormBtn" data-id="'.$forms[$v]["_id"].'" data-formid="'.$v.'" ><i class="fa fa-pencil text-dark"></i></a> ';
echo '<a href="javascript:;" class="deleteFormBtn" data-id="'.$forms[$v]["_id"].'" data-formid="'.$v.'" ><i class="fa fa-trash text-red"></i></a> ' ;
echo "</li>";
}
?>
......@@ -116,12 +119,7 @@ if( isset($form["subForms"]) && count($form["subForms"]) > 1 ) {
if( !empty($forms[$v]) )
{
echo '<h1 class="text-center" style="color:'.$color1.'" >'.@$forms[$v]["name"].'</h1>';
echo "<div class='text-center col-xs-12'>";
echo '<a href="javascript:;" class="editFormBtn" data-id="'.$forms[$v]["_id"].'" data-formid="'.$v.'" ><i class="fa fa-pencil text-dark"></i></a> ';
echo '<a href="javascript:;" class="deleteFormBtn" data-id="'.$forms[$v]["_id"].'" data-formid="'.$v.'" ><i class="fa fa-trash text-red"></i></a> ' ;
echo "</div>";
//echo "<div class='markdown'>";
echo "<div class=''>";
......@@ -207,7 +205,7 @@ jQuery(document).ready(function() {
toastr.success("Le form été supprimée avec succès");
else
toastr.error(res.msg);
//urlCtrl.loadByHash(location.hash);
urlCtrl.loadByHash(location.hash);
},"html");
}
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment