【问题标题】:Php Script to distribute person working in a week用于分发一周工作人员的 PHP 脚本
【发布时间】:2016-12-09 18:54:02
【问题描述】:

我制作了这个脚本来分配一周工作的人,但没有人一天可以工作超过一次,而且必须每周工作 6 天,但仍然有一些问题导致有些人只工作 4 天,有些人多工作。 问题:如何让人们每周工作 6 天? ...我试过这样做:

<?php
$input = array("Mohamed ET Sidi",  "Ahmed ET ibrahim",  "senoud","Hamed Et abdou");
$rand_keys = array_rand($input, 4);
?>

<table  border=1>
    <tr>
        <th> Samedi </th> 
        <th> Dimanche </th> 
        <th> Lundi </th> 
        <th> Mardi </th> 
        <th> Merecredi </th> 
        <th> Jeudi </th> 
        <th> Vendredi </th>
    </tr>
<tr>
<?php

$counter_MS=0;
$counter_AI=0;
$counter_HA=0;
$last_shift = $input[2];

for($i=0;$i<7;$i++){

    echo "<td>\n";
    shuffle($input);

    // controle no one Continu working

    while ($input[0] == $last_shift) {
        shuffle($input);
    }

    // no one work 7 days a week
    while ($counter_MS == 6 && $input[0]="Mohamed ET Sidi" ||  $counter_MS == 6 && $input[1]="Mohamed ET Sidi"     || $counter_MS == 6 && $input[2]="Mohamed ET Sidi") {
        shuffle($input);
    }
    while ($counter_AI == 6 && $input[0]="Ahmed ET ibrahim" ||  $counter_MS == 6 && $input[1]="Ahmed ET ibrahim"     || $counter_MS == 6 && $input[2]="Ahmed ET ibrahim") {
        shuffle($input);
    }
     while ($counter_HA == 6 && $input[0]="Hamed Et abdou" ||  $counter_MS == 6 && $input[1]="Hamed Et abdou"     || $counter_MS == 6 && $input[2]="Hamed Et abdou") {
        shuffle($input);
    }


    if( $input[0] =="Mohamed ET Sidi" || $input[1]=="Mohamed ET Sidi" || $input[2]=="Mohamed ET Sidi")
        $counter_MS++;
    if( $input[0] =="Ahmed ET ibrahim" || $input[1]=="Ahmed ET ibrahim" || $input[2]=="Ahmed ET ibrahim")
        $counter_AI++;
    if( $input[0] =="Hamed Et abdou" || $input[1]=="Hamed Et abdou" || $input[2]=="Hamed Et abdou")
        $counter_HA++;

    echo  $input[0] ." 7H-15H\n" ;   
    echo  $input[1] ." 15H-23H\n" ;  
    echo  $input[2] ." 23H-7H\n" ;        

    $last_shift = $input[2];

    echo "</td>\n";
}
echo "Mohamed Et Sidi Worked =".$counter_MS." days";
echo "Ahmed ET ibrahim =".$counter_AI." days";
echo "Hamed Et abdou =".$counter_HA." days";
?>

【问题讨论】:

  • 你有什么问题?
  • 让人们每周工作 6 天
  • ´这是一个声明,而不是一个问题:P
  • hhhh 好的,在它之前添加“如何”
  • 仍然不是一个正确的问题

标签: php html-table


【解决方案1】:

使用这种方法ABCD 是 4 个人,所以你可以使用这种方法并构建算法

【讨论】:

  • @mohamedmed 如果你想让他们所有人做同样多的工作,我认为这是不可能的
  • 我认为如果我们换人,如果他们 6 或 8 怎么办
  • 抱歉照片颠倒了,请稍等
  • 完成,如果对您有帮助,请接受答案,@mohamedmed
  • 这有帮助,但没有给我我想要的你的算法中的问题,你每天换 4 班,我们只有 3 班……不关心人数,告诉我每周需要多少人来完成 21 个轮班,每个人都可以免费获得一天
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-12-26
  • 2013-07-17
  • 1970-01-01
  • 1970-01-01
  • 2022-07-19
  • 1970-01-01
  • 2013-11-05
相关资源
最近更新 更多