<?php
include("../../packages/require.php");
include("controller/controller_activity.php");
$curpage = "po";
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title><?=$title['po'];?></title>
    <?php include($global['root']."packages/head.php");?>
</head>
<body class="<?=$global['body-css'];?>">
    <div class="wrapper">

        <?php include($global['root']."section/header.php");?>

        <?php include($global['root']."section/sidebar.php");?>

        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
              <h1>
                Module Purchase Order
                <small>Track all your po here</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="<?=$path['dashboard'];?>"><i class="fa fa-dashboard"></i> Home</a></li>
                <li class="active">Purchase Order</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <!-- Default box -->
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">
                        Activity Purchase Order (<?=correctDisplay($data[0]['po_id']);?>)
                        <?php if($data[0]['po_status'] == 'open'){ ?>
                        <span class="label label-info">Open</span>
                        <?php } else if($data[0]['po_status'] == 'progress'){ ?>
                        <span class="label label-warning">In Progress</span>
                        <?php } else if($data[0]['po_status'] == 'prepared'){ ?>
                        <span class="label label-primary">Prepared</span>
                        <?php } else if($data[0]['po_status'] == 'complete'){ ?>
                        <span class="label label-success">Completed</span>
                        <?php } else { ?>
                        <span class="label label-danger">Canceled</span>
                        <?php } ?>
                    </h3>
                </div>
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li>
                            <a href="<?=$path['po-detail'].$O_po.'/';?>">Preview Purchase Order</a>
                        </li>
                        <?php if($acsp_edit == 1){ ?>
                        <?php if($data[0]['po_status'] == 'open'){ ?>
                        <li>
                            <a href="<?=$path['po-edit'].$O_po.'/';?>">Edit Purchase Order</a>
                        </li>
                        <?php } ?>
                        <?php } ?>
                        <?php if($acsp_viewact == 1){ ?>
                        <li class="active">
                            <a href="<?=$path['po-activity'].$O_po.'/';?>">Activity</a>
                        </li>
                        <?php } ?>
                        <?php if($acsp_document == 1){ ?>
                        <?php if($data[0]['po_status'] != 'open' && $data[0]['po_status'] != 'prepared' && $data[0]['po_status'] != 'cancel'){ ?>
                        <li>
                            <a href="<?=$path['po-document'].$O_po.'/';?>">Document</a>
                        </li>
                        <?php } ?>
                        <?php } ?>
                    </ul>
                </div>
                <div class="box-body">
                    <div class="row">
                        <div class="col-md-12">
                            <ul class="timeline">
                                <?php if(is_array($activitys)){ foreach($activitys as $act){ ?>
                                <li class="time-label">
                                    <span class="bg-red">
                                        <?=date("d F Y", strtotime($act['activity_create_date']));?>
                                    </span>
                                </li>
                                <?php if(is_array($act['po'])){ foreach($act['po'] as $ship){ ?>
                                <li>
                                    <?php if($ship['activity_type'] == "complete"){ ?>
                                    <i class="fa fa-check bg-green"></i>
                                    <?php } else if($ship['activity_type'] == "prepared"){ ?>
                                    <i class="fa fa-archive bg-purple"></i>
                                    <?php } else if($ship['activity_type'] == "progress"){ ?>
                                    <i class="fa fa-spinner bg-orange"></i>
                                    <?php } else if($ship['activity_type'] == "open"){ ?>
                                    <i class="fa fa-book bg-red"></i>
                                    <?php } else if($ship['activity_type'] == "cancel"){ ?>
                                    <i class="fa fa-times bg-red"></i>
                                    <?php } else if($ship['activity_type'] == "quarantine"){ ?>
                                    <i class="fa fa-bug bg-yellow"></i>
                                    <?php } else if($ship['activity_type'] == "edit"){ ?>
                                    <i class="fa fa-edit bg-blue"></i>
                                    <?php } else if($ship['activity_type'] == "notes"){ ?>
                                    <i class="fa fa-comments-o bg-aqua"></i>
                                    <?php } else if($ship['activity_type'] == "add"){ ?>
                                    <i class="fa fa-plus bg-green"></i>
                                    <?php } else if($ship['activity_type'] == "update"){ ?>
                                    <i class="fa fa-pencil bg-maroon"></i>
                                    <?php } else if($ship['activity_type'] == "delete"){ ?>
                                    <i class="fa fa-trash bg-red"></i>
                                    <?php } else if($ship['activity_type'] == "print_ship"){ ?>
                                    <i class="fa fa-print bg-blue"></i>
                                    <?php } else if($ship['activity_type'] == "upload"){ ?>
                                    <i class="fa fa-upload bg-blue"></i>
                                    <?php } else if($ship['activity_type'] == "paid"){ ?>
                                    <i class="fa fa-money bg-green"></i>
                                    <?php } else if($ship['activity_type'] == "notpaid"){ ?>
                                    <i class="fa fa-money bg-red"></i>
                                    <?php } else if($ship['activity_type'] == "invoice"){ ?>
                                    <i class="fa fa-sticky-note bg-green"></i>
                                    <?php } ?>
                                    <div class="timeline-item">
                                        <span class="time">
                                            <i class="fa fa-clock-o"></i> <?=date("h:i:s", strtotime($ship['activity_create_date']));?>
                                        </span>
                                        <h3 class="timeline-header no-border">
                                            <a href="#"><?=ucfirst($ship['activity_ref_name']);?></a>
                                        </h3>
                                        <div class="timeline-body">
                                            <?=correctDisplay($ship['activity_notes']);?>
                                        </div>
                                    </div>
                                </li>
                                <?php } } ?>
                                <?php } } ?>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="box-footer clearfix">
                    <div class="row">
                        <div class="col-sm-4 col-xs-6">
                            <div class="text-left">
                                <a href="<?=$path['po-detail'].$O_po.'/';?>" class="btn btn-default">
                                    <i class="fa fa-arrow-left"></i> Back
                                </a>
                            </div>
                        </div>
                        <div class="col-sm-8 col-xs-6">
                            <div class="text-right">
                                <input type="hidden" id="redir-url" value="<?=$path['po-activity'].$data[0]['po_id'].'/';?>">
                                <input type="hidden" id="po-id" value="<?=$data[0]['po_id'];?>">
                                <?php if($acsp_createact == 1){ ?>
                                <a href="#modalNotes" class="btn btn-primary" data-toggle="modal" data-target="#modalNotes">
                                    <i class="fa fa-comment-o"></i> Leave Notes
                                </a>
                                <?php } ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<?php include($global['root']."section/footer.php");?>

</div>
<!-- ./wrapper -->

<!-- ./wrapper -->
<div id="modalNotes" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog madd-dialog" role="document">
        <div class="modal-content madd-content">
            <div class="modal-header madd-header">
                Leave Activity Notes
            </div>
             <form id="form-create" action="<?=$path['po-activity'].'?action=notes';?>" enctype="multipart/form-data" method="post" onsubmit="return validateFormNotes();">
                <div class="modal-body madd-body">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="form-group">
                                <label for="input-note">Notes </label>
                                <textarea class="form-control" name="note" id="input-note" placeholder="Notes" rows="5" ></textarea>
                                <div id="error-note" class="error-text"></div>
                                <input type="hidden" name="po_id" value="<?=$O_po;?>">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer madd-footer">
                    <div class="row">
                        <div class="col-sm-6 col-xs-6">
                            <div class="text-left">
                                <a href="#" data-dismiss="modal" class="btn btn-default">
                                <i class="fa fa-arrow-left"></i> Cancel
                                </a>
                            </div>
                        </div>
                        <div class="col-sm-6 col-xs-6">
                            <div class="text-right">
                                <button id="btn-savenote" class="btn btn-success" type="submit">
                                    <i class="fa fa-save"></i> Save Notes
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<?php include($global['root']."packages/footer.php");?>
<script type="text/javascript">
    $(document).ready(function() {
        <?php if(is_array($vmessage)){ ?>
        <?php $c=0; foreach($vmessage as $vm){ if($c > 0){ $time =  5000 + ($c*1000); } else { $time = 5000; } ?>
            var alertText = "<?=$vm;?>";
            <?php if($valert[$c] != "success"){ ?>
            errorAlertTimer(alertText,<?=$time;?>);// error alert
            <?php } else { ?>
            successAlertTimer(alertText,<?=$time;?>);// success alert
            <?php } ?>
        <?php $c++;} ?>
        <?php } ?>
    });
    $(function () {
      $('[data-toggle="tooltip"]').tooltip()
    })
</script>
<script src="<?=$global['absolute-url'];?>module/po/js/activity.js?<?=mt_rand(10,1000);?>"></script>
</body>
</html>