Commit 9e0792c6 authored by Clément Damiens's avatar Clément Damiens
Browse files

add list history cart with order and orderItem + add event cart valid

parent e7a2f324
......@@ -2540,11 +2540,13 @@ var list = {
initList : function(dataList, action){
var viewList="";
$.each(dataList, function(e,v){
viewList+="<h4 class='listSubtitle col-md-12 col-sm-12 col-xs-12 letter-orange'>"+Object.keys(v).length+" "+e+"</h4>";
if(action != "history")
viewList+="<h4 class='listSubtitle col-md-12 col-sm-12 col-xs-12 letter-orange'>"+Object.keys(v).length+" "+e+"</h4>";
$.each(v, function(i, data){
console.log(data);
viewList+=list.getListOf(e,data,action);
});
$("#listList").append(viewList);
$("#listList").html(viewList);
});
if(action=="history"){
$(".orderItemComment").click(function(){
......
......@@ -437,6 +437,7 @@ class CommunecterController extends Controller
),
"order"=> array(
"save" => array("href" => "/ph/co2/order/save"),
"get" => array("href" => "/ph/co2/order/get"),
),
"action"=> array(
"addaction" => array("href" => "/ph/co2/action/addaction"),
......
......@@ -19,6 +19,7 @@ class OrderController extends CommunecterController {
return array(
//'index' => 'citizenToolKit.controllers.comment.IndexAction',
'save' => 'citizenToolKit.controllers.order.SaveAction',
'get' => 'citizenToolKit.controllers.order.GetAction',
/*'abuseprocess' => 'citizenToolKit.controllers.comment.AbuseProcessAction',
'moderate' => 'citizenToolKit.controllers.comment.ModerateAction',
'countcommentsfrom' => 'citizenToolKit.controllers.comment.CountCommentsAction',
......
......@@ -167,14 +167,14 @@
}
function loadListPro(){
initBtnDash("#btn-list-pro");
data={category:["products"],actionType:"manage"};
data={category:["services","products"],actionType:"manage"};
var url = "element/list/type/"+contextData.type+"/id/"+contextData.id;
showLoader('.content-view-dashboard');
ajaxPost('.content-view-dashboard', baseUrl+'/'+moduleId+'/'+url, data, function(){},"html");
}
function loadHistory(){
initBtnDash("#btn-history");
data={category:["orderItems"],actionType:"history"};
data={category:["orders"],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");
......
......@@ -55,6 +55,33 @@ HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesTheme, Yii::app()->requ
.contentRatingComment textarea{
min-height: 100px;
}
#orderList{
bottom: 0px;
list-style: none;
border-right: 1px solid rgba(0,0,0,0.1);
min-height: 300px
}
#orderList li:hover{
cursor:pointer;
background-color:rgba(0,0,0,0.1);
border-left: 4px solid #FF9E85;
}
#orderList li{
border-left: 4px solid white;
}
/*#orderList li.active:hover{
background-color: yellow;
}*/
.orderSection .title{
font-size: 18px;
font-weight: 100;
text-transform: inherit;
}
#orderList li.active{
border-left: 4px solid #EF5B34;
/*font-weight: bold;
font-size: 20px;*/
}
</style>
<?php if($actionType=="manage"){ ?>
<div class="headerList col-md-12 col-sm-12 no-padding margin-bottom-20 margin-top-20">
......@@ -78,14 +105,43 @@ HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesTheme, Yii::app()->requ
</div>
</div>
<?php } ?>
<div id="listList" class="col-md-12 col-sm-12">
</div>
<?php if($actionType=="history"){ ?>
<ul id="orderList" class="col-md-3 col-sm-3 col-xs-3 no-padding">
<?php $i=0;
foreach ($orderList as $key => $value){
if($i==0){
$initHeader=$value;
}
$idOrder=(string)$value["_id"];
?>
<li class="orderSection <?php if($i==0) echo "active" ?> orderSection<?php echo $key ?> padding-10" data-id="<?php echo $key ?>">
<h4 class="title no-margin"><?php echo $value["name"] ?></h4>
<span><i><?php echo $value["countOrderItem"]; ?> purchase<?php if ($value["countOrderItem"] >1) echo "s" ?></i></span>
</li>
<?php $i++;
} ?>
</ul>
<div id="headerOrder" class="col-md-9 col-sm-9 col-xs-9 margin-bottom-20">
<h4 class="col-md-12 col-sm-12 orderTitle no-padding letter-orange"><?php echo $initHeader["name"] ?></h4>
<span>Price of this command: <span class="orderPrice"><?php echo $initHeader["totalPrice"] ?> <?php echo $initHeader["currency"] ?></span></span><br/>
<span class="orderPurchases"><i><?php echo $value["countOrderItem"]; ?> purchase<?php if ($value["countOrderItem"] >1) echo "s" ?></i></span>
</div>
<div id="listList" class="col-md-9 col-sm-9 col-xs-9 pull-right">
</div>
<?php } else { ?>
<div id="listList" class="col-md-12 col-sm-12">
</div>
<?php } ?>
<script type="text/javascript">
var type = "<?php echo $type; ?>";
var id = "<?php echo $id; ?>";
var view = "<?php echo @$view; ?>";
var indexStepGS = 20;
var listElement = <?php echo json_encode( $list ); ?>;
var orderList= <?php echo json_encode( @$orderList ); ?>;
var actionType="<?php echo $actionType ?>";
jQuery(document).ready(function() {
list.initList(listElement, actionType);
......@@ -93,7 +149,34 @@ HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesTheme, Yii::app()->requ
dyFObj.openForm($(this).data("form-type"),"sub");
});
bindLBHLinks();
if(actionType=="history")
initOrderEvent();
})
function initOrderEvent(){
$(".orderSection").click(function(){
showLoader('#listList');
$(".orderSection").removeClass("active");
$(this).addClass("active");
orderId=$(this).data("id");
$("#headerOrder .orderTitle").text(orderList[orderId].name);
$("#headerOrder .orderPrice").text(orderList[orderId].totalPrice+" "+orderList[orderId].currency);
s=(orderList[orderId].countOrderItem > 1) ? "s": "";
$("#headerOrder .orderPurchases").text(orderList[orderId].countOrderItem+" purchase"+s);
$.ajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/order/get/id/"+orderId,
success: function(data){
if(data.result) {
listElement = data.list;
list.initList(data.list, actionType);
}
else
toastr.error(data.msg);
},
dataType: "json"
});
});
}
/*function initList(){
var viewList="";
$.each(list, function(e,v){
......
......@@ -357,8 +357,9 @@
success: function(data){
if(data.result) {
toastr.success(data.msg);
shoppingCart={countQuantity:0};
//if(reload)
// urlCtrl.loadByHash(location.hash);
urlCtrl.loadByHash("#page.type.citoyens.id."+userId+".view.history");
}
else
toastr.error(data.msg);
......
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