Commit 9678c3d3 authored by Clément Damiens's avatar Clément Damiens
Browse files

save order with items

parent f7a8da82
......@@ -2547,9 +2547,9 @@ var list = {
$("#listList").append(viewList);
});
if(action=="history"){
$(".orderComment").click(function(){
order=listElement["orders"][$(this).data("id")];
commentRating(order, $(this).data("action"));
$(".orderItemComment").click(function(){
orderItem=listElement["orderItems"][$(this).data("id")];
commentRating(orderItem, $(this).data("action"));
});
}
},
......@@ -2564,7 +2564,7 @@ var list = {
btnAction="show";
labelAction="Show your comment";
}
btnAction="<a href='javascript:;' class='btn bg-green orderComment linkBtnList' data-id='"+data._id.$id+"' data-action='"+btnAction+"'>"+labelAction+"</a>";
btnAction="<a href='javascript:;' class='btn bg-green orderItemComment linkBtnList' data-id='"+data._id.$id+"' data-action='"+btnAction+"'>"+labelAction+"</a>";
}
if(!data.useMinSize)
data.imgProfil = "<i class='fa fa-image fa-3x'></i>";
......
......@@ -435,6 +435,9 @@ class CommunecterController extends Controller
"updatefield" => array( "href" => "/ph/co2/comment/updatefield"),
"countcommentsfrom" => array( "href" => "/ph/co2/comment/countcommentsfrom"),
),
"order"=> array(
"save" => array("href" => "/ph/co2/order/save"),
),
"action"=> array(
"addaction" => array("href" => "/ph/co2/action/addaction"),
),
......
<?php
/**
* CommentController.php
*
* @author: Sylvain Barbot
* Date: 2/7/15
* Time: 12:25 AM
*/
class OrderController extends CommunecterController {
protected function beforeAction($action) {
parent::initPage();
return parent::beforeAction($action);
}
public function actions()
{
return array(
//'index' => 'citizenToolKit.controllers.comment.IndexAction',
'save' => 'citizenToolKit.controllers.order.SaveAction',
/*'abuseprocess' => 'citizenToolKit.controllers.comment.AbuseProcessAction',
'moderate' => 'citizenToolKit.controllers.comment.ModerateAction',
'countcommentsfrom' => 'citizenToolKit.controllers.comment.CountCommentsAction',
'delete' => 'citizenToolKit.controllers.comment.DeleteAction',
'updatefield' => 'citizenToolKit.controllers.comment.UpdateFieldAction',*/
);
}
public function actionTestPod() {
$params = array();
$this->render( "testpod" , $params );
}
}
\ No newline at end of file
......@@ -174,7 +174,7 @@
}
function loadHistory(){
initBtnDash("#btn-history");
data={category:["orders"],actionType:"history"};
data={category:["orderItems"],actionType:"history"};
var url = "element/list/type/"+contextData.type+"/id/"+contextData.id;
showLoader('.content-view-dashboard');
ajaxPost('.content-view-dashboard', baseUrl+'/'+moduleId+'/'+url, data, function(){},"html");
......
......@@ -109,7 +109,7 @@
"</div>"+
"</div>";
str+="<div class='col-md-12 pull-right btn-cart margin-top-20'>"+
"<a href='javascript:alert(\"Mangolitooooo Oceatoon\")' class='btn bg-orange text-white pull-right col-md-3' onclick=''>Validate</a>"+
"<a href='javascript:;' onclick='buyCart();' class='btn bg-orange text-white pull-right col-md-3' onclick=''>Validate</a>"+
"<a href='javascript:;' class='btn bg-orange pull-right col-md-3 text-white close-modal' >Continue</a>"+
"</div>";
str+="<div class='col-md-12 margin-top-10 text-left'>"+
......@@ -313,4 +313,56 @@
}
});
}
function buyCart(){
order=new Object;
orderItem=new Object;
order.totalPrice=totalCart;
order.currency="EUR";
$.each(shoppingCart,function(e,v){
if(e=="countQuantity")
order.countOrderItem=v;
else if(e=="services"){
$.each(v, function(cat, listByCat){
$.each(listByCat, function(key, data){
orderItem[key]=new Object;
orderItem[key].orderedItemType=e;
orderItem[key].quantity=data.countQuantity;
orderItem[key].price=(data.price*data.countQuantity);
orderItem[key].reservations=data.reservations;
});
});
}else if(e=="products"){
$.each(v, function(key, data){
orderItem[key]=new Object;
orderItem[key].orderedItemType=e;
orderItem[key].quantity=data.countQuantity;
orderItem[key].price=(data.price*data.countQuantity);
});
}
});
order.orderItems=orderItem;
bootbox.prompt({
title: "Give a name to your command:",
value : "Cart of "+moment(new Date()).format('DD-MM-YYYY HH:MM'),
callback : function(result){
order.name=result;
$.ajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/order/save",
data: order,
success: function(data){
if(data.result) {
toastr.success(data.msg);
//if(reload)
// urlCtrl.loadByHash(location.hash);
}
else
toastr.error(data.msg);
},
dataType: "json"
});
console.log(order);
}
})
}
</script>
\ No newline at end of file
Markdown is supported
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